summaryrefslogtreecommitdiff
path: root/src/nautilus-ui-utilities.c
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-10-06 16:09:33 +0200
committerCarlos Soriano <csoriano@gnome.org>2016-10-12 11:05:31 +0200
commit1f57c5b19c099ae44b2c8ec8ca9a1904f1ed7885 (patch)
treebe8ceb0a395a511fd797b12c4f1db1e52463c0d8 /src/nautilus-ui-utilities.c
parentdedd9c61d7d1b4d685a766e9d494bc1fbc12dca3 (diff)
downloadnautilus-1f57c5b19c099ae44b2c8ec8ca9a1904f1ed7885.tar.gz
ui-utilities: use gtk_menu_popup_at_pointer instead of gtk_popup_menu
We were using gtk_popup_menu which is problematic in backends with no global coordinates like wayland. To fix it, we can use gtk_menu_popup_at_pointer which uses the event relative coordinates. Also, seems the custom handling we were doing for the popup menu in that code is obsoleted, so there is not need to specify the button. https://bugzilla.gnome.org/show_bug.cgi?id=772507
Diffstat (limited to 'src/nautilus-ui-utilities.c')
-rw-r--r--src/nautilus-ui-utilities.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/src/nautilus-ui-utilities.c b/src/nautilus-ui-utilities.c
index fedbb484b..e8fdab8b4 100644
--- a/src/nautilus-ui-utilities.c
+++ b/src/nautilus-ui-utilities.c
@@ -169,41 +169,19 @@ nautilus_gmenu_add_item_in_submodel (GMenu *menu,
void
nautilus_pop_up_context_menu (GtkWidget *parent,
GMenu *menu,
- GdkEventButton *event)
+ GdkEventButton *button_event)
{
GtkWidget *gtk_menu;
- int button;
-
g_return_if_fail (G_IS_MENU (menu));
g_return_if_fail (GTK_IS_WIDGET (parent));
gtk_menu = gtk_menu_new_from_model (G_MENU_MODEL (menu));
gtk_menu_attach_to_widget (GTK_MENU (gtk_menu), parent, NULL);
- /* The event button needs to be 0 if we're popping up this menu from
- * a button release, else a 2nd click outside the menu with any button
- * other than the one that invoked the menu will be ignored (instead
- * of dismissing the menu). This is a subtle fragility of the GTK menu code.
- */
- if (event)
- {
- button = event->type == GDK_BUTTON_RELEASE
- ? 0
- : event->button;
- }
- else
- {
- button = 0;
- }
-
- gtk_menu_popup (GTK_MENU (gtk_menu), /* menu */
- NULL, /* parent_menu_shell */
- NULL, /* parent_menu_item */
- NULL, /* popup_position_func */
- NULL, /* popup_position_data */
- button, /* button */
- event ? event->time : gtk_get_current_event_time ()); /* activate_time */
+ gtk_menu_popup_at_pointer (GTK_MENU (gtk_menu),
+ button_event ? (GdkEvent *) button_event :
+ gtk_get_current_event ());
g_object_ref_sink (gtk_menu);
g_object_unref (gtk_menu);