[Xfce4-commits] <xfce4-taskbar-plugin:master> Dragging pinned icons works with left mouse click now.

Gearoid Murphy noreply at xfce.org
Sat Sep 22 13:40:03 CEST 2012


Updating branch refs/heads/master
         to 650c524ac9b9f3dd939e15975cebc2c96a7467e0 (commit)
       from aa010f398cf8aff6657a5be73589f5b75fa367af (commit)

commit 650c524ac9b9f3dd939e15975cebc2c96a7467e0
Author: Gearoid Murphy <gearoid at murphy.com>
Date:   Sat Sep 22 12:36:59 2012 +0100

    Dragging pinned icons works with left mouse click now.

 taskbar-widget.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/taskbar-widget.c b/taskbar-widget.c
index 5215191..8319b37 100644
--- a/taskbar-widget.c
+++ b/taskbar-widget.c
@@ -179,6 +179,7 @@ struct _XfceTaskBarGroup
     GSList        *wnodes;
     gchar         *window_class_name ;
     guint         unique_id ;
+    gboolean      dragactive ;
     gboolean      pinned ;
     gchar         *command ;
 };
@@ -1552,8 +1553,8 @@ static gboolean xfce_taskbar_button_enter_notify_event (GtkWidget *button, GdkEv
     return FALSE;
 }
 
-/*These are the buttons exposed via a mouse1 click on the group icon*/
-static gboolean xfce_taskbar_button_button_press_event (GtkWidget *button, GdkEventButton *event, XfceTaskBarWNode *child)
+//app buttons are the buttons associated with a single instance of a specific application group, exposed by clicking on a group button
+static gboolean xfce_taskbar_app_button_press_event (GtkWidget *button, GdkEventButton *event, XfceTaskBarWNode *child)
 {
     GtkWidget *menu, *panel_plugin;
 
@@ -1588,7 +1589,8 @@ static gboolean xfce_taskbar_button_button_press_event (GtkWidget *button, GdkEv
     return FALSE;
 }
 
-static gboolean xfce_taskbar_button_button_release_event (GtkWidget *button, GdkEventButton *event, XfceTaskBarWNode *child)
+//app buttons are the buttons associated with a single instance of a specific application group, exposed by clicking on a group button
+static gboolean xfce_taskbar_app_button_release_event (GtkWidget *button, GdkEventButton *event, XfceTaskBarWNode *child)
 {
     panel_return_val_if_fail (XFCE_IS_taskbar (child->taskbar), FALSE);
 
@@ -1657,8 +1659,8 @@ static GtkWidget *xfce_taskbar_button_proxy_menu_item (XfceTaskBarWNode *child,
                 xfce_taskbar_button_enter_notify_event_disconnected, 0);
     }
 
-    g_signal_connect (G_OBJECT (mi), "button-press-event", G_CALLBACK (xfce_taskbar_button_button_press_event), child);
-    g_signal_connect (G_OBJECT (mi), "button-release-event", G_CALLBACK (xfce_taskbar_button_button_release_event), child);
+    g_signal_connect (G_OBJECT (mi), "button-press-event", G_CALLBACK (xfce_taskbar_app_button_press_event), child);
+    g_signal_connect (G_OBJECT (mi), "button-release-event", G_CALLBACK (xfce_taskbar_app_button_release_event), child);
 
     /* TODO item dnd */
 
@@ -1777,6 +1779,7 @@ static void xfce_taskbar_button_drag_begin (GtkWidget *button, GdkDragContext *c
 {
     // Hacky workaround for DnD crashes
     usleep(20000);
+    group->dragactive = TRUE ;
     gtk_drag_set_icon_pixmap(context, gtk_widget_get_colormap(group->icon), gtk_widget_get_snapshot(group->icon, NULL), NULL, 0, 0);
 }
 
@@ -2238,7 +2241,7 @@ static void xfce_taskbar_group_button_menu_destroy (GtkWidget *menu, XfceTaskBar
 #endif
 }
 
-static gboolean xfce_taskbar_group_button_button_press_event
+static gboolean xfce_taskbar_group_button_release_event
 (GtkWidget *button, GdkEventButton *event, XfceTaskBarGroup *group)
 {
     GtkWidget *panel_plugin;
@@ -2246,9 +2249,15 @@ static gboolean xfce_taskbar_group_button_button_press_event
 
     panel_return_val_if_fail (XFCE_IS_taskbar (group->taskbar), FALSE);
 
-    if (event->type != GDK_BUTTON_PRESS || xfce_taskbar_is_locked (group->taskbar))
+    if (event->type != GDK_BUTTON_RELEASE || xfce_taskbar_is_locked (group->taskbar))
         return FALSE;
 
+    if(group->dragactive == TRUE)
+    {
+        group->dragactive = FALSE ;
+        return FALSE ;
+    }
+    
     /* send the event to the panel plugin if control is pressed */
     if (PANEL_HAS_FLAG (event->state, GDK_CONTROL_MASK))
     {
@@ -2460,6 +2469,7 @@ static XfceTaskBarGroup * xfce_taskbar_group_button_new (const char *group_name,
     
     
     //Prep the pinning data
+    group->dragactive = FALSE;
     group->pinned = FALSE;
     group->command = NULL ;
     
@@ -2474,7 +2484,7 @@ static XfceTaskBarGroup * xfce_taskbar_group_button_new (const char *group_name,
     //gtk_button_set_image((GtkButton *)group->button, group->icon);
     
     /* note that the same signals should be in the proxy menu item too */
-    g_signal_connect (G_OBJECT (group->button), "button-press-event", G_CALLBACK (xfce_taskbar_group_button_button_press_event), group);
+    g_signal_connect (G_OBJECT (group->button), "button-release-event", G_CALLBACK (xfce_taskbar_group_button_release_event), group);
 
     /* insert */
     taskbar->wgroups = g_list_append(taskbar->wgroups, group);
@@ -2486,7 +2496,7 @@ static XfceTaskBarGroup * xfce_taskbar_group_button_new (const char *group_name,
     
     /* drag and drop to the pager */
     gtk_drag_dest_set     (group->button, GTK_DEST_DEFAULT_ALL,    source_targets, G_N_ELEMENTS (source_targets), GDK_ACTION_MOVE);
-    gtk_drag_source_set (group->button, GDK_BUTTON2_MASK,            source_targets, G_N_ELEMENTS (source_targets), GDK_ACTION_MOVE);
+    gtk_drag_source_set (group->button, GDK_BUTTON1_MASK,            source_targets, G_N_ELEMENTS (source_targets), GDK_ACTION_MOVE);
     
     g_signal_connect (G_OBJECT (group->button), "drag-data-get",            G_CALLBACK (xfce_taskbar_button_drag_data_get), group);
     g_signal_connect (G_OBJECT (group->button), "drag-begin",                 G_CALLBACK (xfce_taskbar_button_drag_begin), group);


More information about the Xfce4-commits mailing list