]> Dogcows Code - chaz/tint2/blobdiff - src/tint.c
fixed issue 176
[chaz/tint2] / src / tint.c
index 44b6d9e8952702855230b7c4d92f418191b4435a..fd30d39f2f606e032dfa1b37c5df3970e53d4ff5 100644 (file)
@@ -178,86 +178,6 @@ void get_snapshot(const char *path)
 }
 
 
-Taskbar *click_taskbar (Panel *panel, int x, int y)
-{
-       Taskbar *tskbar;
-       int i;
-
-       if (panel_horizontal) {
-               for (i=0; i < panel->nb_desktop ; i++) {
-                       tskbar = &panel->taskbar[i];
-                       if (tskbar->area.on_screen && x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
-                               return tskbar;
-               }
-       }
-       else {
-               for (i=0; i < panel->nb_desktop ; i++) {
-                       tskbar = &panel->taskbar[i];
-                       if (tskbar->area.on_screen && y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
-                               return tskbar;
-               }
-       }
-       return NULL;
-}
-
-
-Task *click_task (Panel *panel, int x, int y)
-{
-       GSList *l0;
-       Taskbar *tskbar;
-
-       if ( (tskbar = click_taskbar(panel, x, y)) ) {
-               if (panel_horizontal) {
-                       Task *tsk;
-                       for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
-                               tsk = l0->data;
-                               if (tsk->area.on_screen && x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
-                                       return tsk;
-                               }
-                       }
-               }
-               else {
-                       Task *tsk;
-                       for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
-                               tsk = l0->data;
-                               if (tsk->area.on_screen && y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
-                                       return tsk;
-                               }
-                       }
-               }
-       }
-       return NULL;
-}
-
-
-int click_padding(Panel *panel, int x, int y)
-{
-       if (panel_horizontal) {
-               if (x < panel->area.paddingxlr || x > panel->area.width-panel->area.paddingxlr)
-               return 1;
-       }
-       else {
-               if (y < panel->area.paddingxlr || y > panel->area.height-panel->area.paddingxlr)
-               return 1;
-       }
-       return 0;
-}
-
-
-int click_clock(Panel *panel, int x, int y)
-{
-       Clock clk = panel->clock;
-       if (panel_horizontal) {
-               if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width))
-                       return TRUE;
-       } else {
-               if (clk.area.on_screen && y >= clk.area.posy && y <= (clk.area.posy + clk.area.height))
-                       return TRUE;
-       }
-       return FALSE;
-}
-
-
 void window_action (Task *tsk, int action)
 {
        if (!tsk) return;
@@ -303,6 +223,20 @@ void window_action (Task *tsk, int action)
                        windows_set_desktop(tsk->win, desk);
                        if (desk == server.desktop)
                                set_active(tsk->win);
+                       break;
+               case NEXT_TASK:
+                       if (task_active) {
+                               Task *tsk1;
+                               tsk1 = next_task(task_active);
+                               set_active(tsk1->win);
+                       }
+                       break;
+               case PREV_TASK:
+                       if (task_active) {
+                               Task *tsk1;
+                               tsk1 = prev_task(task_active);
+                               set_active(tsk1->win);
+                       }
        }
 }
 
@@ -501,6 +435,8 @@ void event_property_notify (XEvent *e)
                                        else
                                                return;
                                }
+                               else
+                                       return;
                        }
                }
                //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
@@ -610,15 +546,11 @@ void event_property_notify (XEvent *e)
 
 void event_expose (XEvent *e)
 {
-       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;
-       }
+       Panel *panel;
+       panel = get_panel(e->xany.window);
+       if (!panel) return;
+       // TODO : one panel_refresh per panel ?
+       panel_refresh = 1;
 }
 
 
@@ -666,11 +598,6 @@ void event_configure_notify (Window win)
 }
 
 
-void event_timer()
-{
-}
-
-
 void dnd_message(XClientMessageEvent *e)
 {
        Panel *panel = get_panel(e->window);
@@ -739,6 +666,34 @@ int main (int argc, char *argv[])
        sigemptyset(&empty_mask);
 
        while (1) {
+               if (panel_refresh) {
+                       panel_refresh = 0;
+
+                       if (refresh_systray) {
+                               panel = (Panel*)systray.area.panel;
+                               XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None);
+                       }
+                       for (i=0 ; i < nb_panel ; i++) {
+                               panel = &panel1[i];
+
+                               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);
+                       }
+                       XFlush (server.dsp);
+
+                       if (refresh_systray) {
+                               refresh_systray = 0;
+                               panel = (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_icon();
+                       }
+               }
+
                // thanks to AngryLlama for the timer
                // Create a File Description Set containing x11_fd, and every timer_fd
                FD_ZERO (&fdset);
@@ -754,6 +709,19 @@ int main (int argc, char *argv[])
 
                // Wait for X Event or a Timer
                if (pselect(max_fd+1, &fdset, 0, 0, 0, &empty_mask) > 0) {
+                       // we need to iterate over the whole timer list, since fd_set can only be checked with the
+                       // brute force method FD_ISSET for every possible timer
+                       timer_iter = timer_list;
+                       while (timer_iter) {
+                               timer = timer_iter->data;
+                               if (FD_ISSET(timer->id, &fdset)) {
+                                       uint64_t dummy;
+                                       if ( -1  != read(timer->id, &dummy, sizeof(uint64_t)) )
+                                               timer->_callback();
+                               }
+                               timer_iter = timer_iter->next;
+                       }
+
                        while (XPending (server.dsp)) {
                                XNextEvent(server.dsp, &e);
 
@@ -770,9 +738,9 @@ int main (int argc, char *argv[])
                                        case MotionNotify: {
                                                if (!g_tooltip.enabled) break;
                                                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);
+                                               Area* area = click_area(panel, e.xmotion.x, e.xmotion.y);
+                                               if (area->_get_tooltip_text)
+                                                       tooltip_trigger_show(area, panel, e.xmotion.x_root, e.xmotion.y_root);
                                                else
                                                        tooltip_trigger_hide();
                                                break;
@@ -786,6 +754,11 @@ int main (int argc, char *argv[])
                                                event_expose(&e);
                                                break;
 
+                                       case MapNotify:
+                                               if (e.xany.window == g_tooltip.window)
+                                                       tooltip_update();
+                                               break;
+
                                        case PropertyNotify:
                                                event_property_notify(&e);
                                                break;
@@ -804,7 +777,7 @@ int main (int argc, char *argv[])
                                                break;
                                        case UnmapNotify:
                                        case DestroyNotify:
-                                               if (!systray.area.on_screen)
+                                               if (e.xany.window == g_tooltip.window || !systray.area.on_screen)
                                                        break;
                                                for (it = systray.list_icons; it; it = g_slist_next(it)) {
                                                        if (((TrayWindow*)it->data)->id == e.xany.window) {
@@ -825,19 +798,6 @@ int main (int argc, char *argv[])
                                                break;
                                }
                        }
-
-                       // we need to iterate over the whole timer list, since fd_set can only be checked with the
-                       // brute force method FD_ISSET for every possible timer
-                       timer_iter = timer_list;
-                       while (timer_iter) {
-                               timer = timer_iter->data;
-                               if (FD_ISSET(timer->id, &fdset)) {
-                                       uint64_t dummy;
-                                       read(timer->id, &dummy, sizeof(uint64_t));
-                                       timer->_callback();
-                               }
-                               timer_iter = timer_iter->next;
-                       }
                }
 
                switch (signal_pending) {
@@ -854,34 +814,6 @@ int main (int argc, char *argv[])
                        cleanup ();
                        return 0;
                }
-
-               if (panel_refresh) {
-                       panel_refresh = 0;
-
-                       if (refresh_systray) {
-                               panel = (Panel*)systray.area.panel;
-                               XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None);
-                       }
-                       for (i=0 ; i < nb_panel ; i++) {
-                               panel = &panel1[i];
-
-                               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);
-                       }
-                       XFlush (server.dsp);
-
-                       if (refresh_systray) {
-                               refresh_systray = 0;
-                               panel = (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_icon();
-                       }
-               }
        }
 }
 
This page took 0.031709 seconds and 4 git commands to generate.