diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-08-03 21:36:30 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-08-03 21:37:45 +0200 |
commit | 5bae7c1bd2ee1843c32cb6e44954e8c5e5904456 (patch) | |
tree | 77baa910c266830b6c716a0c68f5c8f3ad456283 | |
parent | 6f83d1dcebddc6bc3a80fb1148081ff1a1f61177 (diff) | |
download | fiv-5bae7c1bd2ee1843c32cb6e44954e8c5e5904456.tar.gz fiv-5bae7c1bd2ee1843c32cb6e44954e8c5e5904456.tar.xz fiv-5bae7c1bd2ee1843c32cb6e44954e8c5e5904456.zip |
Use gdk_event_triggers_context_menu()
-rw-r--r-- | fiv-browser.c | 18 | ||||
-rw-r--r-- | 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 |