From: Michael Stapelberg Date: Thu, 22 Oct 2015 07:19:07 +0000 (+0200) Subject: Merge pull request #2017 from Airblader/bug-2011 X-Git-Tag: 4.12~125 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0425f488355ce0cddcbaa0e8f8e8687151e19261;hp=f25e9a7872dafa8bd13c0f661a163d440b61536a;p=i3%2Fi3 Merge pull request #2017 from Airblader/bug-2011 Activate root output if RandR request fails. --- diff --git a/src/randr.c b/src/randr.c index e4522c4d..81a33e62 100644 --- a/src/randr.c +++ b/src/randr.c @@ -604,7 +604,6 @@ void randr_query_outputs(void) { Output *output, *other, *first; xcb_randr_get_output_primary_cookie_t pcookie; xcb_randr_get_screen_resources_current_cookie_t rcookie; - resources_reply *res; /* timestamp of the configuration so that we get consistent replies to all * requests (if the configuration changes between our different calls) */ @@ -621,28 +620,31 @@ void randr_query_outputs(void) { ELOG("Could not get RandR primary output\n"); else DLOG("primary output is %08x\n", primary->output); - if ((res = xcb_randr_get_screen_resources_current_reply(conn, rcookie, NULL)) == NULL) - return; - cts = res->config_timestamp; + resources_reply *res = xcb_randr_get_screen_resources_current_reply(conn, rcookie, NULL); + if (res == NULL) { + ELOG("Could not query screen resources.\n"); + } else { + cts = res->config_timestamp; - int len = xcb_randr_get_screen_resources_current_outputs_length(res); - randr_outputs = xcb_randr_get_screen_resources_current_outputs(res); + int len = xcb_randr_get_screen_resources_current_outputs_length(res); + randr_outputs = xcb_randr_get_screen_resources_current_outputs(res); - /* Request information for each output */ - xcb_randr_get_output_info_cookie_t ocookie[len]; - for (int i = 0; i < len; i++) - ocookie[i] = xcb_randr_get_output_info(conn, randr_outputs[i], cts); + /* Request information for each output */ + xcb_randr_get_output_info_cookie_t ocookie[len]; + for (int i = 0; i < len; i++) + ocookie[i] = xcb_randr_get_output_info(conn, randr_outputs[i], cts); - /* Loop through all outputs available for this X11 screen */ - for (int i = 0; i < len; i++) { - xcb_randr_get_output_info_reply_t *output; + /* Loop through all outputs available for this X11 screen */ + for (int i = 0; i < len; i++) { + xcb_randr_get_output_info_reply_t *output; - if ((output = xcb_randr_get_output_info_reply(conn, ocookie[i], NULL)) == NULL) - continue; + if ((output = xcb_randr_get_output_info_reply(conn, ocookie[i], NULL)) == NULL) + continue; - handle_output(conn, randr_outputs[i], output, cts, res); - free(output); + handle_output(conn, randr_outputs[i], output, cts, res); + free(output); + } } /* If there's no randr output, enable the output covering the root window. */