mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +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:
committed by
Carlos R. Mafra
parent
3bd9e8358f
commit
118beb2c60
33
src/misc.c
33
src/misc.c
@@ -731,49 +731,28 @@ static char *keysymToString(KeySym keysym, unsigned int state)
|
||||
char *GetShortcutString(const char *shortcut)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
char *k;
|
||||
int control = 0;
|
||||
char *tmp, *text;
|
||||
char *k, *tmp, *text;
|
||||
|
||||
tmp = text = wstrdup(shortcut);
|
||||
|
||||
/* get modifiers */
|
||||
while ((k = strchr(text, '+')) != NULL) {
|
||||
int mod;
|
||||
const char *lbl;
|
||||
|
||||
*k = 0;
|
||||
mod = wXModifierFromKey(text);
|
||||
if (mod < 0) {
|
||||
return wstrdup("bug");
|
||||
}
|
||||
|
||||
if (strcasecmp(text, "Meta") == 0) {
|
||||
buffer = wstrappend(buffer, "M+");
|
||||
} else if (strcasecmp(text, "Alt") == 0) {
|
||||
buffer = wstrappend(buffer, "A+");
|
||||
} else if (strcasecmp(text, "Shift") == 0) {
|
||||
buffer = wstrappend(buffer, "Sh+");
|
||||
} else if (strcasecmp(text, "Mod1") == 0) {
|
||||
buffer = wstrappend(buffer, "M1+");
|
||||
} else if (strcasecmp(text, "Mod2") == 0) {
|
||||
buffer = wstrappend(buffer, "M2+");
|
||||
} else if (strcasecmp(text, "Mod3") == 0) {
|
||||
buffer = wstrappend(buffer, "M3+");
|
||||
} else if (strcasecmp(text, "Mod4") == 0) {
|
||||
buffer = wstrappend(buffer, "M4+");
|
||||
} else if (strcasecmp(text, "Mod5") == 0) {
|
||||
buffer = wstrappend(buffer, "M5+");
|
||||
} else if (strcasecmp(text, "Control") == 0) {
|
||||
control = 1;
|
||||
} else {
|
||||
lbl = wXModifierToShortcutLabel(mod);
|
||||
if (lbl)
|
||||
buffer = wstrappend(buffer, lbl);
|
||||
else
|
||||
buffer = wstrappend(buffer, text);
|
||||
}
|
||||
text = k + 1;
|
||||
}
|
||||
|
||||
if (control) {
|
||||
buffer = wstrappend(buffer, "^");
|
||||
}
|
||||
buffer = wstrappend(buffer, text);
|
||||
wfree(tmp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user