all repos — tint2 @ eb1244a41548a68a48ea31b8d41c6eb804a97308

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Simplify systray icon management (attempt to fix issue 480)

git-svn-id: http://tint2.googlecode.com/svn/trunk@751 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
o9000 o9000
commit

eb1244a41548a68a48ea31b8d41c6eb804a97308

parent

e49e05ad69d196132dc03d55ed7dc9047af4f2cc

3 files changed, 13 insertions(+), 22 deletions(-)

jump to
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -217,8 +217,9 @@ }

} // position and size the icon window - XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size); XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size); + traywin->ignore_remaps = 2; + XReparentWindow(server.dsp, traywin->tray_id, ((Panel*)systray.area.panel)->main_win, traywin->x, traywin->y); } }

@@ -384,8 +385,7 @@ else {

set_attr.background_pixmap = ParentRelative; mask = CWBackPixmap; } - Window parent_window; - parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, visual, mask, &set_attr); + Window parent_window = panel->main_win; old = XSetErrorHandler(window_error_handler); XReparentWindow(server.dsp, id, parent_window, 0, 0); // watch for the icon trying to resize itself / closing again!

@@ -394,7 +394,6 @@ XSync(server.dsp, False);

XSetErrorHandler(old); if (error != FALSE) { fprintf(stderr, "tint2 : not icon_swallow\n"); - XDestroyWindow(server.dsp, parent_window); return FALSE; }

@@ -417,7 +416,6 @@ }

} else { fprintf(stderr, "tint2 : xembed error\n"); - XDestroyWindow(server.dsp, parent_window); return FALSE; } }

@@ -438,7 +436,6 @@ XSendEvent(server.dsp, id, False, 0xFFFFFF, &e);

} traywin = g_new0(TrayWindow, 1); - traywin->id = parent_window; traywin->tray_id = id; traywin->hide = hide; traywin->depth = attr.depth;

@@ -455,16 +452,9 @@ else

systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows); //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons)); - if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { - traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles); - XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual); - } - // show the window if (!traywin->hide) XMapWindow(server.dsp, traywin->tray_id); - if (!traywin->hide && !panel->is_hidden) - XMapRaised(server.dsp, traywin->id); // changed in systray systray.area.resize = 1;

@@ -491,7 +481,6 @@ old = XSetErrorHandler(window_error_handler);

if (!traywin->hide) XUnmapWindow(server.dsp, traywin->tray_id); XReparentWindow(server.dsp, traywin->tray_id, server.root_win, 0, 0); - XDestroyWindow(server.dsp, traywin->id); XSync(server.dsp, False); XSetErrorHandler(old); if (traywin->render_timeout)
M src/systray/systraybar.hsrc/systray/systraybar.h

@@ -34,7 +34,6 @@

typedef struct { - Window id; Window tray_id; int x, y; int width, height;

@@ -43,6 +42,7 @@ int hide;

int depth; Damage damage; timeout* render_timeout; + int ignore_remaps; } TrayWindow;
M src/tint.csrc/tint.c

@@ -832,8 +832,9 @@ for (l = systray.list_icons; l ; l = l->next) {

traywin = (TrayWindow*)l->data; if (traywin->tray_id == win) { //printf("move tray %d\n", traywin->x); - XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height); - XResizeWindow(server.dsp, traywin->tray_id, traywin->width, traywin->height); + XResizeWindow(server.dsp, traywin->tray_id, traywin->width, traywin->width); + traywin->ignore_remaps = 2; + XReparentWindow(server.dsp, traywin->tray_id, ((Panel*)systray.area.panel)->main_win, traywin->x, traywin->y); panel_refresh = 1; return; }

@@ -1264,7 +1265,11 @@ if (e.xany.window == g_tooltip.window || !systray_enabled)

break; for (it = systray.list_icons; it; it = g_slist_next(it)) { if (((TrayWindow*)it->data)->tray_id == e.xany.window) { - remove_icon((TrayWindow*)it->data); + if (((TrayWindow*)it->data)->ignore_remaps > 0) { + ((TrayWindow*)it->data)->ignore_remaps--; + } else { + remove_icon((TrayWindow*)it->data); + } break; } }

@@ -1408,10 +1413,7 @@ GSList *l;

XDamageNotifyEvent* de = &event_union.de; for (l = systray.list_icons; l ; l = l->next) { traywin = (TrayWindow*)l->data; - if ( traywin->id == de->drawable ) { - systray_render_icon(traywin); - break; - } + systray_render_icon(traywin); } } }