]> Dogcows Code - chaz/tint2/commitdiff
*fix* forward all clicks tint2 does not handle to the window manager, if wm_menu = 1
authorAndreas Fink <andreas.fink85@googlemail.com>
Mon, 28 Dec 2009 15:49:15 +0000 (15:49 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Mon, 28 Dec 2009 15:49:15 +0000 (15:49 +0000)
src/taskbar/task.c
src/tint.c
src/util/timer.c

index 21b741b0d819522653e66e9313df20cbff62465b..a569a99e4ec47f3a8555ec58c3cb5d6d15ab33b5 100644 (file)
@@ -531,7 +531,7 @@ void del_urgent(Task *tsk)
 int is_urgent(Task *tsk)
 {
        if (!tsk)
-               return;
+               return 0;
        GSList* urgent_task = urgent_list;
        while (urgent_task) {
                Task_urgent* t = urgent_task->data;
index a91f8cc38267d1110376dfd61f3ed30b596fb20b..fc471def24f2a9bfcefa87a8b5a9e8d551da914a 100644 (file)
@@ -241,26 +241,61 @@ void window_action (Task *tsk, int action)
 }
 
 
+int tint2_handles_click(Panel* panel, XButtonEvent* e)
+{
+       Task* task = click_task(panel, e->x, e->y);
+       if (task) {
+               if(   (e->button == 1)
+                        || (e->button == 2 && mouse_middle != 0)
+                        || (e->button == 3 && mouse_right != 0)
+                        || (e->button == 4 && mouse_scroll_up != 0)
+                        || (e->button == 5 && mouse_scroll_down !=0) )
+               {
+                       return 1;
+               }
+               else
+                       return 0;
+       }
+       // no task clicked --> check if taskbar clicked
+       Taskbar *tskbar = click_taskbar(panel, e->x, e->y);
+       if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP)
+               return 1;
+       if (click_clock(panel, e->x, e->y)) {
+               if ( (e->button == 1 && clock_lclick_command) || (e->button == 2 && clock_rclick_command) )
+                       return 1;
+               else
+                       return 0;
+       }
+       return 0;
+}
+
+
+void forward_click(XEvent* e)
+{
+       // forward the click to the desktop window (thanks conky)
+       XUngrabPointer(server.dsp, e->xbutton.time);
+       e->xbutton.window = server.root_win;
+       // icewm doesn't open under the mouse.
+       // and xfce doesn't open at all.
+       e->xbutton.x = e->xbutton.x_root;
+       e->xbutton.y = e->xbutton.y_root;
+       //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
+       //XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
+       XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
+}
+
+
 void event_button_press (XEvent *e)
 {
        Panel *panel = get_panel(e->xany.window);
        if (!panel) return;
 
-       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)
-               XUngrabPointer(server.dsp, e->xbutton.time);
-               e->xbutton.window = server.root_win;
-               // icewm doesn't open under the mouse.
-               // and xfce doesn't open at all.
-               e->xbutton.x = e->xbutton.x_root;
-               e->xbutton.y = e->xbutton.y_root;
-               //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
-               //XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
-               XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
+       if (wm_menu && !tint2_handles_click(panel, &e->xbutton) ) {
+               forward_click(e);
                return;
        }
+       task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);
 
        XLowerWindow (server.dsp, panel->main_win);
 }
@@ -271,6 +306,12 @@ void event_button_release (XEvent *e)
        Panel *panel = get_panel(e->xany.window);
        if (!panel) return;
 
+       if (wm_menu && !tint2_handles_click(panel, &e->xbutton)) {
+               forward_click(e);
+               task_drag = 0;
+               return;
+       }
+
        int action = TOGGLE_ICONIFY;
        switch (e->xbutton.button) {
                case 2:
index 4da7cc353e4d54cbaa620684e5b06c357a777872..8ffadc88d829b9d05453c7bea2c7efd615ec96bd 100644 (file)
@@ -29,6 +29,15 @@ gint compare_timespecs(const struct timespec* t1, const struct timespec* t2);
 int timespec_subtract(struct timespec* result, struct timespec* x, struct timespec* y);
 
 
+/** Implementation notes for timeouts: The timeouts are kept in a GSList sorted by their
+       * expiration time.
+       * That means that update_next_timeout() only have to consider the first timeout in the list,
+       * and callback_timeout_expired() only have to consider the timeouts as long as the expiration time
+       * is in the past to the current time.
+       * As time measurement we use clock_gettime(CLOCK_MONOTONIC) because this refers to a timer, which
+       * reference point lies somewhere in the past and cannot be changed, but just queried.
+**/
+
 const struct timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)())
 {
        struct timeout* t = malloc(sizeof(struct timeout));
@@ -71,7 +80,7 @@ void callback_timeout_expired()
                        // it's time for the callback function
                        t->_callback();
                        if (g_slist_find(timeout_list, t)) {
-                               // if _callback() calls stop_timeout(t) the timeout 't' does not exist anymore
+                               // if _callback() calls stop_timeout(t) the timeout 't' was freed and is not in the timeout_list
                                timeout_list = g_slist_remove(timeout_list, t);
                                if (t->interval_msec > 0)
                                        add_timeout_intern(t->interval_msec, t->interval_msec, t->_callback, t);
@@ -87,6 +96,7 @@ void callback_timeout_expired()
 
 void stop_timeout(const struct timeout* t)
 {
+       // if not in the list, it was deleted in callback_timeout_expired
        if (g_slist_find(timeout_list, t)) {
                timeout_list = g_slist_remove(timeout_list, t);
                free((void*)t);
This page took 0.023162 seconds and 4 git commands to generate.