From 5bae7c1bd2ee1843c32cb6e44954e8c5e5904456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Wed, 3 Aug 2022 21:36:30 +0200 Subject: Use gdk_event_triggers_context_menu() --- fiv-browser.c | 18 +++++++++++------- fiv-sidebar.c | 7 +++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/fiv-browser.c b/fiv-browser.c index db46bd3..ab046b3 100644 --- a/fiv-browser.c +++ b/fiv-browser.c @@ -1085,11 +1085,18 @@ fiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event) gtk_widget_get_focus_on_click(widget)) gtk_widget_grab_focus(widget); + // In accordance with Nautilus, Thunar, and the mildly confusing + // Apple Human Interface Guidelines, but not with the ugly Windows User + // Experience Interaction Guidelines, open the context menu on button press. + // (Originally our own behaviour, but the GDK3 function also does this.) + gboolean triggers_menu = + gdk_event_triggers_context_menu((const GdkEvent *) event); + const Entry *entry = entry_at(self, event->x, event->y); - if (!entry && state == 0) { - if (event->button == GDK_BUTTON_SECONDARY) + if (!entry) { + if (triggers_menu) show_context_menu(widget, fiv_io_model_get_location(self->model)); - else if (event->button != GDK_BUTTON_PRIMARY) + else if (state || event->button != GDK_BUTTON_PRIMARY) return GDK_EVENT_PROPAGATE; if (self->selected) { @@ -1099,10 +1106,7 @@ fiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event) return GDK_EVENT_STOP; } - // In accordance with Nautilus, Thunar, and the mildly confusing - // Apple Human Interface Guidelines, but not with the ugly Windows User - // Experience Interaction Guidelines, open the context menu on button press. - if (entry && event->button == GDK_BUTTON_SECONDARY) { + if (entry && triggers_menu) { self->selected = entry; gtk_widget_queue_draw(widget); diff --git a/fiv-sidebar.c b/fiv-sidebar.c index 8cb2080..bc83649 100644 --- a/fiv-sidebar.c +++ b/fiv-sidebar.c @@ -196,14 +196,13 @@ static gboolean on_breadcrumb_button_press(GtkWidget *widget, GdkEventButton *event, G_GNUC_UNUSED gpointer user_data) { - if (event->type != GDK_BUTTON_PRESS || - event->button != GDK_BUTTON_SECONDARY) - return FALSE; + if (!gdk_event_triggers_context_menu((const GdkEvent *) event)) + return GDK_EVENT_PROPAGATE; GFile *location = g_object_get_qdata(G_OBJECT(widget), fiv_sidebar_location_quark()); gtk_menu_popup_at_pointer(fiv_context_menu_new(widget, location), NULL); - return TRUE; + return GDK_EVENT_STOP; } static gboolean -- cgit v1.2.3