From: Andreas Fink Date: Wed, 30 Dec 2009 16:25:19 +0000 (+0000) Subject: *add* more real_transparency things added... whole panel works now, but systray still... X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=be465e9a323ee71d7a6ab71040a117d3d64db813;p=chaz%2Ftint2 *add* more real_transparency things added... whole panel works now, but systray still has problems :( --- diff --git a/src/panel.c b/src/panel.c index e2bbf9f..ee3e27d 100644 --- a/src/panel.c +++ b/src/panel.c @@ -160,6 +160,13 @@ void init_panel() XMoveResizeWindow(server.dsp, p->main_win, p->posx, p->posy, p->area.width, p->area.height); } + if (!server.gc) { + XGCValues gcv; + if (real_transparency) + server.gc = XCreateGC(server.dsp, p->main_win, 0, &gcv); + else + server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv); + } //printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height); set_panel_properties(p); set_panel_background(p); @@ -479,11 +486,23 @@ void set_panel_properties(Panel *p) void set_panel_background(Panel *p) { - get_root_pixmap(); - if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap); p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth); + if (real_transparency) { + cairo_surface_t *tmp = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height); + cairo_t *cr = cairo_create(tmp); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_rectangle(cr, 0, 0, p->area.width, p->area.height); + cairo_set_source_rgba(cr, 1, 1, 1, 0); + cairo_paint (cr); + cairo_destroy (cr); + cairo_surface_destroy (tmp); + return; + } + + get_root_pixmap(); + // copy background (server.root_pmap) in panel.area.pix.pmap Window dummy; int x, y; diff --git a/src/server.c b/src/server.c index 475c0b6..f843963 100644 --- a/src/server.c +++ b/src/server.c @@ -32,6 +32,7 @@ void server_catch_error (Display *d, XErrorEvent *ev){} static char *name_trayer = 0; +int real_transparency = 0; void server_init_atoms () { @@ -97,6 +98,8 @@ void cleanup_server() { if (name_trayer) free(name_trayer); XFreeColormap(server.dsp, server.colormap); + free(server.monitor); + XFreeGC(server.dsp, server.gc); } @@ -304,7 +307,6 @@ void get_desktops() void server_init_visual() { - int real_transparency = 0; XVisualInfo *xvi; XVisualInfo templ = { .screen=server.screen, .depth=32, .class=TrueColor }; int nvi; @@ -325,8 +327,8 @@ void server_init_visual() XFree (xvi); if (visual && real_transparency) { - printf("real transparency on... depth: %d\n", server.depth); server.depth = 32; + printf("real transparency on... depth: %d\n", server.depth); server.colormap = XCreateColormap(server.dsp, server.root_win, visual, AllocNone); server.visual = visual; } diff --git a/src/server.h b/src/server.h index 2769ff8..7a86ca4 100644 --- a/src/server.h +++ b/src/server.h @@ -13,7 +13,7 @@ #include #include - +extern int real_transparency; typedef struct Global_atom { Atom _XROOTPMAP_ID; @@ -112,6 +112,7 @@ void server_refresh_main_pixmap (); void server_catch_error (Display *d, XErrorEvent *ev); void server_init_atoms (); void server_init_visual(); +void cleanup_server(); // detect root background void get_root_pixmap(); diff --git a/src/tint.c b/src/tint.c index cd0b2b8..987003c 100644 --- a/src/tint.c +++ b/src/tint.c @@ -102,8 +102,6 @@ void init (int argc, char *argv[]) server.screen = DefaultScreen (server.dsp); server.root_win = RootWindow(server.dsp, server.screen); server.desktop = server_get_current_desktop (); - XGCValues gcv; - server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv); server_init_visual(); XSetErrorHandler ((XErrorHandler) server_catch_error); @@ -151,8 +149,7 @@ void cleanup() if (config_path) g_free(config_path); if (snapshot_path) g_free(snapshot_path); - if (server.monitor) free(server.monitor); - XFreeGC(server.dsp, server.gc); + cleanup_server(); XCloseDisplay(server.dsp); } diff --git a/src/util/area.c b/src/util/area.c index 827e118..fc80a89 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -29,6 +29,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 +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; @@ -104,7 +108,18 @@ void draw (Area *a, int active) *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); + if (real_transparency) { + cairo_surface_t *tmp = cairo_xlib_surface_create (server.dsp, *pmap, server.visual, a->width, a->height); + cairo_t *cr = cairo_create(tmp); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_rectangle(cr, 0, 0, a->width, a->height); + cairo_set_source_rgba(cr, 1, 1, 1, 0); + cairo_paint (cr); + cairo_destroy (cr); + cairo_surface_destroy (tmp); + } + 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;