1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

Display modifiers in window menu

The window menu displays the shortcut key for operations with a
shortcut, but does not display the modifiers. This reduces the utility
of the display as it's hard to know whether "h" means "Mod4+h" or
"Ctrl+Mod4+h" or something else.

This patch prefixes those shortcut displays with the modifier names,
e.g. Ctrl+Mod4+h, and adds a preference ModifierKeyLabels to allow
overriding this, e.g. to "⌃◇h". It doesn't add this preference to
WPrefs, if someone else wants to do that feel free.

Signed-off-by: Brad Jorsch <anomie@users.sourceforge.net>
This commit is contained in:
Brad Jorsch
2010-11-16 20:42:04 -05:00
committed by Carlos R. Mafra
parent 1b2745fad8
commit 85f31104cd
4 changed files with 76 additions and 45 deletions

View File

@@ -147,6 +147,8 @@ static int setMenuStyle();
static int setSwPOptions();
static int updateUsableArea();
static int setModifierKeyLabels();
extern Cursor wCursor[WCUR_LAST];
static int getCursor();
static int setCursor();
@@ -511,6 +513,8 @@ WDefaultEntry optionList[] = {
NULL, getColor, setIconTitleBack, NULL, NULL},
{"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
NULL, getPropList, setSwPOptions, NULL, NULL},
{"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
NULL, getPropList, setModifierKeyLabels, NULL, NULL},
/* keybindings */
@@ -2998,6 +3002,36 @@ static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, WMPropList * arra
return 0;
}
static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
{
int i;
WPreferences *prefs = (WPreferences *) foo;
if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
WMReleasePropList(array);
return 0;
}
DestroyWindowMenu(scr);
for (i = 0; i < 7; i++) {
if (prefs->modifier_labels[i])
wfree(prefs->modifier_labels[i]);
if (WMIsPLString(WMGetFromPLArray(array, i))) {
prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
} else {
wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
prefs->modifier_labels[i] = NULL;
}
}
WMReleasePropList(array);
return 0;
}
/*
* Very ugly kluge.
* Need access to the double click variables, so that all widgets in