Project

General

Profile

Bug #1489 » 1489-S3_3+Main.patch

Dean Brown, 06/08/2025 04:21 AM

View differences:

1489-S3_1+S3_2.patch
From fd92784ccd6310921f6173735ba46735b368596b Mon Sep 17 00:00:00 2001
From: Dino <macwiz23@comcast.net>
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 "<Meta>"
+#define ACCL_MOD_MASK GDK_META_MASK
+#else
+#define ACCL_MOD_KEY "<ctrl>"
+#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 "<Meta>"
-#else
-#define ACCL_MOD_KEY "<ctrl>"
-#endif
-
-
static GMenu *main_menubar = NULL;
static bool menus_built = FALSE;
--
2.31.0
client/gui-gtk-3.22/editgui.c
/************************************************************************//**
Handle ctrl+[key] combinations.
Mac only - Handle meta+[key] combinations.
****************************************************************************/
static gboolean handle_edit_key_press_with_ctrl(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);
}
client/gui-gtk-3.22/gui_main.h
#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"
client/gui-gtk-3.22/menu.c
#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,
client/gui-gtk-4.0/editgui.c
/************************************************************************//**
Handle ctrl+[key] combinations.
Mac only - Handle meta+[key] combinations.
****************************************************************************/
static gboolean handle_edit_key_press_with_ctrl(guint keyval)
{
......
/* 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);
}
client/gui-gtk-4.0/gui_main.h
#include "gui_main_g.h"
#include "options.h"
/* Mac uses "command"/"meta" key for menu accelerator modifier key */
#ifdef __APPLE__
#define ACCL_MOD_KEY "<Meta>"
#define ACCL_MOD_MASK GDK_META_MASK
#else
#define ACCL_MOD_KEY "<ctrl>"
#define ACCL_MOD_MASK GDK_CONTROL_MASK
#endif
#define GUI_NAME_FULL "gui-gtk-4.0"
#define GUI_NAME_SHORT "gtk4"
client/gui-gtk-4.0/menu.c
#include "menu.h"
/* Mac uses "command"/"meta" key for menu accelerator modifier key */
#ifdef __APPLE__
#define ACCL_MOD_KEY "<Meta>"
#else
#define ACCL_MOD_KEY "<ctrl>"
#endif
static GMenu *main_menubar = NULL;
static bool menus_built = FALSE;
client/gui-gtk-5.0/editgui.c
/************************************************************************//**
Handle ctrl+[key] combinations.
Mac only - Handle meta+[key] combinations.
****************************************************************************/
static gboolean handle_edit_key_press_with_ctrl(guint keyval)
{
......
/* 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);
}
client/gui-gtk-5.0/gui_main.h
#include "gui_main_g.h"
#include "options.h"
/* Mac uses "command"/"meta" key for menu accelerator modifier key */
#ifdef __APPLE__
#define ACCL_MOD_KEY "<Meta>"
#define ACCL_MOD_MASK GDK_META_MASK
#else
#define ACCL_MOD_KEY "<ctrl>"
#define ACCL_MOD_MASK GDK_CONTROL_MASK
#endif
#define GUI_NAME_FULL "gui-gtk-4.x"
#define GUI_NAME_SHORT "gtk4x"
client/gui-gtk-5.0/menu.c
#include "menu.h"
/* Mac uses "command"/"meta" key for menu accelerator modifier key */
#ifdef __APPLE__
#define ACCL_MOD_KEY "<Meta>"
#else
#define ACCL_MOD_KEY "<ctrl>"
#endif
static GMenu *main_menubar = NULL;
static bool menus_built = FALSE;
(3-3/4)