]> Dogcows Code - chaz/tint2/commitdiff
change systray code. fixed issue 91.
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Fri, 19 Jun 2009 21:08:34 +0000 (21:08 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Fri, 19 Jun 2009 21:08:34 +0000 (21:08 +0000)
ChangeLog
src/battery/battery.c
src/clock/clock.c
src/server.c
src/systray/systraybar.c
src/systray/systraybar.h
src/tint.c
src/util/area.c

index fd40836728c9fd09ee0ae66f54403cc0e61396a9..d48a4818d3f8056f549d5a9cba66a1b0305ad4f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-06-19
+- change systray code. fixed issue 91.
+
 2009-06-18
 - patch by Christian Ruppert, configure option for battery
 
index 74e93ec5e19e29a98336114a76088528aae41ff1..d1b380fdaf54e9803ef8b94d3ae5935145fc01a7 100644 (file)
@@ -305,7 +305,7 @@ void resize_battery(void *obj)
        if(new_width > old_width || new_width < (old_width-6)) {
                // refresh and resize other objects on panel
                // we try to limit the number of refresh
-               printf("battery_width %d, new_width %d\n", battery->area.width, new_width);
+               // printf("battery_width %d, new_width %d\n", battery->area.width, new_width);
                panel->area.resize = 1;
                systray.area.resize = 1;
                panel_refresh = 1;
index 10778d4ee2d467adbb4a9e2999f41a7ec763ef47..2e54d10c0751cc7242af11f31f1c690ef3bcdd7a 100644 (file)
@@ -177,9 +177,9 @@ void resize_clock (void *obj)
    if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
       Panel *panel = ((Area*)obj)->panel;
 
-      printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
       // resize clock
       // we try to limit the number of resize
+      // printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
       clock->area.width = new_width + 1;
       clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
 
index 33e4014bf782c10cb98f5568b7e4110b9ff3dcef..8ec12978ad10f5cc057ad1eb49cd3e7b7fca9fe3 100644 (file)
@@ -268,7 +268,6 @@ next:
 
        // detect number of desktops
        // wait 15s to leave some time for window manager startup
-       // FIXME: We should also provide a small warning about not respected NETWM specs.
    for (i=0 ; i < 15 ; i++) {
       server.nb_desktop = server_get_number_of_desktop ();
       if (server.nb_desktop > 0) break;
@@ -276,7 +275,7 @@ next:
    }
    if (server.nb_desktop == 0) {
       server.nb_desktop = 1;
-      fprintf(stderr, "tint2 : cannot found number of desktop.\n");
+      fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n");
    }
        fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", server.nb_monitor, server.nb_desktop);
 }
index 9687c9aa9e71d255ab2fbba7aa5573eb3b9c0fdd..d382d8a72eaa5c5ce61e8b350f6ef8d8f0c63d67 100644 (file)
@@ -2,6 +2,7 @@
 * Tint2 : systraybar
 *
 * Copyright (C) 2009 thierry lorthiois (lorthiois@bbsoft.fr)
+* based on 'docker-1.5' from Ben Jansens.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2
@@ -46,10 +47,6 @@ Systraybar systray;
 void init_systray()
 {
        Panel *panel = &panel1[0];
-       systray.area.parent = panel;
-       systray.area.panel = panel;
-       systray.area._draw_foreground = draw_systray;
-       systray.area._resize = resize_systray;
 
        if (systray.area.on_screen)
                systray.area.on_screen = init_net();
@@ -57,11 +54,16 @@ void init_systray()
        if (!systray.area.on_screen)
                return;
 
+       systray.area.parent = panel;
+       systray.area.panel = panel;
+       systray.area._resize = resize_systray;
+
        // configure systray
        // draw only one systray (even with multi panel)
        systray.area.posy = panel->area.pix.border.width + panel->area.paddingy;
        systray.area.height = panel->area.height - (2 * systray.area.posy);
        systray.area.width = 0;
+       systray.area.redraw = 1;
 
        systray.area.posx = panel->area.width - panel->area.paddingxlr - panel->area.pix.border.width - systray.area.width;
        if (panel->clock.area.on_screen)
@@ -70,8 +72,6 @@ void init_systray()
        if (panel->battery.area.on_screen)
                systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
 #endif
-
-       systray.area.redraw = 1;
 }
 
 
@@ -93,42 +93,6 @@ void cleanup_systray()
 }
 
 
-void draw_systray(void *obj, cairo_t *c, int active)
-{
-       Systraybar *sysbar = obj;
-       Panel *panel = sysbar->area.panel;
-       TrayWindow *traywin;
-       GSList *l;
-       int icon_size;
-
-       //printf("draw_systray %d %d\n", systray.area.posx, systray.area.width);
-       icon_size = sysbar->area.height - (2 * sysbar->area.pix.border.width) - (2 * sysbar->area.paddingy);
-       for (l = systray.list_icons; l ; l = l->next) {
-               traywin = (TrayWindow*)l->data;
-
-               // watch for the icon trying to resize itself!
-               //XSelectInput(server.dsp, traywin->id, StructureNotifyMask|ResizeRedirectMask);
-               XSelectInput(server.dsp, traywin->id, StructureNotifyMask);
-
-               // position and size the icon window
-               XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
-               //printf("icon %d, %d, %d\n", traywin->x, traywin->y, icon_size);
-               // ceci intervertie les fonds : le premier icone prend le fond du dernier
-               // le dernier prend le fond de l'avant dernier, ...
-               XSetWindowBackgroundPixmap (server.dsp, panel->main_win, systray.area.pix.pmap);
-
-               // flush before clearing, otherwise the clear isn't effective.
-               XFlush(server.dsp);
-               // make sure the new child will get the right stuff in its background
-               // for ParentRelative.
-               XClearWindow(server.dsp, panel->main_win);
-
-               // show the window
-               XMapRaised(server.dsp, traywin->id);
-       }
-}
-
-
 void resize_systray(void *obj)
 {
        Systraybar *sysbar = obj;
@@ -152,8 +116,6 @@ void resize_systray(void *obj)
                systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
 #endif
 
-       systray.area.redraw = 1;
-
        posy = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
        posx = systray.area.posx + systray.area.pix.border.width + systray.area.paddingxlr;
        for (l = systray.list_icons; l ; l = l->next) {
@@ -164,10 +126,11 @@ void resize_systray(void *obj)
                traywin->width = icon_size;
                traywin->height = icon_size;
                posx += (icon_size + systray.area.paddingx);
-       }
 
-       // resize other objects on panel
-       printf("resize_systray %d %d\n", systray.area.posx, systray.area.width);
+               // position and size the icon window
+               XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
+       }
+       //printf("resize_systray %d %d\n", systray.area.posx, systray.area.width);
 }
 
 /*
@@ -227,7 +190,6 @@ int init_net()
        ev.data.l[3] = 0;
        ev.data.l[4] = 0;
        XSendEvent(server.dsp, server.root_win, False, StructureNotifyMask, (XEvent*)&ev);
-
        return 1;
 }
 
@@ -241,23 +203,6 @@ void cleanup_net()
 }
 
 
-/*
-void fix_geometry()
-{
-  GSList *it;
-  Panel *panel = systray.area.panel;
-
-  // find the proper width and height
-  width = 0;
-  height = icon_size;
-  for (it = icons; it != NULL; it = g_slist_next(it)) {
-    width += icon_size;
-  }
-
-  XResizeWindow(server.dsp, panel->main_win, width + border * 2, height + border * 2);
-}
-*/
-
 gboolean error;
 int window_error_handler(Display *d, XErrorEvent *e)
 {
@@ -270,28 +215,20 @@ int window_error_handler(Display *d, XErrorEvent *e)
 }
 
 
-gboolean icon_swallow(Window id)
+// The traywin must have its id and type set.
+gboolean add_icon(Window id)
 {
+       TrayWindow *traywin;
        XErrorHandler old;
        Panel *panel = systray.area.panel;
 
        error = FALSE;
        old = XSetErrorHandler(window_error_handler);
        XReparentWindow(server.dsp, id, panel->main_win, 0, 0);
-       printf("icon_swallow %lx %lx\n", id, panel->main_win);
        XSync(server.dsp, False);
        XSetErrorHandler(old);
 
-       return !error;
-}
-
-
-// The traywin must have its id and type set.
-gboolean add_icon(Window id)
-{
-       TrayWindow *traywin;
-
-       if (!icon_swallow(id)) {
+       if (error != FALSE) {
                fprintf(stderr, "tint2 : not icon_swallow\n");
                return FALSE;
        }
@@ -300,15 +237,19 @@ gboolean add_icon(Window id)
        traywin->id = id;
 
        systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
-       printf("ajout d'un icone %d (%lx)\n", g_slist_length(systray.list_icons), id);
+       //printf("ajout d'un icone %d (%lx)\n", g_slist_length(systray.list_icons), id);
        systray.area.resize = 1;
-       systray.area.redraw = 1;
+       systray.area.redraw = 1;
+
+       // watch for the icon trying to resize itself!
+       XSelectInput(server.dsp, traywin->id, StructureNotifyMask);
+
+       // show the window
+       XMapRaised(server.dsp, traywin->id);
 
        // changed in systray force resize on panel
-       Panel *panel = systray.area.panel;
        panel->area.resize = 1;
        panel_refresh = 1;
-
        return TRUE;
 }
 
@@ -329,8 +270,9 @@ void remove_icon(TrayWindow *traywin)
        // remove from our list
        systray.list_icons = g_slist_remove(systray.list_icons, traywin);
        g_free(traywin);
-       printf("suppression d'un icone %d\n", g_slist_length(systray.list_icons));
+       //printf("suppression d'un icone %d\n", g_slist_length(systray.list_icons));
        systray.area.resize = 1;
+       systray.area.redraw = 1;
 
        // changed in systray force resize on panel
        Panel *panel = systray.area.panel;
index f6c910ace73c802ed9f6015a2a1ed9aa06889d11..4f369716e7209398d0431b17c4aac23418df6450 100644 (file)
@@ -2,7 +2,7 @@
 * Copyright (C) 2009 thierry lorthiois (lorthiois@bbsoft.fr)
 *
 * systraybar
-* based on 'docker-1.5' from Ben Jansens
+* based on 'docker-1.5' from Ben Jansens.
 *
 **************************************************************************/
 
@@ -44,8 +44,6 @@ void net_message(XClientMessageEvent *e);
 
 void remove_icon(TrayWindow *traywin);
 
-void draw_systray(void *obj, cairo_t *c, int active);
-
 void resize_systray(void *obj);
 
 void refresh_systray();
index baaaf0326928a82b3a478d29304042830b9bc267..6f85b68caec80519d17f67dd97ea058e740c4624 100644 (file)
@@ -359,7 +359,6 @@ void event_property_notify (XEvent *e)
                        for (i=0 ; i < nb_panel ; i++) {
                                set_panel_background(&panel1[i]);
                        }
-                       refresh_systray();
          panel_refresh = 1;
       }
    }
@@ -642,11 +641,21 @@ load_config:
                        for (i=0 ; i < nb_panel ; i++) {
                                panel = &panel1[i];
 
+                               if (panel == systray.area.panel)
+                                       XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None);
+
                                if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
                                panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
 
                                refresh(&panel->area);
                           XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
+
+                               if (panel == systray.area.panel) {
+                                       // tint2 doen't draw systray icons. it just redraw background.
+                                       XSetWindowBackgroundPixmap (server.dsp, panel->main_win, panel->temp_pmap);
+                                       // force icon's refresh
+                                       refresh_systray();
+                               }
                        }
                        XFlush (server.dsp);
                }
index 61919f9ae81e301f5500b932bdeb86a7a90b9f14..1e10947f6cf1b8f2ab8c7d6c5096b984da9d3d18 100644 (file)
@@ -41,7 +41,6 @@ void refresh (Area *a)
        size(a);
 
        // don't draw transparent objects (without foreground and without background)
-
    if (a->redraw) {
           a->redraw = 0;
           //printf("draw area posx %d, width %d\n", a->posx, a->width);
This page took 0.042958 seconds and 4 git commands to generate.