]> Dogcows Code - chaz/openbox/blobdiff - render/render.c
add keybinds for switching workspaces
[chaz/openbox] / render / render.c
index ebd681eabc3a4981b489cc91d87b51e5e9841e56..12b373ce70e7b0ad57efd36549559104526d19b1 100644 (file)
@@ -4,6 +4,7 @@
 #include "render.h"
 #include "gradient.h"
 #include "font.h"
+#include "mask.h"
 #include "../kernel/openbox.h"
 
 int render_depth;
@@ -53,18 +54,19 @@ void render_startup(void)
     }  
 }
 
-void x_paint(Window win, Appearance *l, int w, int h)
+void x_paint(Window win, Appearance *l, int x, int y, int w, int h)
 {
     int i;
     XImage *im;
+    Pixmap oldp;
 
     if (w <= 0 || h <= 0) return;
 
     g_assert(l->surface.type == Surface_Planar);
 //    printf("painting window %ld\n", win);
 
-    if (l->pixmap != None) XFreePixmap(ob_display, l->pixmap);
-    l->pixmap = XCreatePixmap(ob_display, ob_root, w, h, render_depth);
+    oldp = l->pixmap; /* save to free after changing the visible pixmap */
+    l->pixmap = XCreatePixmap(ob_display, ob_root, x+w, y+h, render_depth);
     g_assert(l->pixmap != None);
 
     if (l->xftdraw != NULL)
@@ -80,6 +82,23 @@ void x_paint(Window win, Appearance *l, int w, int h)
     if (l->surface.data.planar.grad == Background_Solid)
         gradient_solid(l, w, h);
     else gradient_render(&l->surface, w, h);
+
+/*reduce depth here...
+  also, this is not the right place for this code, it's only here so
+  text rendering shows up for now.
+*/
+    if (l->surface.data.planar.grad != Background_Solid) {
+        im = XCreateImage(ob_display, render_visual, render_depth,
+                          ZPixmap, 0, NULL, w, h, 32, 0);
+        g_assert(im != None);
+        im->byte_order = endian;
+        im->data = l->surface.data.planar.pixel_data;
+        XPutImage(ob_display, l->pixmap, DefaultGC(ob_display, ob_screen),
+                  im, 0, 0, x, y, w, h);
+        im->data = NULL;
+        XDestroyImage(im);
+    }
+
     for (i = 0; i < l->textures; i++) {
         switch (l->texture[i].type) {
         case Text:
@@ -89,22 +108,16 @@ void x_paint(Window win, Appearance *l, int w, int h)
             }
             font_draw(l->xftdraw, &l->texture[i].data.text);
         break;
+        case Bitmask:
+            if (l->texture[i].data.mask.color->gc == None)
+                color_allocate_gc(l->texture[i].data.mask.color);
+            mask_draw(l->pixmap, &l->texture[i].data.mask, w, h);
+        break;
         }
     }
-//reduce depth
-    if (l->surface.data.planar.grad != Background_Solid) {
-        im = XCreateImage(ob_display, render_visual, render_depth,
-                          ZPixmap, 0, NULL, w, h, 32, 0);
-        g_assert(im != None);
-        im->byte_order = endian;
-        im->data = l->surface.data.planar.pixel_data;
-        XPutImage(ob_display, l->pixmap, DefaultGC(ob_display, ob_screen),
-                  im, 0, 0, 0, 0, w, h);
-        im->data = NULL;
-        XDestroyImage(im);
-    }
     XSetWindowBackgroundPixmap(ob_display, win, l->pixmap);
     XClearWindow(ob_display, win);
+    if (oldp != None) XFreePixmap(ob_display, oldp);
 }
 
 /*
This page took 0.021028 seconds and 4 git commands to generate.