]> git.sur5r.net Git - i3/i3/commitdiff
When no screens are found, don’t hog the CPU. Also, wait longer for screens (10 seconds).
authorMichael Stapelberg <michael@stapelberg.de>
Mon, 7 Dec 2009 15:31:49 +0000 (16:31 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 7 Dec 2009 15:31:49 +0000 (16:31 +0100)
Instead of just going on, i3 will exit cleanly now, putting an
appropriate message into the logfile.

src/xinerama.c

index 6c87e775028a8905b7debb554e7ecb8cc5ec3ab6..06a861f3c9980392b2a0767d21a930790581d4cd 100644 (file)
@@ -188,7 +188,7 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
          * which the X server does not return any screens, such as when rotating
          * screens), but not longer than 5 seconds (strictly speaking, only four
          * seconds of trying are guaranteed due to the 1-second-resolution) */
-        while ((time(NULL) - before_trying) < 5) {
+        while ((time(NULL) - before_trying) < 10) {
                 reply = xcb_xinerama_query_screens_reply(conn, xcb_xinerama_query_screens_unchecked(conn), NULL);
                 if (!reply) {
                         LOG("Couldn't get Xinerama screens\n");
@@ -227,11 +227,19 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
 
                 if (num_screens == 0) {
                         LOG("No screens found. This is weird. Trying again...\n");
+                        /* Give the scheduler a chance to do something else
+                         * and don’t hog the CPU */
+                        usleep(250);
                         continue;
                 }
 
                 break;
         }
+
+        if (num_screens == 0) {
+                LOG("No screens found for 10 seconds. Please fix your setup. i3 will exit now.\n");
+                exit(0);
+        }
 }
 
 /*