From 23f2e7771053233df3d4c348ae46f838ccdda7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 14 Jan 2021 13:04:57 +0100 Subject: [PATCH] wsi/x11: Use get_screen_resources_current in wsi_x11_detect_xwayland get_screen_resources may trigger an active probe of display connections in the X server, which may take significant time and/or result in log file spam. Fixes: b5268d532a01 "wsi/x11: Detect Xwayland" Reported-by: Sylvain Bertrand Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/vulkan/wsi/wsi_common_x11.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 124377dd6cb..165b366e2df 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -120,30 +120,31 @@ static bool wsi_x11_detect_xwayland(xcb_connection_t *conn) { xcb_randr_query_version_cookie_t ver_cookie = - xcb_randr_query_version_unchecked(conn, 1, 2); + xcb_randr_query_version_unchecked(conn, 1, 3); xcb_randr_query_version_reply_t *ver_reply = xcb_randr_query_version_reply(conn, ver_cookie, NULL); - bool has_randr_v1_2 = ver_reply && (ver_reply->major_version > 1 || - ver_reply->minor_version >= 2); + bool has_randr_v1_3 = ver_reply && (ver_reply->major_version > 1 || + ver_reply->minor_version >= 3); free(ver_reply); - if (!has_randr_v1_2) + if (!has_randr_v1_3) return false; const xcb_setup_t *setup = xcb_get_setup(conn); xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup); - xcb_randr_get_screen_resources_cookie_t gsr_cookie = - xcb_randr_get_screen_resources_unchecked(conn, iter.data->root); - xcb_randr_get_screen_resources_reply_t *gsr_reply = - xcb_randr_get_screen_resources_reply(conn, gsr_cookie, NULL); + xcb_randr_get_screen_resources_current_cookie_t gsr_cookie = + xcb_randr_get_screen_resources_current_unchecked(conn, iter.data->root); + xcb_randr_get_screen_resources_current_reply_t *gsr_reply = + xcb_randr_get_screen_resources_current_reply(conn, gsr_cookie, NULL); if (!gsr_reply || gsr_reply->num_outputs == 0) { free(gsr_reply); return false; } - xcb_randr_output_t *randr_outputs = xcb_randr_get_screen_resources_outputs(gsr_reply); + xcb_randr_output_t *randr_outputs = + xcb_randr_get_screen_resources_current_outputs(gsr_reply); xcb_randr_get_output_info_cookie_t goi_cookie = xcb_randr_get_output_info(conn, randr_outputs[0], gsr_reply->config_timestamp); free(gsr_reply);