From e08405537571cb064fb29dfcf0a7d104b2852720 Mon Sep 17 00:00:00 2001 From: Dino Date: Sat, 7 Jun 2025 21:18:22 -0400 Subject: [PATCH] #1489, handle_edit_key_press() needs to handle platform specific ctrl/meta modifier. Macro for platform specific menu accelerator modifier keys moved from menu,c to gui_main.h. --- 1489-S3_1+S3_2.patch | 143 +++++++++++++++++++++++++++++++++ client/gui-gtk-3.22/editgui.c | 6 +- client/gui-gtk-3.22/gui_main.h | 7 ++ client/gui-gtk-3.22/menu.c | 8 -- client/gui-gtk-4.0/editgui.c | 4 +- client/gui-gtk-4.0/gui_main.h | 10 +++ client/gui-gtk-4.0/menu.c | 8 -- client/gui-gtk-5.0/editgui.c | 4 +- client/gui-gtk-5.0/gui_main.h | 10 +++ client/gui-gtk-5.0/menu.c | 8 -- 10 files changed, 180 insertions(+), 28 deletions(-) create mode 100644 1489-S3_1+S3_2.patch diff --git a/1489-S3_1+S3_2.patch b/1489-S3_1+S3_2.patch new file mode 100644 index 0000000000..fd609b4d59 --- /dev/null +++ b/1489-S3_1+S3_2.patch @@ -0,0 +1,143 @@ +From fd92784ccd6310921f6173735ba46735b368596b Mon Sep 17 00:00:00 2001 +From: Dino +Date: Sat, 7 Jun 2025 20:08:14 -0400 +Subject: [PATCH] #1489, handle_edit_key_press() needs to handle platform + specific ctrl/meta modifier. Macro for platform specific menu accelerator + modifier keys moved from menu,c to gui_main.h. + +--- + client/gui-gtk-3.22/editgui.c | 6 ++++-- + client/gui-gtk-3.22/gui_main.h | 7 +++++++ + client/gui-gtk-3.22/menu.c | 8 -------- + client/gui-gtk-4.0/editgui.c | 4 +++- + client/gui-gtk-4.0/gui_main.h | 10 ++++++++++ + client/gui-gtk-4.0/menu.c | 8 -------- + 6 files changed, 24 insertions(+), 19 deletions(-) + +diff --git a/client/gui-gtk-3.22/editgui.c b/client/gui-gtk-3.22/editgui.c +index 75ed1ac454..35e1df638e 100644 +--- a/client/gui-gtk-3.22/editgui.c ++++ b/client/gui-gtk-3.22/editgui.c +@@ -1602,6 +1602,7 @@ static void editinfobox_refresh(struct editinfobox *ei) + + /************************************************************************//** + Handle ctrl+[key] combinations. ++ Mac only - Handle meta+[key] combinations. + ****************************************************************************/ + static gboolean handle_edit_key_press_with_ctrl(GdkEventKey *ev) + { +@@ -1663,9 +1664,10 @@ gboolean handle_edit_key_press(GdkEventKey *ev) + { + enum editor_tool_type ett, new_ett = NUM_EDITOR_TOOL_TYPES; + +- /* Check ctrl before shift - this is correct also for the case where ++ /* Check ctrl/meta before shift - this is correct also for the case where + * they are both active. */ +- if (ev->state & GDK_CONTROL_MASK) { ++ /* ACCL_MOD_KEY is GDK_META_MASK on Mac, else GDK_CONTROL_MASK */ ++ if (ev->state & ACCL_MOD_KEY) { + return handle_edit_key_press_with_ctrl(ev); + } + +diff --git a/client/gui-gtk-3.22/gui_main.h b/client/gui-gtk-3.22/gui_main.h +index 8f7f665429..061aad71b2 100644 +--- a/client/gui-gtk-3.22/gui_main.h ++++ b/client/gui-gtk-3.22/gui_main.h +@@ -19,6 +19,13 @@ + #include "gui_main_g.h" + #include "options.h" + ++/* Mac uses "command"/"meta" key for menu accelerator modifier key */ ++#ifdef __APPLE__ ++#define ACCL_MOD_KEY GDK_META_MASK ++#else ++#define ACCL_MOD_KEY GDK_CONTROL_MASK ++#endif ++ + #define GUI_NAME_FULL "gui-gtk-3.22" + #define GUI_NAME_SHORT "gtk3.22" + +diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c +index acfadeb3ea..a5ef17ff20 100644 +--- a/client/gui-gtk-3.22/menu.c ++++ b/client/gui-gtk-3.22/menu.c +@@ -75,14 +75,6 @@ + #define GTK_STOCK_EDIT NULL + #endif + +-/* Mac uses "command"/"meta" key for menu accelerator modifier key */ +-#ifdef __APPLE__ +-#define ACCL_MOD_KEY GDK_META_MASK +-#else +-#define ACCL_MOD_KEY GDK_CONTROL_MASK +-#endif +- +- + static GtkBuilder *ui_builder = NULL; + + static void menu_entry_set_active(const char *key, +diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c +index 04cb8fde18..ba1501ddc8 100644 +--- a/client/gui-gtk-4.0/editgui.c ++++ b/client/gui-gtk-4.0/editgui.c +@@ -1612,6 +1612,7 @@ static void editinfobox_refresh(struct editinfobox *ei) + + /************************************************************************//** + Handle ctrl+[key] combinations. ++ Mac only - Handle meta+[key] combinations. + ****************************************************************************/ + static gboolean handle_edit_key_press_with_ctrl(guint keyval) + { +@@ -1675,7 +1676,8 @@ gboolean handle_edit_key_press(guint keyval, GdkModifierType state) + + /* Check ctrl before shift - this is correct also for the case where + * they are both active. */ +- if (state & GDK_CONTROL_MASK) { ++ /* ACCL_MOD_MASK is GDK_META_MASK on Mac, else GDK_CONTROL_MASK */ ++ if (state & ACCL_MOD_MASK) { + return handle_edit_key_press_with_ctrl(keyval); + } + +diff --git a/client/gui-gtk-4.0/gui_main.h b/client/gui-gtk-4.0/gui_main.h +index 34ed5e7414..1a6e7571e6 100644 +--- a/client/gui-gtk-4.0/gui_main.h ++++ b/client/gui-gtk-4.0/gui_main.h +@@ -19,6 +19,16 @@ + #include "gui_main_g.h" + #include "options.h" + ++ ++/* Mac uses "command"/"meta" key for menu accelerator modifier key */ ++#ifdef __APPLE__ ++#define ACCL_MOD_KEY "" ++#define ACCL_MOD_MASK GDK_META_MASK ++#else ++#define ACCL_MOD_KEY "" ++#define ACCL_MOD_MASK GDK_CONTROL_MASK ++#endif ++ + #define GUI_NAME_FULL "gui-gtk-4.0" + #define GUI_NAME_SHORT "gtk4" + +diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c +index e3708c927c..1036d474b8 100644 +--- a/client/gui-gtk-4.0/menu.c ++++ b/client/gui-gtk-4.0/menu.c +@@ -71,14 +71,6 @@ + + #include "menu.h" + +-/* Mac uses "command"/"meta" key for menu accelerator modifier key */ +-#ifdef __APPLE__ +-#define ACCL_MOD_KEY "" +-#else +-#define ACCL_MOD_KEY "" +-#endif +- +- + static GMenu *main_menubar = NULL; + static bool menus_built = FALSE; + +-- +2.31.0 + diff --git a/client/gui-gtk-3.22/editgui.c b/client/gui-gtk-3.22/editgui.c index 75ed1ac454..35e1df638e 100644 --- a/client/gui-gtk-3.22/editgui.c +++ b/client/gui-gtk-3.22/editgui.c @@ -1602,6 +1602,7 @@ static void editinfobox_refresh(struct editinfobox *ei) /************************************************************************//** Handle ctrl+[key] combinations. + Mac only - Handle meta+[key] combinations. ****************************************************************************/ static gboolean handle_edit_key_press_with_ctrl(GdkEventKey *ev) { @@ -1663,9 +1664,10 @@ gboolean handle_edit_key_press(GdkEventKey *ev) { enum editor_tool_type ett, new_ett = NUM_EDITOR_TOOL_TYPES; - /* Check ctrl before shift - this is correct also for the case where + /* Check ctrl/meta before shift - this is correct also for the case where * they are both active. */ - if (ev->state & GDK_CONTROL_MASK) { + /* ACCL_MOD_KEY is GDK_META_MASK on Mac, else GDK_CONTROL_MASK */ + if (ev->state & ACCL_MOD_KEY) { return handle_edit_key_press_with_ctrl(ev); } diff --git a/client/gui-gtk-3.22/gui_main.h b/client/gui-gtk-3.22/gui_main.h index 8f7f665429..061aad71b2 100644 --- a/client/gui-gtk-3.22/gui_main.h +++ b/client/gui-gtk-3.22/gui_main.h @@ -19,6 +19,13 @@ #include "gui_main_g.h" #include "options.h" +/* Mac uses "command"/"meta" key for menu accelerator modifier key */ +#ifdef __APPLE__ +#define ACCL_MOD_KEY GDK_META_MASK +#else +#define ACCL_MOD_KEY GDK_CONTROL_MASK +#endif + #define GUI_NAME_FULL "gui-gtk-3.22" #define GUI_NAME_SHORT "gtk3.22" diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index 297fc0ee24..64561c265f 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -74,14 +74,6 @@ #define GTK_STOCK_EDIT NULL #endif -/* Mac uses "command"/"meta" key for menu accelerator modifier key */ -#ifdef __APPLE__ -#define ACCL_MOD_KEY GDK_META_MASK -#else -#define ACCL_MOD_KEY GDK_CONTROL_MASK -#endif - - static GtkBuilder *ui_builder = NULL; static void menu_entry_set_active(const char *key, diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c index 53f89d6ea5..6d681e1b22 100644 --- a/client/gui-gtk-4.0/editgui.c +++ b/client/gui-gtk-4.0/editgui.c @@ -1612,6 +1612,7 @@ static void editinfobox_refresh(struct editinfobox *ei) /************************************************************************//** Handle ctrl+[key] combinations. + Mac only - Handle meta+[key] combinations. ****************************************************************************/ static gboolean handle_edit_key_press_with_ctrl(guint keyval) { @@ -1675,7 +1676,8 @@ gboolean handle_edit_key_press(guint keyval, GdkModifierType state) /* Check ctrl before shift - this is correct also for the case where * they are both active. */ - if (state & GDK_CONTROL_MASK) { + /* ACCL_MOD_MASK is GDK_META_MASK on Mac, else GDK_CONTROL_MASK */ + if (state & ACCL_MOD_MASK) { return handle_edit_key_press_with_ctrl(keyval); } diff --git a/client/gui-gtk-4.0/gui_main.h b/client/gui-gtk-4.0/gui_main.h index 6ad8a7f696..fff13e12ec 100644 --- a/client/gui-gtk-4.0/gui_main.h +++ b/client/gui-gtk-4.0/gui_main.h @@ -19,6 +19,16 @@ #include "gui_main_g.h" #include "options.h" + +/* Mac uses "command"/"meta" key for menu accelerator modifier key */ +#ifdef __APPLE__ +#define ACCL_MOD_KEY "" +#define ACCL_MOD_MASK GDK_META_MASK +#else +#define ACCL_MOD_KEY "" +#define ACCL_MOD_MASK GDK_CONTROL_MASK +#endif + #define GUI_NAME_FULL "gui-gtk-4.0" #define GUI_NAME_SHORT "gtk4" diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index d3b24ef287..15f769f4af 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -70,14 +70,6 @@ #include "menu.h" -/* Mac uses "command"/"meta" key for menu accelerator modifier key */ -#ifdef __APPLE__ -#define ACCL_MOD_KEY "" -#else -#define ACCL_MOD_KEY "" -#endif - - static GMenu *main_menubar = NULL; static bool menus_built = FALSE; diff --git a/client/gui-gtk-5.0/editgui.c b/client/gui-gtk-5.0/editgui.c index 85561acd94..696d9d43e4 100644 --- a/client/gui-gtk-5.0/editgui.c +++ b/client/gui-gtk-5.0/editgui.c @@ -1612,6 +1612,7 @@ static void editinfobox_refresh(struct editinfobox *ei) /************************************************************************//** Handle ctrl+[key] combinations. + Mac only - Handle meta+[key] combinations. ****************************************************************************/ static gboolean handle_edit_key_press_with_ctrl(guint keyval) { @@ -1675,7 +1676,8 @@ gboolean handle_edit_key_press(guint keyval, GdkModifierType state) /* Check ctrl before shift - this is correct also for the case where * they are both active. */ - if (state & GDK_CONTROL_MASK) { + /* ACCL_MOD_MASK is GDK_META_MASK on Mac, else GDK_CONTROL_MASK */ + if (state & ACCL_MOD_MASK) { return handle_edit_key_press_with_ctrl(keyval); } diff --git a/client/gui-gtk-5.0/gui_main.h b/client/gui-gtk-5.0/gui_main.h index 9fc496bdb8..9348f7b641 100644 --- a/client/gui-gtk-5.0/gui_main.h +++ b/client/gui-gtk-5.0/gui_main.h @@ -19,6 +19,16 @@ #include "gui_main_g.h" #include "options.h" + +/* Mac uses "command"/"meta" key for menu accelerator modifier key */ +#ifdef __APPLE__ +#define ACCL_MOD_KEY "" +#define ACCL_MOD_MASK GDK_META_MASK +#else +#define ACCL_MOD_KEY "" +#define ACCL_MOD_MASK GDK_CONTROL_MASK +#endif + #define GUI_NAME_FULL "gui-gtk-4.x" #define GUI_NAME_SHORT "gtk4x" diff --git a/client/gui-gtk-5.0/menu.c b/client/gui-gtk-5.0/menu.c index 7398bc8580..5e30a7a88d 100644 --- a/client/gui-gtk-5.0/menu.c +++ b/client/gui-gtk-5.0/menu.c @@ -70,14 +70,6 @@ #include "menu.h" -/* Mac uses "command"/"meta" key for menu accelerator modifier key */ -#ifdef __APPLE__ -#define ACCL_MOD_KEY "" -#else -#define ACCL_MOD_KEY "" -#endif - - static GMenu *main_menubar = NULL; static bool menus_built = FALSE; -- 2.31.0