Commit 1f57c5b1 authored by Carlos Soriano Sánchez's avatar Carlos Soriano Sánchez

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.
parent dedd9c61
......@@ -169,41 +169,19 @@ nautilus_gmenu_add_item_in_submodel (GMenu *menu,
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;
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);
......@@ -35,8 +35,8 @@ void nautilus_gmenu_merge (GMenu *original,
const gchar *submodel_name,
gboolean prepend);
void nautilus_pop_up_context_menu (GtkWidget *parent,
GMenu *menu,
GdkEventButton *event);
GMenu *menu,
GdkEventButton *button_event);
char * nautilus_escape_action_name (const char *action_name,
const char *prefix);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment