Mesa (staging/21.0): wsi/x11: Use get_screen_resources_current in wsi_x11_detect_xwayland

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 20 17:22:35 UTC 2021


Module: Mesa
Branch: staging/21.0
Commit: be4b6186061f001688e0dbf8c06fa0d47c59f070
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=be4b6186061f001688e0dbf8c06fa0d47c59f070

Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Thu Jan 14 13:04:57 2021 +0100

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 <sylvain.bertrand at legeek.net>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8492>
(cherry picked from commit 23f2e7771053233df3d4c348ae46f838ccdda7ef)

---

 .pick_status.json               |  2 +-
 src/vulkan/wsi/wsi_common_x11.c | 19 ++++++++++---------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b0756c1311f..7ee2d46102c 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -454,7 +454,7 @@
         "description": "wsi/x11: Use get_screen_resources_current in wsi_x11_detect_xwayland",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "b5268d532a019c81877343f8e5390ca215db6338"
     },
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);



More information about the mesa-commit mailing list