]> Dogcows Code - chaz/tint2/blobdiff - src/util/area.c
*fix* more systray modifications for nice looking icons in real transparency mode
[chaz/tint2] / src / util / area.c
index 0e151e28bcf663cbfb3bbf66f7efbaef7fc78014..ae9c5413e3b87964eb2f599507fdfdd20e0e6c98 100644 (file)
 #include "server.h"
 #include "panel.h"
 
+// QUESTION: Why do we need Pixmaps for drawing? Can't we draw directly in the Window???
+// Parent could pass a cairo_surface_t to the children, and children use it, for drawing...
+
+
 // 1) resize child
 // 2) resize parent
 // 3) redraw parent
@@ -43,6 +47,11 @@ void refresh (Area *a)
        // don't draw transparent objects (without foreground and without background)
        if (a->redraw) {
                a->redraw = 0;
+               // force redraw of child
+               GSList *l;
+               for (l = a->list ; l ; l = l->next)
+                       set_redraw(l->data);
+
                //printf("draw area posx %d, width %d\n", a->posx, a->width);
                draw(a, 0);
                if (a->use_active)
@@ -50,9 +59,9 @@ void refresh (Area *a)
        }
 
        // draw current Area
-       Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
-       if (*pmap == 0) printf("empty area posx %d, width %d\n", a->posx, a->width);
-       XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
+       Pixmap pmap = (a->is_active == 0) ? (a->pix.pmap) : (a->pix_active.pmap);
+       if (pmap == 0) printf("empty area posx %d, width %d\n", a->posx, a->width);
+       XCopyArea (server.dsp, pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
 
        // and then refresh child object
        GSList *l;
@@ -67,13 +76,16 @@ void size (Area *a)
 
        if (a->resize) {
                a->resize = 0;
-               for (l = a->list; l ; l = l->next)
-                       size(l->data);
+               // force the resize of childs
+               for (l = a->list; l ; l = l->next) {
+                       Area *area = (Area*)l->data;
+                       area->resize = 1;
+                       size(area);
+               }
 
                // resize can generate a redraw
-               if (a->_resize) {
+               if (a->_resize)
                        a->_resize(a);
-               }
        }
 }
 
@@ -95,8 +107,11 @@ void draw (Area *a, int active)
        if (*pmap) XFreePixmap (server.dsp, *pmap);
        *pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
 
-       // add layer of root pixmap
-       XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
+       // add layer of root pixmap (or clear pixmap if real_transparency==true)
+       if (real_transparency)
+               clear_pixmap(*pmap, 0 ,0, a->width, a->height);
+       else
+               XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
 
        cairo_surface_t *cs;
        cairo_t *c;
@@ -236,3 +251,14 @@ void draw_rect(cairo_t *c, double x, double y, double w, double h, double r)
 }
 
 
+void clear_pixmap(Pixmap p, int x, int y, int w, int h)
+{
+       cairo_surface_t *tmp = cairo_xlib_surface_create (server.dsp, p, server.visual, w, h);
+       cairo_t *cr = cairo_create(tmp);
+       cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+       cairo_rectangle(cr, x, y, w, h);
+       cairo_set_source_rgba(cr, 1, 1, 1, 0);
+       cairo_fill(cr);
+       cairo_destroy(cr);
+       cairo_surface_destroy (tmp);
+}
This page took 0.021973 seconds and 4 git commands to generate.