From a379b8138a3794d21000f300bd254010ad95277b Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <fourdan.olivier@wanadoo.fr>
Date: Tue, 24 Oct 2006 20:45:10 +0000
Subject: [PATCH] Fix visual/depth/colormap with and without render.

(Old svn revision: 23503)
---
 src/client.c | 27 ++++++++++++++++++++++-----
 src/screen.c | 13 ++++---------
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/client.c b/src/client.c
index 65ae97e1b..0e0026ce5 100644
--- a/src/client.c
+++ b/src/client.c
@@ -1493,8 +1493,6 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture)
     c->y = attr.y;
     c->width = attr.width;
     c->height = attr.height;
-    c->visual = attr.visual;
-    c->depth  = attr.depth;
 
 #ifdef HAVE_LIBSTARTUP_NOTIFICATION
     c->startup_id = NULL;
@@ -1655,11 +1653,24 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture)
      */
     clientApplyInitialState (c);
 
-    valuemask = CWEventMask|CWBitGravity|CWWinGravity|CWColormap;
+    valuemask = CWEventMask|CWBitGravity|CWWinGravity;
     attributes.event_mask = (FRAME_EVENT_MASK | POINTER_EVENT_MASK);
     attributes.win_gravity = StaticGravity;
     attributes.bit_gravity = StaticGravity;
-    attributes.colormap = attr.colormap;
+
+#ifdef HAVE_RENDER
+    if (display_info->have_render)
+    {
+        c->visual = attr.visual;
+        c->depth  = attr.depth;
+        attributes.colormap = attr.colormap;
+        valuemask |= CWColormap;
+    }
+    else
+    {
+        c->visual = screen_info->visual;
+        c->depth  = screen_info->depth;
+    }
 
 #ifdef HAVE_COMPOSITOR
     if (c->depth == 32)
@@ -1669,7 +1680,13 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture)
         attributes.background_pixel = 0;
         valuemask |= CWBackPixmap|CWBackPixel|CWBorderPixel;
     }
-#endif
+#endif /* HAVE_COMPOSITOR */
+
+#else  /* HAVE_RENDER */
+    /* We don't support multiple depth/visual w/out render */
+    c->visual = screen_info->visual;
+    c->depth  = screen_info->depth;
+#endif /* HAVE_RENDER */
 
     c->frame =
         XCreateWindow (display_info->dpy, screen_info->xroot, 0, 0, 1, 1, 0,
diff --git a/src/screen.c b/src/screen.c
index 329001113..e70207f52 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -53,7 +53,6 @@ myScreenInit (DisplayInfo *display_info, GdkScreen *gscr, unsigned long event_ma
 #ifdef ENABLE_KDE_SYSTRAY_PROXY
     gchar selection[32];
 #endif
-    XWindowAttributes attr;
     ScreenInfo *screen_info;
     GdkWindow *event_win;
     PangoLayout *layout;
@@ -103,14 +102,10 @@ myScreenInit (DisplayInfo *display_info, GdkScreen *gscr, unsigned long event_ma
     screen_info->xroot = (Window) GDK_DRAWABLE_XID(gdk_screen_get_root_window (gscr));
     screen_info->screen = gdk_screen_get_number (gscr);
     screen_info->cmap = GDK_COLORMAP_XCOLORMAP(gdk_screen_get_rgb_colormap (gscr));
-
-    /* Retrieve size, depth and visual attributes from root win of screen */
-    XGetWindowAttributes (display_info->dpy, screen_info->xroot, &attr);
-    screen_info->width = attr.width;
-    screen_info->height = attr.height;
-    screen_info->depth = attr.depth;
-    screen_info->visual = attr.visual;
- 
+    screen_info->depth = DefaultDepth (display_info->dpy, screen_info->screen);
+    screen_info->width = WidthOfScreen (screen_info->xscreen);
+    screen_info->height = HeightOfScreen (screen_info->xscreen);
+    screen_info->visual = DefaultVisual (display_info->dpy, screen_info->screen);
     screen_info->current_ws = 0;
     screen_info->previous_ws = 0;
     screen_info->current_ws = 0;
-- 
GitLab