From df87b1820b5b61976e153c5571e0ec3e3ab5f6ff Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Mon, 29 Jul 2024 19:59:29 +0200 Subject: [PATCH 1/2] macos: Add Ctrl+left-click mapping for context menus Update GdkEvent.triggers_context_menu to trigger a context menu on macOS. --- gdk/gdkevents.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index cb698a2544..34d954a58e 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -998,6 +998,13 @@ gdk_event_triggers_context_menu (GdkEvent *event) if (bevent->button == GDK_BUTTON_SECONDARY && ! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK))) return TRUE; + +#ifdef __APPLE__ + if (bevent->button == GDK_BUTTON_PRIMARY && + (bevent->state & GDK_CONTROL_MASK) && + ! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK))) + return TRUE; +#endif } return FALSE; From f0925e4ef2dc77956f83fcf88db78f5a555f2126 Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Mon, 29 Jul 2024 20:07:13 +0200 Subject: [PATCH 2/2] docs: Update function docs for gdk_event_triggers_context_menu Include macOS, make code snipper easier identifyable. --- gdk/gdkevents.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 34d954a58e..95a0a84ae2 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -978,9 +978,13 @@ gdk_event_get_axis (GdkEvent *event, * according to platform conventions. * * The right mouse button typically triggers context menus. + * On macOS, Control+left mouse button also triggers. * * This function should always be used instead of simply checking for - * event->button == %GDK_BUTTON_SECONDARY. + * + * ```c + * event->button == GDK_BUTTON_SECONDARY + * ``` * * Returns: %TRUE if the event should trigger a context menu. */