[Xfce4-commits] <xfce4-taskbar-plugin:master> Minor mouse click behavioural tweak.

Gearoid Murphy noreply at xfce.org
Sun Oct 14 16:52:01 CEST 2012


Updating branch refs/heads/master
         to 82300bf7907d846be579383cc9855daf4ddfae70 (commit)
       from 3d44306b86b5942887e4c1650d3cc21e102bf944 (commit)

commit 82300bf7907d846be579383cc9855daf4ddfae70
Author: Gearoid Murphy <gearoid at murphy.com>
Date:   Sun Oct 14 15:50:17 2012 +0100

    Minor mouse click behavioural tweak.

 taskbar-widget.c |   75 +++++++++++++++++++++++++++--------------------------
 1 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/taskbar-widget.c b/taskbar-widget.c
index 2cecb52..e4d671d 100644
--- a/taskbar-widget.c
+++ b/taskbar-widget.c
@@ -2251,6 +2251,7 @@ static gboolean xfce_taskbar_group_button_press_event
 }
 
 // This function handles all the logic for mouse button relase on the taskbar icons
+// It's a witches brew of shimmies and hacks
 static gboolean xfce_taskbar_group_button_release_event
 (GtkWidget *button, GdkEventButton *event, XfceTaskBarGroup *group)
 {
@@ -2272,26 +2273,6 @@ static gboolean xfce_taskbar_group_button_release_event
         return FALSE ;
     }
     
-    //Check if there's a hover menu active, if so, disable it
-    GList *attached = gtk_menu_get_for_attach_widget(group->button);
-    guint list_length = g_list_length(attached);
-    size_t menu_source = 0 ;
-    panel_assert (list_length <= 1 && "There should only be at most one menu attached to the icon!");
-    if(list_length == 1)
-    {
-        GtkMenu *menu = attached->data;
-        gint time_diff = (gtk_get_current_event_time() - group->hover_visible_timestamp);
-        menu_source = (size_t)(g_object_get_data(G_OBJECT(menu), "menu-source"));
-        //We don't want to dismiss the menu if the user generates a
-        //request for it very shortly after it has appeared
-        if(event->button == LEFTMOUSE && time_diff < HOVER_DISPLAY_COOLOFF)
-        {
-            return TRUE ;
-        }
-        
-        gtk_widget_destroy (GTK_WIDGET(menu));
-    }
-    
     //Middle mouse click on the taskbar icon launchs the icon
     if(event->button == MIDMOUSE)
     {
@@ -2299,27 +2280,47 @@ static gboolean xfce_taskbar_group_button_release_event
         return TRUE ;
     }
     
-    
-    if (event->button == LEFTMOUSE || event->button == RIGHTMOUSE)
+    //Get the number of visible windows for the group icon
+    //If there's only a single window visible, set active_child
+    //otherwise active_child will be NULL, regardless of multiple
+    //active windows
+    GSList *li;
+    XfceTaskBarWNode *child, *active_child=0x0 ;
+    int visible_count=0x0 ;
+    for (li = group->wnodes; li != NULL; li = li->next)
     {
-        GSList *li;
-        XfceTaskBarWNode *child, *active_child=0x0 ;
-        int visible_count=0x0 ;
-        for (li = group->wnodes; li != NULL; li = li->next)
+        child = li->data;
+        if(child->visible)
         {
-            child = li->data;
-            if(child->visible)
+            visible_count += 1 ;
+            if(active_child == 0x0 && visible_count == 1)
+                active_child = child ;
+            else
             {
-                visible_count += 1 ;
-                if(active_child == 0x0 && visible_count == 1)
-                    active_child = child ;
-                else
-                {
-                    active_child = 0x0 ;
-                }
+                active_child = 0x0 ;
             }
         }
-        
+    }
+    
+    //Check if there's a hover menu active, if so, dismiss it, but only if it's outside the cooloff period
+    //If possible, detect menu_source to reflect the mouse button which invoked the hover menu
+    //This is used to re-activate the hover menu when a different mouse button is used
+    size_t menu_source = 0 ;
+    if(g_list_length(gtk_menu_get_for_attach_widget(group->button)) == 1)
+    {
+        GtkMenu *menu = (gtk_menu_get_for_attach_widget(group->button))->data;
+        gint time_diff = (gtk_get_current_event_time() - group->hover_visible_timestamp);
+        menu_source = (size_t)(g_object_get_data(G_OBJECT(menu), "menu-source"));
+        //We don't want to dismiss the menu if the user generates a request for it very shortly after it has appeared
+        if(active_child == 0x0 && event->button == LEFTMOUSE && time_diff < HOVER_DISPLAY_COOLOFF)
+        {
+            return TRUE ;
+        }
+        gtk_widget_destroy (GTK_WIDGET(menu));
+    }
+    
+    if (event->button == LEFTMOUSE || event->button == RIGHTMOUSE)
+    {
         // If a single instance of a class window is visible to the taskbar,
         // activate that instance instead of showing the associated group menus,
         // when a left mouse click falls on the icon
@@ -2329,7 +2330,7 @@ static gboolean xfce_taskbar_group_button_release_event
             return TRUE ;
         }
         
-        //2nd click of same button dismisses the menu
+        //2nd click of same mouse button means we don't generate a new menu
         if(menu_source == event->button)
         {
             return TRUE ;


More information about the Xfce4-commits mailing list