From 66bf19c1e0c87e3eec4f8875eb82f775d55706cc Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Tue, 24 Feb 2026 21:48:37 -0500 Subject: [PATCH] wmaker: add new ModifierKeyShortLabels option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch is adding a new ModifierKeyShortLabels option to the WindowMaker file to let the user specify the modifier key labels used in the shortcuts like those appearing in the root menu. For example, to overwrite the default labels, a user can set the new option value to: ModifierKeyShortLabels = ( "\342\207\247", "\342\214\203", "\342\214\245", "\342\207\255", "\342\207\263", "\342\214\230", "\342\207\252", "\342\227\206", "\342\214\245" ); Which is using the same symbols as defined in macos. For example, instead of printing M4+, "\342\214\230" will print the ⌘ (Command) symbol. --- src/WindowMaker.h | 1 + src/defaults.c | 39 +++++++++++++++++++++++++++++++++++++++ src/xmodifier.c | 42 ++++++++++++++++++++++++------------------ 3 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 75464fdf..dea943b9 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -393,6 +393,7 @@ extern struct WPreferences { signed char workspace_name_display_position; unsigned int modifier_mask; /* mask to use as kbd modifier */ char *modifier_labels[7]; /* Names of the modifiers */ + char *modifier_short_labels[9]; /* Short names of the modifiers */ unsigned int supports_tiff; /* Use tiff files */ diff --git a/src/defaults.c b/src/defaults.c index 43860599..6b6bc4c3 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -151,6 +151,7 @@ static WDECallbackUpdate setSwPOptions; static WDECallbackUpdate updateUsableArea; static WDECallbackUpdate setModifierKeyLabels; +static WDECallbackUpdate setModifierShortKeyLabels; static WDECallbackUpdate setHotCornerActions; static WDECallbackConvert getCursor; @@ -624,6 +625,8 @@ WDefaultEntry optionList[] = { NULL, getPropList, setSwPOptions, NULL, NULL}, {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences, NULL, getPropList, setModifierKeyLabels, NULL, NULL}, + {"ModifierKeyShortLabels", "(\"Sh+\", \"^\", \"M1+\", \"M2+\", \"M3+\", \"M4+\", \"M5+\", \"M+\", \"A+\")", &wPreferences, + NULL, getPropList, setModifierShortKeyLabels, NULL, NULL}, {"FrameBorderWidth", "1", NULL, NULL, getInt, setFrameBorderWidth, NULL, NULL}, {"FrameBorderColor", "black", NULL, @@ -3499,6 +3502,42 @@ static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdat return 0; } +static int setModifierShortKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) +{ + WMPropList *array = tdata; + int i; + struct WPreferences *prefs = foo; + + if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 9) { + wwarning(_("Value for option \"%s\" must be an array of 9 strings"), entry->key); + WMReleasePropList(array); + return 0; + } + + DestroyWindowMenu(scr); + + for (i = 0; i < 9; i++) { + if (prefs->modifier_short_labels[i]) + wfree(prefs->modifier_short_labels[i]); + + if (WMIsPLString(WMGetFromPLArray(array, i))) { + prefs->modifier_short_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i))); + if (prefs->modifier_short_labels[i][0] == '\0') { + wwarning(_("Invalid argument for option \"%s\" item %d, cannot be empty"), entry->key, i); + wfree(prefs->modifier_short_labels[i]); + prefs->modifier_short_labels[i] = NULL; + } + } else { + wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i); + prefs->modifier_short_labels[i] = NULL; + } + } + + WMReleasePropList(array); + + return 0; +} + static int setHotCornerActions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { WMPropList *array = tdata; diff --git a/src/xmodifier.c b/src/xmodifier.c index e2c0fa2a..f4bdd0d0 100644 --- a/src/xmodifier.c +++ b/src/xmodifier.c @@ -280,24 +280,30 @@ const char *wXModifierToShortcutLabel(int mask) if (mask < 0) return NULL; - if (mask == ShiftMask) - return "Sh+"; - if (mask == ControlMask) - return "^"; - if (mask == AltMask) - return "A+"; - if (mask == Mod1Mask) - return "M1+"; - if (mask == Mod2Mask) - return "M2+"; - if (mask == Mod3Mask) - return "M3+"; - if (mask == Mod4Mask) - return "M4+"; - if (mask == Mod5Mask) - return "M5+"; - if (mask == MetaMask) - return "M+"; + struct map_entry { + int mask; + int label_index; + const char *def; + } maps[] = { + { ShiftMask, 0, "Sh+"}, + { ControlMask, 1, "^" }, + { AltMask, 8, "A+" }, + { Mod1Mask, 2, "M1+"}, + { Mod2Mask, 3, "M2+"}, + { Mod3Mask, 4, "M3+"}, + { Mod4Mask, 5, "M4+"}, + { Mod5Mask, 6, "M5+"}, + { MetaMask, 7, "M+" } + }; + + for (size_t i = 0; i < sizeof(maps)/sizeof(maps[0]); i++) { + if (mask == maps[i].mask) { + int idx = maps[i].label_index; + if (idx >= 0 && idx < 9 && wPreferences.modifier_short_labels[idx]) + return wPreferences.modifier_short_labels[idx]; + return maps[i].def; + } + } wwarning(_("Can't convert keymask 0x%04X to a shortcut label"), mask); return NULL;