From: Thierry Lorthiois Date: Sun, 17 Jan 2010 13:43:44 +0000 (+0000) Subject: detect start/stop composite manager. and answer to question. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=f19a767f91b6e498cec2c07792b5d77658bc889b;p=chaz%2Ftint2 detect start/stop composite manager. and answer to question. --- diff --git a/src/server.c b/src/server.c index 2d7de6e..18000f2 100644 --- a/src/server.c +++ b/src/server.c @@ -92,6 +92,10 @@ void server_init_atoms () server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False); server.atom.XdndPosition = XInternAtom(server.dsp, "XdndPosition", False); server.atom.XdndStatus = XInternAtom(server.dsp, "XdndStatus", False); + + server.colormap = 0; + server.monitor = 0; + server.gc = 0; } @@ -328,18 +332,23 @@ void server_init_visual() XFree (xvi); // check composite manager - if (XGetSelectionOwner(server.dsp, server.atom._NET_WM_CM_S0) == None) - real_transparency = 0; - else - real_transparency = 1; + server.composite_manager = XGetSelectionOwner(server.dsp, server.atom._NET_WM_CM_S0); + if (server.colormap) + XFreeColormap(server.dsp, server.colormap); - if (visual && real_transparency) { + if (visual && server.composite_manager != None) { + XSetWindowAttributes attrs; + attrs.event_mask = StructureNotifyMask; + XChangeWindowAttributes (server.dsp, server.composite_manager, CWEventMask, &attrs); + + real_transparency = 1; 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; } else { + real_transparency = 0; server.depth = DefaultDepth(server.dsp, server.screen); printf("real transparency off.... depth: %d\n", server.depth); server.colormap = DefaultColormap(server.dsp, server.screen); diff --git a/src/server.h b/src/server.h index 11ea89b..3da2f04 100644 --- a/src/server.h +++ b/src/server.h @@ -84,6 +84,7 @@ typedef struct { Display *dsp; Window root_win; + Window composite_manager; // current desktop int desktop; int screen; diff --git a/src/tint.c b/src/tint.c index c95c317..3a7b82b 100644 --- a/src/tint.c +++ b/src/tint.c @@ -636,6 +636,7 @@ void dnd_message(XClientMessageEvent *e) int main (int argc, char *argv[]) { XEvent e; + XClientMessageEvent *ev; fd_set fdset; int x11_fd, i; Panel *panel; @@ -677,6 +678,8 @@ int main (int argc, char *argv[]) panel_refresh = 0; // QUESTION: do we need this first refresh_systray, because we check refresh_systray once again later... + // ANSWER: yes, panel->temp_pmap is freeded in the loop. + // we change background to None to avoid tray icon using freeded pixmap. if (refresh_systray) { panel = (Panel*)systray.area.panel; XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None); @@ -781,6 +784,12 @@ int main (int argc, char *argv[]) break; case UnmapNotify: case DestroyNotify: + if (e.xany.window == server.composite_manager) { + printf("Stop composite.\n"); + //signal_pending = SIGUSR2; + server_init_visual(); + break; + } if (e.xany.window == g_tooltip.window || !systray.area.on_screen) break; for (it = systray.list_icons; it; it = g_slist_next(it)) { @@ -792,6 +801,15 @@ int main (int argc, char *argv[]) break; case ClientMessage: + ev = &e; + if (ev->data.l[1] == server.atom._NET_WM_CM_S0) { + if (ev->data.l[2] == None) + printf("Stop composite 2.\n"); + else + printf("Start composite.\n"); + server_init_visual(); + //signal_pending = SIGUSR2; + } if (!systray.area.on_screen) break; if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) { net_message(&e.xclient);