Use gdk_event_triggers_context_menu()

This commit is contained in:
Přemysl Eric Janouch 2022-08-03 21:36:30 +02:00
parent 6f83d1dceb
commit 5bae7c1bd2
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 14 additions and 11 deletions

View File

@ -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);

View File

@ -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