From 1f57c5b19c099ae44b2c8ec8ca9a1904f1ed7885 Mon Sep 17 00:00:00 2001 From: Carlos Soriano Date: Thu, 6 Oct 2016 16:09:33 +0200 Subject: 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 --- src/nautilus-ui-utilities.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'src/nautilus-ui-utilities.c') 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); -- cgit v1.2.1