[Xfce4-commits] [xfce/xfdesktop] 14/16: Fix menu popups from command line

noreply at xfce.org noreply at xfce.org
Wed Apr 19 17:46:31 CEST 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfdesktop.

commit 3907aba542aee92630bf1970071fdc20be5f6ad3
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Wed Apr 19 15:55:28 2017 +0300

    Fix menu popups from command line
    
    Fix launching a menu from xfdesktop -M or -W.
---
 src/xfce-desktop.c          | 43 ++++++++++++++++++++++++++++++-------------
 src/xfce-desktop.h          |  6 ++++--
 src/xfdesktop-application.c |  4 ++--
 src/xfdesktop-icon-view.c   |  5 ++---
 4 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c
index 9a13a03..f1047d3 100644
--- a/src/xfce-desktop.c
+++ b/src/xfce-desktop.c
@@ -1196,12 +1196,11 @@ xfce_desktop_button_press_event(GtkWidget *w,
                 return FALSE;
 #endif
             /* no icons on the desktop, grab the focus and pop up the menu */
-            if(!gtk_widget_has_grab(w)) {
+            if(!gtk_widget_has_grab(w))
                 gtk_grab_add(w);
 
-                xfce_desktop_popup_root_menu(desktop, evt);
+                xfce_desktop_popup_root_menu(desktop, button, evt->time);
                 return TRUE;
-            }
         } else if(button == 2 || (button == 1 && (state & GDK_SHIFT_MASK)
                                   && (state & GDK_CONTROL_MASK)))
         {
@@ -1209,7 +1208,7 @@ xfce_desktop_button_press_event(GtkWidget *w,
             if(!gtk_widget_has_grab(w))
                 gtk_grab_add(w);
 
-            xfce_desktop_popup_secondary_root_menu(desktop, evt);
+            xfce_desktop_popup_secondary_root_menu(desktop, button, evt->time);
             return TRUE;
         }
     }
@@ -1234,15 +1233,22 @@ static gboolean
 xfce_desktop_popup_menu(GtkWidget *w)
 {
     GdkEventButton *evt;
+    guint button, etime;
 
     TRACE("entering");
 
     evt = (GdkEventButton *)gtk_get_current_event();
+    if(evt && GDK_BUTTON_PRESS == evt->type) {
+        button = evt->button;
+        etime = evt->time;
+    } else {
+        button = 0;
+        etime = gtk_get_current_event_time();
+    }
     
-    xfce_desktop_popup_root_menu(XFCE_DESKTOP(w), evt);
+    xfce_desktop_popup_root_menu(XFCE_DESKTOP(w), button, etime);
 
-    if(evt)
-        gdk_event_free((GdkEvent*)evt);
+    gdk_event_free((GdkEvent*)evt);
     return TRUE;
 }
 
@@ -1696,7 +1702,8 @@ xfce_desktop_menu_destroy_idled(gpointer data)
 
 static void
 xfce_desktop_do_menu_popup(XfceDesktop *desktop,
-                           GdkEventButton *evt,
+                           guint button,
+                           guint activate_time,
                            guint populate_signal)
 {
     GdkScreen *screen;
@@ -1730,25 +1737,35 @@ xfce_desktop_do_menu_popup(XfceDesktop *desktop,
 
     gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(desktop), NULL);
 
-    gtk_menu_popup_at_pointer(GTK_MENU (menu), (GdkEvent *)evt);
+    /* Per gtk_menu_popup's documentation "for conflict-resolve initiation of
+     * concurrent requests for mouse/keyboard grab requests." */
+    if(activate_time == 0)
+        activate_time = gtk_get_current_event_time();
+
+    xfce_gtk_menu_popup_until_mapped(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, activate_time);
 }
 
+
 void
 xfce_desktop_popup_root_menu(XfceDesktop *desktop,
-                             GdkEventButton *evt)
+                             guint button,
+                             guint activate_time)
 {
     TRACE("entering");
 
-    xfce_desktop_do_menu_popup(desktop, evt,
+    xfce_desktop_do_menu_popup(desktop, button, activate_time,
                                signals[SIG_POPULATE_ROOT_MENU]);
 
 }
 
 void
 xfce_desktop_popup_secondary_root_menu(XfceDesktop *desktop,
-                                       GdkEventButton *evt)
+                                       guint button,
+                                       guint activate_time)
 {
-    xfce_desktop_do_menu_popup(desktop, evt,
+    TRACE("entering");
+
+    xfce_desktop_do_menu_popup(desktop, button, activate_time,
                                signals[SIG_POPULATE_SECONDARY_ROOT_MENU]);
 }
 
diff --git a/src/xfce-desktop.h b/src/xfce-desktop.h
index 8055a07..640b778 100644
--- a/src/xfce-desktop.h
+++ b/src/xfce-desktop.h
@@ -105,9 +105,11 @@ void xfce_desktop_thaw_updates(XfceDesktop *desktop);
 
 
 void xfce_desktop_popup_root_menu(XfceDesktop *desktop,
-                                  GdkEventButton *evt);
+                                  guint button,
+                                  guint activate_time);
 void xfce_desktop_popup_secondary_root_menu(XfceDesktop *desktop,
-                                            GdkEventButton *evt);
+                                            guint button,
+                                            guint activate_time);
 
 void xfce_desktop_refresh(XfceDesktop *desktop, gboolean advance_wallpaper);
 
diff --git a/src/xfdesktop-application.c b/src/xfdesktop-application.c
index 77935c7..3bbda43 100644
--- a/src/xfdesktop-application.c
+++ b/src/xfdesktop-application.c
@@ -457,10 +457,10 @@ cb_xfdesktop_application_menu(GAction  *action,
 
     if(popup_root_menu) {
         xfce_desktop_popup_root_menu(XFCE_DESKTOP(app->desktop),
-                                     NULL);
+                                     0, GDK_CURRENT_TIME);
     } else {
         xfce_desktop_popup_secondary_root_menu(XFCE_DESKTOP(app->desktop),
-                                               NULL);
+                                               0, GDK_CURRENT_TIME);
     }
 }
 
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index cac2bb0..239441a 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -891,7 +891,7 @@ xfdesktop_icon_view_button_press(GtkWidget *widget,
             /* Since we're not over any icons this won't be the start of a
              * drag so we can pop up menu */
             if(evt->button == 3 || (evt->button == 1 && (evt->state & GDK_SHIFT_MASK))) {
-                xfce_desktop_popup_root_menu(XFCE_DESKTOP(widget), evt);
+                xfce_desktop_popup_root_menu(XFCE_DESKTOP(widget), evt->button, evt->time);
                 return TRUE;
             }
         }
@@ -1016,8 +1016,7 @@ xfdesktop_icon_view_button_release(GtkWidget *widget,
          * We pass 0 as the button because the docs say that you must use 0
          * for pop ups other than button press events. */
         if(icon_l && (icon = icon_l->data)) {
-            evt->button = 0;
-            xfce_desktop_popup_root_menu(XFCE_DESKTOP(widget), evt);
+            xfce_desktop_popup_root_menu(XFCE_DESKTOP(widget), 0, evt->time);
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list