]> Dogcows Code - chaz/tint2/blobdiff - src/tint.c
fixed issue 150
[chaz/tint2] / src / tint.c
index 70c6f5bd314dd83df088f987c39211695c4a73d1..c85bd1bac8f4cbb9dbd4358098c9ab769bb90513 100644 (file)
@@ -37,6 +37,7 @@
 #include "taskbar.h"
 #include "systraybar.h"
 #include "panel.h"
+#include "tooltip.h"
 
 
 void signal_handler(int sig)
@@ -72,6 +73,7 @@ void init (int argc, char *argv[])
        signal(SIGTERM, signal_handler);
        signal(SIGHUP, signal_handler);
        signal(SIGCHLD, SIG_IGN);               // don't have to wait() after fork()
+       signal(SIGALRM, tooltip_sighandler);
 
        // set global data
        memset(&server, 0, sizeof(Server_global));
@@ -134,25 +136,26 @@ void cleanup()
 
 Taskbar *click_taskbar (Panel *panel, int x, int y)
 {
-       GSList *l0;
-       Taskbar *tskbar = NULL;
+       Taskbar *tskbar;
+       int i;
+
        if (panel_horizontal) {
-               for (l0 = panel->area.list; l0 ; l0 = l0->next) {
-                       tskbar = l0->data;
+               for (i=0; i < panel->nb_desktop ; i++) {
+                       tskbar = &panel->taskbar[i];
                        if (!tskbar->area.on_screen) continue;
                        if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
-                               break;
+                               return tskbar;
                }
        }
        else {
-               for (l0 = panel->area.list; l0 ; l0 = l0->next) {
-                       tskbar = l0->data;
+               for (i=0; i < panel->nb_desktop ; i++) {
+                       tskbar = &panel->taskbar[i];
                        if (!tskbar->area.on_screen) continue;
                        if (y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
-                               break;
+                               return tskbar;
                }
        }
-       return tskbar;
+       return NULL;
 }
 
 
@@ -166,7 +169,7 @@ Task *click_task (Panel *panel, int x, int y)
                        Task *tsk;
                        for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
                                tsk = l0->data;
-                               if (x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
+                               if (tsk->area.on_screen && x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
                                        return tsk;
                                }
                        }
@@ -175,7 +178,7 @@ Task *click_task (Panel *panel, int x, int y)
                        Task *tsk;
                        for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
                                tsk = l0->data;
-                               if (y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
+                               if (tsk->area.on_screen && y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
                                        return tsk;
                                }
                        }
@@ -265,8 +268,7 @@ void event_button_press (XEvent *e)
        Panel *panel = get_panel(e->xany.window);
        if (!panel) return;
 
-       if (panel_mode == MULTI_DESKTOP)
-               task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);
+       task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);
 
        if (wm_menu && !task_drag && !click_clock(panel, e->xbutton.x, e->xbutton.y) && (e->xbutton.button != 1) ) {
                // forward the click to the desktop window (thanks conky)
@@ -390,33 +392,37 @@ void event_property_notify (XEvent *e)
                }
                // Change desktop
                else if (at == server.atom._NET_CURRENT_DESKTOP) {
+                       int old_desktop = server.desktop;
                        server.desktop = server_get_current_desktop ();
                        for (i=0 ; i < nb_panel ; i++) {
                                Panel *panel = &panel1[i];
                                if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
-                                       // redraw taskbar
+                                       // redraw both taskbar
+                                       panel->taskbar[old_desktop].area.is_active = 0;
+                                       panel->taskbar[old_desktop].area.redraw = 1;
+                                       panel->taskbar[server.desktop].area.is_active = 1;
+                                       panel->taskbar[server.desktop].area.redraw = 1;
                                        panel_refresh = 1;
-                                       Taskbar *tskbar;
-                                       Task *tsk;
-                                       GSList *l;
-                                       for (j=0 ; j < panel->nb_desktop ; j++) {
-                                               tskbar = &panel->taskbar[j];
-                                               if (tskbar->area.is_active) {
-                                                       tskbar->area.is_active = 0;
-                                                       tskbar->area.redraw = 1;
-                                                       for (l = tskbar->area.list; l ; l = l->next) {
-                                                               tsk = l->data;
-                                                               tsk->area.redraw = 1;
-                                                       }
-                                               }
-                                               if (j == server.desktop) {
-                                                       tskbar->area.is_active = 1;
-                                                       tskbar->area.redraw = 1;
-                                                       for (l = tskbar->area.list; l ; l = l->next) {
-                                                               tsk = l->data;
-                                                               tsk->area.redraw = 1;
-                                                       }
-                                               }
+                               }
+                               // check ALLDESKTOP task => resize taskbar
+                               Taskbar *tskbar;
+                               Task *tsk;
+                               GSList *l;
+                               tskbar = &panel->taskbar[old_desktop];
+                               for (l = tskbar->area.list; l ; l = l->next) {
+                                       tsk = l->data;
+                                       if (tsk->desktop == ALLDESKTOP) {
+                                               tsk->area.on_screen = 0;
+                                               tskbar->area.resize = 1;
+                                               panel_refresh = 1;
+                                       }
+                               }
+                               tskbar = &panel->taskbar[server.desktop];
+                               for (l = tskbar->area.list; l ; l = l->next) {
+                                       tsk = l->data;
+                                       if (tsk->desktop == ALLDESKTOP) {
+                                               tsk->area.on_screen = 1;
+                                               tskbar->area.resize = 1;
                                        }
                                }
                        }
@@ -553,8 +559,8 @@ void event_property_notify (XEvent *e)
                                                if (tsk->win == tsk2->win && tsk != tsk2) {
                                                        tsk2->icon_width = tsk->icon_width;
                                                        tsk2->icon_height = tsk->icon_height;
-                                                       tsk2->icon_data = tsk->icon_data;
-                                                       tsk2->icon_data_active = tsk->icon_data_active;
+                                                       tsk2->icon = tsk->icon;
+                                                       tsk2->icon_active = tsk->icon_active;
                                                        tsk2->area.redraw = 1;
                                                }
                                        }
@@ -578,6 +584,15 @@ void event_property_notify (XEvent *e)
                                panel_refresh = 1;
                        }
                }
+               else if (at == server.atom.WM_HINTS) {
+                       XWMHints* wmhints = XGetWMHints(server.dsp, win);
+                       if (wmhints && wmhints->flags & XUrgencyHint) {
+                               task_urgent = tsk;
+                               tick_urgent = 0;
+                               time_precision = 1;
+                       }
+                       XFree(wmhints);
+               }
 
                if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
        }
@@ -586,12 +601,15 @@ void event_property_notify (XEvent *e)
 
 void event_expose (XEvent *e)
 {
-       Panel *panel;
-
-       panel = get_panel(e->xany.window);
-       if (!panel) return;
-       // TODO : one panel_refresh per panel ?
-       panel_refresh = 1;
+       if (e->xany.window == g_tooltip.window)
+               tooltip_update();
+       else {
+               Panel *panel;
+               panel = get_panel(e->xany.window);
+               if (!panel) return;
+               // TODO : one panel_refresh per panel ?
+               panel_refresh = 1;
+       }
 }
 
 
@@ -708,7 +726,6 @@ int main (int argc, char *argv[])
        GSList *it;
 
        init (argc, argv);
-
 load_config:
        i = 0;
        init_config();
@@ -748,6 +765,7 @@ load_config:
 
                                switch (e.type) {
                                        case ButtonPress:
+                                               tooltip_hide();
                                                event_button_press (&e);
                                                break;
 
@@ -755,6 +773,20 @@ load_config:
                                                event_button_release(&e);
                                                break;
 
+                                       case MotionNotify: {
+                                               Panel* panel = get_panel(e.xmotion.window);
+                                               Task* task = click_task(panel, e.xmotion.x, e.xmotion.y);
+                                               if (task)
+                                                       tooltip_trigger_show(task, e.xmotion.x_root, e.xmotion.y_root);
+                                               else
+                                                       tooltip_trigger_hide();
+                                               break;
+                                       }
+
+                                       case LeaveNotify:
+                                               tooltip_trigger_hide();
+                                               break;
+
                                        case Expose:
                                                event_expose(&e);
                                                break;
@@ -764,6 +796,8 @@ load_config:
                                                break;
 
                                        case ConfigureNotify:
+                                               //XMoveWindow(dpy, fen, pos_x, pos_y);
+                                               //XResizeWindow(dpy, fen, largeur, hauteur);
                                                if (e.xconfigure.window == server.root_win)
                                                        goto load_config;
                                                else
This page took 0.027003 seconds and 4 git commands to generate.