XCB plugin: query screen resources without _current

xcb_randr_get_screen_resources() and xcb_randr_get_screen_resources_current()
do basically the same, but for one case: if nothing has queried these
information ever before. So if an application is the very first client ever
to connect to an X server it may just return nothing. A call to
xcb_randr_get_screen_info_reply() will then cause the X server to allocate the
needed information and send an update notification, resulting in a second
QXcbScreen being created, but the other one is still around and probably used.

The behavior I observed with a simple test application was that the application
was not visible on the screen when it was the first client ever on the X
server. Killing the application and starting it again made it work just fine.

Change-Id: Id64f267e8ebcfa5b39d21d98307170a09e5169df
Reviewed-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
bb10
Rolf Eike Beer 2013-12-05 17:33:24 +01:00 committed by The Qt Project
parent cbf5aa625d
commit 6d858a0fdb
1 changed files with 6 additions and 6 deletions

View File

@ -144,23 +144,23 @@ void QXcbConnection::updateScreens()
xcb_generic_error_t *error = NULL;
xcb_randr_get_output_primary_cookie_t primaryCookie =
xcb_randr_get_output_primary(xcb_connection(), xcbScreen->root);
xcb_randr_get_screen_resources_current_cookie_t resourcesCookie =
xcb_randr_get_screen_resources_current(xcb_connection(), xcbScreen->root);
xcb_randr_get_screen_resources_cookie_t resourcesCookie =
xcb_randr_get_screen_resources(xcb_connection(), xcbScreen->root);
xcb_randr_get_output_primary_reply_t *primary =
xcb_randr_get_output_primary_reply(xcb_connection(), primaryCookie, &error);
if (!primary || error) {
qWarning("QXcbConnection: Failed to get the primary output of the screen");
free(error);
} else {
xcb_randr_get_screen_resources_current_reply_t *resources =
xcb_randr_get_screen_resources_current_reply(xcb_connection(), resourcesCookie, &error);
xcb_randr_get_screen_resources_reply_t *resources =
xcb_randr_get_screen_resources_reply(xcb_connection(), resourcesCookie, &error);
if (!resources || error) {
qWarning("QXcbConnection: Failed to get the screen resources");
free(error);
} else {
xcb_timestamp_t timestamp = resources->config_timestamp;
outputCount = xcb_randr_get_screen_resources_current_outputs_length(resources);
xcb_randr_output_t *outputs = xcb_randr_get_screen_resources_current_outputs(resources);
outputCount = xcb_randr_get_screen_resources_outputs_length(resources);
xcb_randr_output_t *outputs = xcb_randr_get_screen_resources_outputs(resources);
for (int i = 0; i < outputCount; i++) {
xcb_randr_get_output_info_reply_t *output =