[waffle] [PATCH] x11: fix for a non-zero default screen

Marek Olšák maraeo at gmail.com
Tue Aug 19 15:10:52 PDT 2014


From: Marek Olšák <marek.olsak at amd.com>

---
 src/waffle/x11/x11_window.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/waffle/x11/x11_window.c b/src/waffle/x11/x11_window.c
index 582cc02..b2e3631 100644
--- a/src/waffle/x11/x11_window.c
+++ b/src/waffle/x11/x11_window.c
@@ -53,6 +53,19 @@ x11_winddow_get_depth(xcb_connection_t *conn,
     return 0;
 }
 
+static xcb_screen_t *
+get_xcb_screen(const xcb_setup_t *setup, int screen)
+{
+    xcb_screen_iterator_t iter;
+
+    iter = xcb_setup_roots_iterator(setup);
+    for (; iter.rem; --screen, xcb_screen_next(&iter))
+        if (screen == 0)
+            return iter.data;
+
+    return NULL;
+}
+
 bool
 x11_window_init(struct x11_window *self,
                 struct x11_display *dpy,
@@ -75,7 +88,7 @@ x11_window_init(struct x11_window *self,
         goto error;
     }
 
-    const xcb_screen_t *screen = xcb_setup_roots_iterator(setup).data;
+    const xcb_screen_t *screen = get_xcb_screen(setup, dpy->screen);
     if (!screen) {
         wcore_errorf(WAFFLE_ERROR_UNKNOWN, "failed to get xcb screen");
         goto error;
-- 
1.9.1



More information about the waffle mailing list