From 1a53cc067b1087815fb99297d65e0b058c187d18 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 7 Dec 2009 16:31:49 +0100 Subject: [PATCH] =?UTF-8?q?When=20no=20screens=20are=20found,=20don?= =?UTF-8?q?=E2=80=99t=20hog=20the=20CPU.=20Also,=20wait=20longer=20for=20s?= =?UTF-8?q?creens=20(10=20seconds).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of just going on, i3 will exit cleanly now, putting an appropriate message into the logfile. --- src/xinerama.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/xinerama.c b/src/xinerama.c index 6c87e775..06a861f3 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -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); + } } /*