From b65bd2bd4c6a770564db59302016b97cb1b0dbda Mon Sep 17 00:00:00 2001 From: Gabriele Barbero Date: Sat, 17 May 2025 17:52:35 +0200 Subject: [PATCH] widgets: ignore GDK_MOD2_MASK when... ...remapping shortcuts with GDK_META_MASK On macOS, the Command key is GDK_META_MASK. But when setting a shortcut, GDK_MOD2_MASK is added too. This extra modifier makes it hard to check if the shortcut is already in use. GIMP sees it as a different combination, even if it's really the same. Now, when GDK_META_MASK is used, we remove GDK_MOD2_MASK. This helps GIMP detect existing shortcuts correctly and avoid duplicates. --- app/widgets/gimpactionview.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/widgets/gimpactionview.c b/app/widgets/gimpactionview.c index 632e312319..b5e42ca2d7 100644 --- a/app/widgets/gimpactionview.c +++ b/app/widgets/gimpactionview.c @@ -712,6 +712,18 @@ gimp_action_view_accel_edited (GtkCellRendererAccel *accel, accel_mask == action_accel_mask) return; +#if defined(__APPLE__) + /* On macOS, pressing the Command key (GDK_META_MASK) often results in + * GDK_MOD2_MASK being added automatically by the system. + * This causes shortcut comparisons to fail because GIMP treats + * "Command" and "Command+Mod2" as different combinations. + * To avoid false mismatches and detect duplicates correctly, + * we remove GDK_MOD2_MASK whenever GDK_META_MASK is present. + */ + if ((accel_mask & (GDK_META_MASK | GDK_MOD2_MASK)) == (GDK_META_MASK | GDK_MOD2_MASK)) + accel_mask &= ~GDK_MOD2_MASK; +#endif + if (! accel_key || /* Don't allow arrow keys, they are all swallowed by the canvas