From 517bedbcfbd6764ccb4f97ff8dde718f6eadde99 Mon Sep 17 00:00:00 2001 From: Dino Date: Sun, 27 Jul 2025 20:37:53 -0400 Subject: [PATCH] #1483 fix shortcut key for View -> Show Stack Size not working on Mac --- client/gui-gtk-3.22/editgui.c | 4 +- client/gui-gtk-3.22/gui_main.c | 5 +-- client/gui-gtk-3.22/gui_main.h | 6 ++- client/gui-gtk-3.22/menu.c | 68 +++++++++++++++++----------------- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/client/gui-gtk-3.22/editgui.c b/client/gui-gtk-3.22/editgui.c index 35e1df638e..559dcf5058 100644 --- a/client/gui-gtk-3.22/editgui.c +++ b/client/gui-gtk-3.22/editgui.c @@ -1666,8 +1666,8 @@ gboolean handle_edit_key_press(GdkEventKey *ev) /* Check ctrl/meta before shift - this is correct also for the case where * they are both active. */ - /* ACCL_MOD_KEY is GDK_META_MASK on Mac, else GDK_CONTROL_MASK */ - if (ev->state & ACCL_MOD_KEY) { + /* ACCL_MOD_MASK is GDK_META_MASK on Mac, else GDK_CONTROL_MASK */ + if (ev->state & ACCL_MOD_MASK) { return handle_edit_key_press_with_ctrl(ev); } diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c index adcb6c4f84..e014945d64 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -447,13 +447,11 @@ static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, bool volchange = FALSE; switch (ev->keyval) { - case GDK_KEY_plus: case GDK_KEY_KP_Add: gui_options.sound_effects_volume += 10; volchange = TRUE; break; - case GDK_KEY_minus: case GDK_KEY_KP_Subtract: gui_options.sound_effects_volume -= 10; volchange = TRUE; @@ -471,7 +469,8 @@ static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, return TRUE; } - } else if (!(ev->state & GDK_CONTROL_MASK)) { + } + if (!(ev->state & ACCL_MOD_MASK)) { switch (ev->keyval) { case GDK_KEY_plus: case GDK_KEY_KP_Add: diff --git a/client/gui-gtk-3.22/gui_main.h b/client/gui-gtk-3.22/gui_main.h index 061aad71b2..e92739ee81 100644 --- a/client/gui-gtk-3.22/gui_main.h +++ b/client/gui-gtk-3.22/gui_main.h @@ -21,9 +21,11 @@ /* Mac uses "command"/"meta" key for menu accelerator modifier key */ #ifdef __APPLE__ -#define ACCL_MOD_KEY GDK_META_MASK +#define ACCL_MOD_KEY "" +#define ACCL_MOD_MASK GDK_META_MASK #else -#define ACCL_MOD_KEY GDK_CONTROL_MASK +#define ACCL_MOD_KEY "" +#define ACCL_MOD_MASK GDK_CONTROL_MASK #endif #define GUI_NAME_FULL "gui-gtk-3.22" diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index 2fb9ff2dd0..2a41a6a9b5 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -290,9 +290,9 @@ static struct menu_entry_info menu_entries[] = { "SAVE_OPTIONS", N_("Save Options _Now"), 0, 0, G_CALLBACK(save_options_callback), MGROUP_SAFE }, { "RELOAD_TILESET", N_("_Reload Tileset"), - GDK_KEY_r, GDK_MOD1_MASK | ACCL_MOD_KEY, + GDK_KEY_r, GDK_MOD1_MASK | ACCL_MOD_MASK, G_CALLBACK(reload_tileset_callback), MGROUP_SAFE }, - { "GAME_SAVE", N_("_Save Game"), GDK_KEY_s, ACCL_MOD_KEY, + { "GAME_SAVE", N_("_Save Game"), GDK_KEY_s, ACCL_MOD_MASK, G_CALLBACK(save_game_callback), MGROUP_SAFE }, { "GAME_SAVE_AS", N_("Save Game _As..."), 0, 0, G_CALLBACK(save_game_as_callback), MGROUP_SAFE }, @@ -301,18 +301,18 @@ static struct menu_entry_info menu_entries[] = { "MAPIMG_SAVE_AS", N_("Save _Map Image As..."), 0, 0, G_CALLBACK(save_mapimg_as_callback), MGROUP_SAFE }, { "LEAVE", N_("_Leave"), 0, 0, G_CALLBACK(leave_callback), MGROUP_SAFE }, - { "QUIT", N_("_Quit"), GDK_KEY_q, ACCL_MOD_KEY, + { "QUIT", N_("_Quit"), GDK_KEY_q, ACCL_MOD_MASK, G_CALLBACK(quit_callback), MGROUP_SAFE }, - { "FIND_CITY", N_("_Find City"), GDK_KEY_f, ACCL_MOD_KEY, + { "FIND_CITY", N_("_Find City"), GDK_KEY_f, ACCL_MOD_MASK, G_CALLBACK(find_city_callback), MGROUP_SAFE }, { "WORKLISTS", N_("Work_lists"), - GDK_KEY_l, ACCL_MOD_KEY | GDK_SHIFT_MASK, + GDK_KEY_l, ACCL_MOD_MASK | GDK_SHIFT_MASK, G_CALLBACK(worklists_callback), MGROUP_SAFE }, { "RALLY_DLG", N_("Rally point dialog"), - GDK_KEY_r, ACCL_MOD_KEY | GDK_SHIFT_MASK, + GDK_KEY_r, ACCL_MOD_MASK | GDK_SHIFT_MASK, G_CALLBACK(rally_dialog_callback), MGROUP_SAFE }, { "INFRA_DLG", N_("Infra dialog"), - GDK_KEY_f, ACCL_MOD_KEY | GDK_SHIFT_MASK, + GDK_KEY_f, ACCL_MOD_MASK | GDK_SHIFT_MASK, G_CALLBACK(infra_dialog_callback), MGROUP_SAFE }, { "CLIENT_LUA_SCRIPT", N_("Client _Lua Script"), 0, 0, G_CALLBACK(client_lua_script_callback), MGROUP_SAFE }, @@ -339,37 +339,37 @@ static struct menu_entry_info menu_entries[] = GDK_KEY_F1, GDK_SHIFT_MASK, G_CALLBACK(bg_select0_callback), MGROUP_SAFE }, { "BATTLE_GROUP_ASSIGN_0", N_("Assign Battle Group 1"), - GDK_KEY_F1, ACCL_MOD_KEY, + GDK_KEY_F1, ACCL_MOD_MASK, G_CALLBACK(bg_assign0_callback), MGROUP_SAFE }, { "BATTLE_GROUP_APPEND_0", N_("Append to Battle Group 1"), - GDK_KEY_F1, GDK_SHIFT_MASK | ACCL_MOD_KEY, + GDK_KEY_F1, GDK_SHIFT_MASK | ACCL_MOD_MASK, G_CALLBACK(bg_append0_callback), MGROUP_SAFE }, { "BATTLE_GROUP_SELECT_1", N_("Select Battle Group 2"), GDK_KEY_F2, GDK_SHIFT_MASK, G_CALLBACK(bg_select1_callback), MGROUP_SAFE }, { "BATTLE_GROUP_ASSIGN_1", N_("Assign Battle Group 2"), - GDK_KEY_F2, ACCL_MOD_KEY, + GDK_KEY_F2, ACCL_MOD_MASK, G_CALLBACK(bg_assign1_callback), MGROUP_SAFE }, { "BATTLE_GROUP_APPEND_1", N_("Append to Battle Group 2"), - GDK_KEY_F2, GDK_SHIFT_MASK | ACCL_MOD_KEY, + GDK_KEY_F2, GDK_SHIFT_MASK | ACCL_MOD_MASK, G_CALLBACK(bg_append1_callback), MGROUP_SAFE }, { "BATTLE_GROUP_SELECT_2", N_("Select Battle Group 3"), GDK_KEY_F3, GDK_SHIFT_MASK, G_CALLBACK(bg_select2_callback), MGROUP_SAFE }, { "BATTLE_GROUP_ASSIGN_2", N_("Assign Battle Group 3"), - GDK_KEY_F3, ACCL_MOD_KEY, + GDK_KEY_F3, ACCL_MOD_MASK, G_CALLBACK(bg_assign2_callback), MGROUP_SAFE }, { "BATTLE_GROUP_APPEND_2", N_("Append to Battle Group 3"), - GDK_KEY_F3, GDK_SHIFT_MASK | ACCL_MOD_KEY, + GDK_KEY_F3, GDK_SHIFT_MASK | ACCL_MOD_MASK, G_CALLBACK(bg_append2_callback), MGROUP_SAFE }, { "BATTLE_GROUP_SELECT_3", N_("Select Battle Group 4"), GDK_KEY_F4, GDK_SHIFT_MASK, G_CALLBACK(bg_select3_callback), MGROUP_SAFE }, { "BATTLE_GROUP_ASSIGN_3", N_("Assign Battle Group 4"), - GDK_KEY_F4, ACCL_MOD_KEY, + GDK_KEY_F4, ACCL_MOD_MASK, G_CALLBACK(bg_assign3_callback), MGROUP_SAFE }, { "BATTLE_GROUP_APPEND_3", N_("Append to Battle Group 4"), - GDK_KEY_F4, GDK_SHIFT_MASK | ACCL_MOD_KEY, + GDK_KEY_F4, GDK_SHIFT_MASK | ACCL_MOD_MASK, G_CALLBACK(bg_append3_callback), MGROUP_SAFE }, { "HELP_OVERVIEW", N_("?help:Overview"), 0, 0, @@ -428,29 +428,29 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(help_about_callback), MGROUP_SAFE }, { "SAVE_OPTIONS_ON_EXIT", N_("Save Options on _Exit"), 0, 0, G_CALLBACK(save_options_on_exit_callback), MGROUP_SAFE }, - { "EDIT_MODE", N_("_Editing Mode"), GDK_KEY_e, ACCL_MOD_KEY, + { "EDIT_MODE", N_("_Editing Mode"), GDK_KEY_e, ACCL_MOD_MASK, G_CALLBACK(edit_mode_callback), MGROUP_SAFE }, - { "SHOW_CITY_OUTLINES", N_("Cit_y Outlines"), GDK_KEY_y, ACCL_MOD_KEY, + { "SHOW_CITY_OUTLINES", N_("Cit_y Outlines"), GDK_KEY_y, ACCL_MOD_MASK, G_CALLBACK(show_city_outlines_callback), MGROUP_SAFE }, - { "SHOW_CITY_OUTPUT", N_("City Output"), GDK_KEY_v, ACCL_MOD_KEY, + { "SHOW_CITY_OUTPUT", N_("City Output"), GDK_KEY_v, ACCL_MOD_MASK, G_CALLBACK(show_city_output_callback), MGROUP_SAFE }, - { "SHOW_MAP_GRID", N_("Map _Grid"), GDK_KEY_g, ACCL_MOD_KEY, + { "SHOW_MAP_GRID", N_("Map _Grid"), GDK_KEY_g, ACCL_MOD_MASK, G_CALLBACK(show_map_grid_callback), MGROUP_SAFE }, - { "SHOW_NATIONAL_BORDERS", N_("National _Borders"), GDK_KEY_b, ACCL_MOD_KEY, + { "SHOW_NATIONAL_BORDERS", N_("National _Borders"), GDK_KEY_b, ACCL_MOD_MASK, G_CALLBACK(show_national_borders_callback), MGROUP_SAFE }, - { "SHOW_NATIVE_TILES", N_("Native Tiles"), GDK_KEY_n, ACCL_MOD_KEY | GDK_SHIFT_MASK, + { "SHOW_NATIVE_TILES", N_("Native Tiles"), GDK_KEY_n, ACCL_MOD_MASK | GDK_SHIFT_MASK, G_CALLBACK(show_native_tiles_callback), MGROUP_SAFE }, { "SHOW_CITY_FULL_BAR", N_("City Full Bar"), 0, 0, G_CALLBACK(show_city_full_bar_callback), MGROUP_SAFE }, - { "SHOW_CITY_NAMES", N_("City _Names"), GDK_KEY_n, ACCL_MOD_KEY, + { "SHOW_CITY_NAMES", N_("City _Names"), GDK_KEY_n, ACCL_MOD_MASK, G_CALLBACK(show_city_names_callback), MGROUP_SAFE }, - { "SHOW_CITY_GROWTH", N_("City G_rowth"), GDK_KEY_o, ACCL_MOD_KEY, + { "SHOW_CITY_GROWTH", N_("City G_rowth"), GDK_KEY_o, ACCL_MOD_MASK, G_CALLBACK(show_city_growth_callback), MGROUP_SAFE }, - { "SHOW_CITY_PRODUCTIONS", N_("City _Production"), GDK_KEY_p, ACCL_MOD_KEY, + { "SHOW_CITY_PRODUCTIONS", N_("City _Production"), GDK_KEY_p, ACCL_MOD_MASK, G_CALLBACK(show_city_productions_callback), MGROUP_SAFE }, { "SHOW_CITY_BUY_COST", N_("City Buy Cost"), 0, 0, G_CALLBACK(show_city_buy_cost_callback), MGROUP_SAFE }, - { "SHOW_CITY_TRADE_ROUTES", N_("City Tra_deroutes"), GDK_KEY_d, ACCL_MOD_KEY, + { "SHOW_CITY_TRADE_ROUTES", N_("City Tra_deroutes"), GDK_KEY_d, ACCL_MOD_MASK, G_CALLBACK(show_city_trade_routes_callback), MGROUP_SAFE }, { "SHOW_TERRAIN", N_("_Terrain"), 0, 0, G_CALLBACK(show_terrain_callback), MGROUP_SAFE }, @@ -479,7 +479,7 @@ static struct menu_entry_info menu_entries[] = { "SHOW_UNIT_SHIELDS", N_("Unit shields"), 0, 0, G_CALLBACK(show_unit_shields_callback), MGROUP_SAFE }, { "SHOW_STACK_SIZE", N_("Unit Stack Size"), - GDK_KEY_plus, ACCL_MOD_KEY, + GDK_KEY_plus, ACCL_MOD_MASK, G_CALLBACK(show_stack_size_callback), MGROUP_SAFE }, { "SHOW_FOCUS_UNIT", N_("Focu_s Unit"), 0, 0, G_CALLBACK(show_focus_unit_callback), MGROUP_SAFE }, @@ -491,7 +491,7 @@ static struct menu_entry_info menu_entries[] = { "RECALC_BORDERS", N_("Recalculate _Borders"), 0, 0, G_CALLBACK(recalc_borders_callback), MGROUP_EDIT }, { "TOGGLE_FOG", N_("Toggle Fog of _War"), GDK_KEY_w, - ACCL_MOD_KEY | GDK_SHIFT_MASK, + ACCL_MOD_MASK | GDK_SHIFT_MASK, G_CALLBACK(toggle_fog_callback), MGROUP_EDIT }, { "SCENARIO_PROPERTIES", N_("Game/Scenario Properties"), 0, 0, G_CALLBACK(scenario_properties_callback), MGROUP_EDIT }, @@ -505,7 +505,7 @@ static struct menu_entry_info menu_entries[] = { "REPORT_RESEARCH", N_("_Research"), GDK_KEY_F6, 0, G_CALLBACK(report_research_callback), MGROUP_PLAYER }, { "POLICIES", N_("_Policies..."), - GDK_KEY_p, GDK_SHIFT_MASK | ACCL_MOD_KEY, + GDK_KEY_p, GDK_SHIFT_MASK | ACCL_MOD_MASK, G_CALLBACK(multiplier_callback), MGROUP_PLAYER }, { "REPORT_SPACESHIP", N_("_Spaceship"), GDK_KEY_F12, 0, G_CALLBACK(report_spaceship_callback), MGROUP_PLAYER }, @@ -581,14 +581,14 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(build_mine_callback), MGROUP_UNIT }, { "PLANT", N_("Plant"), GDK_KEY_m, GDK_SHIFT_MASK, G_CALLBACK(plant_callback), MGROUP_UNIT }, - { "CONNECT_ROAD", N_("Connect With Roa_d"), GDK_KEY_r, ACCL_MOD_KEY, + { "CONNECT_ROAD", N_("Connect With Roa_d"), GDK_KEY_r, ACCL_MOD_MASK, G_CALLBACK(connect_road_callback), MGROUP_UNIT }, - { "CONNECT_RAIL", N_("Connect With Rai_l"), GDK_KEY_l, ACCL_MOD_KEY, + { "CONNECT_RAIL", N_("Connect With Rai_l"), GDK_KEY_l, ACCL_MOD_MASK, G_CALLBACK(connect_rail_callback), MGROUP_UNIT }, - { "CONNECT_MAGLEV", N_("Connect With _Maglev"), GDK_KEY_m, ACCL_MOD_KEY, + { "CONNECT_MAGLEV", N_("Connect With _Maglev"), GDK_KEY_m, ACCL_MOD_MASK, G_CALLBACK(connect_maglev_callback), MGROUP_UNIT }, { "CONNECT_IRRIGATION", N_("Connect With Irri_gation"), - GDK_KEY_i, ACCL_MOD_KEY, + GDK_KEY_i, ACCL_MOD_MASK, G_CALLBACK(connect_irrigation_callback), MGROUP_UNIT }, { "TRANSFORM_TERRAIN", N_("Transf_orm Terrain"), GDK_KEY_o, 0, G_CALLBACK(transform_terrain_callback), MGROUP_UNIT }, @@ -609,10 +609,10 @@ static struct menu_entry_info menu_entries[] = { "MENU_GOVERNMENT", N_("_Government"), 0, 0, NULL, MGROUP_PLAYING }, - { "TAX_RATE", N_("_Tax Rates..."), GDK_KEY_t, ACCL_MOD_KEY, + { "TAX_RATE", N_("_Tax Rates..."), GDK_KEY_t, ACCL_MOD_MASK, G_CALLBACK(tax_rate_callback), MGROUP_PLAYING }, { "START_REVOLUTION", N_("_Revolution..."), - GDK_KEY_g, GDK_SHIFT_MASK | ACCL_MOD_KEY, + GDK_KEY_g, GDK_SHIFT_MASK | ACCL_MOD_MASK, G_CALLBACK(government_callback), MGROUP_PLAYING }, { NULL } }; -- 2.31.0