[waffle] [PATCH 2/2] x11: Support visuals that don't match root visual

Pauli Nieminen pauli.nieminen at linux.intel.com
Thu May 24 07:33:37 PDT 2012


If window is created with a visual that doesn't match parent window
visual X11 protocol requires application to set depth and broder pixel
for the new window.

Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com>
---
 src/waffle/x11/x11.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/waffle/x11/x11.c b/src/waffle/x11/x11.c
index 1a9394b..6c4776d 100644
--- a/src/waffle/x11/x11.c
+++ b/src/waffle/x11/x11.c
@@ -57,6 +57,22 @@ x11_display_disconnect(Display *dpy)
     return !error;
 }
 
+uint8_t
+x11_get_depth_for_visual(xcb_connection_t *conn, const xcb_screen_t *screen,
+		xcb_visualid_t id)
+{
+	xcb_depth_iterator_t depth = xcb_screen_allowed_depths_iterator(screen);
+	for (; depth.rem; xcb_depth_next(&depth)) {
+		xcb_visualtype_iterator_t visual =
+			xcb_depth_visuals_iterator (depth.data);
+		for (; visual.rem; xcb_visualtype_next(&visual)) {
+			if (visual.data->visual_id == id)
+				return depth.data->depth;
+		}
+	}
+	return 0;
+}
+
 xcb_window_t
 x11_window_create(
         xcb_connection_t *conn,
@@ -95,12 +111,13 @@ x11_window_create(
     const uint32_t event_mask = XCB_EVENT_MASK_BUTTON_PRESS
                                | XCB_EVENT_MASK_EXPOSURE
                                | XCB_EVENT_MASK_KEY_PRESS;
-    const uint32_t attrib_mask = XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
-    const uint32_t attrib_list[] = {event_mask, colormap, 0};
+    const uint32_t attrib_mask = XCB_CW_EVENT_MASK | XCB_CW_COLORMAP |
+	    XCB_CW_BORDER_PIXEL;
+    const uint32_t attrib_list[] = {0, event_mask, colormap, 0};
 
     xcb_void_cookie_t create_cookie = xcb_create_window_checked(
             conn,
-            XCB_COPY_FROM_PARENT, // depth
+            x11_get_depth_for_visual(conn, screen, visual_id), // depth
             window,
             screen->root, // parent
             0, 0, // x, y
-- 
1.7.5.4



More information about the waffle mailing list