1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 22:28:02 +01:00

wmaker: improve key shortcut labelling

This patch is improving the key shortcut labelling in the root menu.
It modifies the GetShortcutString function to save some cycles
as wXModifierFromKey is already doing all the string comparisons.
This patch introduces a new function called wXModifierToShortcutLabel
that is checking the return value from wXModifierFromKey.
Not sure why Control was set as a special key, as keyboards could
have 2 controls but also 2 shift keys.

Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
David Maciejak
2014-09-01 12:48:36 +07:00
committed by Carlos R. Mafra
parent 3bd9e8358f
commit 118beb2c60
3 changed files with 35 additions and 27 deletions

View File

@@ -262,6 +262,34 @@ static void x_reset_modifier_mapping(Display * display)
XFreeModifiermap(x_modifier_keymap);
}
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+";
wwarning("Can't convert keymask %d to shortcut label", mask);
return NULL;
}
int wXModifierFromKey(const char *key)
{
if (strcasecmp(key, "SHIFT") == 0 && ShiftMask != 0)