]> Dogcows Code - chaz/openbox/commitdiff
support clients which use true transparency 32-bit visuals.
authorDana Jansens <danakj@orodu.net>
Fri, 2 Mar 2007 06:01:16 +0000 (06:01 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 2 Mar 2007 06:01:16 +0000 (06:01 +0000)
this requires that when a client is using a 32-bit visual, we have to
make the frame windows that sit underneath it to use the same visual (and a
colormap which matches it)

openbox/client.c
openbox/frame.c
openbox/frame.h

index efd5dbc91717c745232252603d540b97f9241de8..056a9780c75ee1672a47c3fa1cf97ec244fc84e4 100644 (file)
@@ -312,7 +312,7 @@ void client_manage(Window window)
     XChangeSaveSet(ob_display, window, SetModeInsert);
 
     /* create the decoration frame for the client window */
-    self->frame = frame_new();
+    self->frame = frame_new(self);
 
     frame_grab_client(self->frame, self);
 
index 2c1152ee0f3f1ee4b9614fd5a30abdb4eefa2ead..57a1b8ab9ad1073d3beaf06555e7a56aa4649d38 100644 (file)
@@ -47,59 +47,95 @@ static gboolean flash_timeout(gpointer data);
 static void set_theme_statics(ObFrame *self);
 static void free_theme_statics(ObFrame *self);
 
-static Window createWindow(Window parent, gulong mask,
-                           XSetWindowAttributes *attrib)
+static Window createWindow(Window parent, Visual *visual,
+                           gulong mask, XSetWindowAttributes *attrib)
 {
     return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
-                         RrDepth(ob_rr_inst), InputOutput,
-                         RrVisual(ob_rr_inst), mask, attrib);
+                         (visual ? 32 : RrDepth(ob_rr_inst)), InputOutput,
+                         (visual ? visual : RrVisual(ob_rr_inst)),
+                         mask, attrib);
                        
 }
 
-ObFrame *frame_new()
+static Visual *check_32bit_client(ObClient *c)
+{
+    XWindowAttributes wattrib;
+    Status ret;
+
+    ret = XGetWindowAttributes(ob_display, c->window, &wattrib);
+    g_assert(ret != BadDrawable);
+    g_assert(ret != BadWindow);
+
+    if (wattrib.depth == 32)
+        return wattrib.visual;
+    return NULL;
+}
+
+ObFrame *frame_new(ObClient *client)
 {
     XSetWindowAttributes attrib;
     gulong mask;
     ObFrame *self;
+    Visual *visual;
 
     self = g_new0(ObFrame, 1);
 
     self->obscured = TRUE;
 
-    /* create all of the decor windows */
+    visual = check_32bit_client(client);
+
+    /* create the non-visible decor windows */
+
     mask = CWEventMask;
+    if (visual) {
+        /* client has a 32-bit visual */
+        mask |= CWColormap | CWBackPixel | CWBorderPixel;
+        /* create a colormap with the visual */
+        self->colormap = attrib.colormap =
+            XCreateColormap(ob_display,
+                            RootWindow(ob_display, ob_screen),
+                            visual, AllocNone);
+        attrib.background_pixel = BlackPixel(ob_display, 0);
+        attrib.border_pixel = BlackPixel(ob_display, 0);
+    }
     attrib.event_mask = FRAME_EVENTMASK;
-    self->window = createWindow(RootWindow(ob_display, ob_screen),
+    self->window = createWindow(RootWindow(ob_display, ob_screen), visual,
                                 mask, &attrib);
+    mask &= ~CWEventMask;
+    self->plate = createWindow(self->window, visual, mask, &attrib);
 
-    mask = 0;
-    self->plate = createWindow(self->window, mask, &attrib);
+    /* create the visible decor windows */
 
     mask = CWEventMask;
+    if (visual) {
+        /* client has a 32-bit visual */
+        mask |= CWColormap | CWBackPixel | CWBorderPixel;
+        attrib.colormap = RrColormap(ob_rr_inst);
+    }
     attrib.event_mask = ELEMENT_EVENTMASK;
-    self->title = createWindow(self->window, mask, &attrib);
+    self->title = createWindow(self->window, NULL, mask, &attrib);
 
     mask |= CWCursor;
     attrib.cursor = ob_cursor(OB_CURSOR_NORTHWEST);
-    self->tlresize = createWindow(self->title, mask, &attrib);
+    self->tlresize = createWindow(self->title, NULL, mask, &attrib);
     attrib.cursor = ob_cursor(OB_CURSOR_NORTHEAST);
-    self->trresize = createWindow(self->title, mask, &attrib);
+    self->trresize = createWindow(self->title, NULL, mask, &attrib);
 
     mask &= ~CWCursor;
-    self->label = createWindow(self->title, mask, &attrib);
-    self->max = createWindow(self->title, mask, &attrib);
-    self->close = createWindow(self->title, mask, &attrib);
-    self->desk = createWindow(self->title, mask, &attrib);
-    self->shade = createWindow(self->title, mask, &attrib);
-    self->icon = createWindow(self->title, mask, &attrib);
-    self->iconify = createWindow(self->title, mask, &attrib);
-    self->handle = createWindow(self->window, mask, &attrib);
+    self->label = createWindow(self->title, NULL, mask, &attrib);
+    self->max = createWindow(self->title, NULL, mask, &attrib);
+    self->close = createWindow(self->title, NULL, mask, &attrib);
+    self->desk = createWindow(self->title, NULL, mask, &attrib);
+    self->shade = createWindow(self->title, NULL, mask, &attrib);
+    self->icon = createWindow(self->title, NULL, mask, &attrib);
+    self->iconify = createWindow(self->title, NULL, mask, &attrib);
+    self->handle = createWindow(self->window, NULL, mask, &attrib);
 
     mask |= CWCursor;
     attrib.cursor = ob_cursor(OB_CURSOR_SOUTHWEST);
-    self->lgrip = createWindow(self->handle, mask, &attrib);
+    self->lgrip = createWindow(self->handle, NULL, mask, &attrib);
     attrib.cursor = ob_cursor(OB_CURSOR_SOUTHEAST);
-    self->rgrip = createWindow(self->handle, mask, &attrib); 
+    self->rgrip = createWindow(self->handle, NULL, mask, &attrib); 
 
     self->focused = FALSE;
 
@@ -181,6 +217,8 @@ static void frame_free(ObFrame *self)
     free_theme_statics(self);
 
     XDestroyWindow(ob_display, self->window);
+    if (self->colormap)
+        XFreeColormap(ob_display, self->colormap);
 
     g_free(self);
 }
index af01bfade591fd305cdd37506c13142784dbbd7a..b48c07cacfee521bca50146f395976ba57fd2fd4 100644 (file)
@@ -98,6 +98,8 @@ struct _ObFrame
     Window    tlresize;
     Window    trresize;
 
+    Colormap  colormap;
+
     RrAppearance *a_unfocused_title;
     RrAppearance *a_focused_title;
     RrAppearance *a_unfocused_label;
@@ -142,7 +144,7 @@ struct _ObFrame
     GTimeVal  flash_end;
 };
 
-ObFrame *frame_new();
+ObFrame *frame_new(struct _ObClient *c);
 void frame_show(ObFrame *self);
 void frame_hide(ObFrame *self);
 void frame_adjust_theme(ObFrame *self);
This page took 0.035708 seconds and 4 git commands to generate.