X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Futil%2Farea.c;h=acce72550f109e8a847b539aca23f7521fe2ab34;hb=367bf8f76227dea6e7e10e974967ae1d60cfe38e;hp=8c40aa667a339ab8f7556566e9608b53f24fe5cb;hpb=9f16bbd6cc603cbbb6e6cbd55299ce48641fa5bb;p=chaz%2Ftint2 diff --git a/src/util/area.c b/src/util/area.c index 8c40aa6..acce725 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,10 @@ #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 @@ -55,9 +60,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; @@ -72,13 +77,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); - } } } @@ -100,7 +108,9 @@ 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 + // add layer of root pixmap (or clear pixmap if real_transparency==true) + if (real_transparency) + clear_pixmap(*pmap, 0 ,0, a->width, a->height); 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; @@ -241,3 +251,10 @@ 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) +{ + Picture pict = XRenderCreatePicture(server.dsp, p, XRenderFindVisualFormat(server.dsp, server.visual), 0, 0); + XRenderColor col = { .red=0, .green=0, .blue=0, .alpha=0 }; + XRenderFillRectangle(server.dsp, PictOpSrc, pict, &col, x, y, w, h); + XRenderFreePicture(server.dsp, pict); +}