mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
Added GetShortcutKey().
The function getShortcutString() was defined statically in winmenu.c. Replace it with the new function GetShortcutKey() which calls the existing function GetShortcutString() so it can be used elsewhere and cut down on code duplication. A result of this change is that shortcuts are now labelled consistently. Previously the format was different in generated menus, which used, for example, M1 to refer to Mod1 whereas window menus used the full string Mod1. Now both use the shorter form. One could argue that the new function name is more consistent, as now GetShortcutString() takes a char * argument and GetShortcutKey() takes a WShortcutKey argument. That argument assumes that the original intention behind the name of GetShortcutString() was not to hint that it returns a String...
This commit is contained in:
committed by
Carlos R. Mafra
parent
0da2b6e928
commit
cd5382cedf
21
src/misc.c
21
src/misc.c
@@ -33,6 +33,8 @@
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
#include <WINGs/WUtil.h>
|
||||
#include <wraster.h>
|
||||
|
||||
@@ -771,6 +773,25 @@ char *GetShortcutString(char *text)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char *GetShortcutKey(WShortKey key)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
char *k = XKeysymToString(XkbKeycodeToKeysym(dpy, key.keycode, 0, 0));
|
||||
if (!k) return NULL;
|
||||
|
||||
char **m = wPreferences.modifier_labels;
|
||||
if (key.modifier & ControlMask) tmp = wstrappend(tmp, m[1] ? m[1] : "Ctrl+");
|
||||
if (key.modifier & ShiftMask) tmp = wstrappend(tmp, m[0] ? m[0] : "Shift+");
|
||||
if (key.modifier & Mod1Mask) tmp = wstrappend(tmp, m[2] ? m[2] : "Mod1+");
|
||||
if (key.modifier & Mod2Mask) tmp = wstrappend(tmp, m[3] ? m[3] : "Mod2+");
|
||||
if (key.modifier & Mod3Mask) tmp = wstrappend(tmp, m[4] ? m[4] : "Mod3+");
|
||||
if (key.modifier & Mod4Mask) tmp = wstrappend(tmp, m[5] ? m[5] : "Mod4+");
|
||||
if (key.modifier & Mod5Mask) tmp = wstrappend(tmp, m[6] ? m[6] : "Mod5+");
|
||||
tmp = wstrappend(tmp, k);
|
||||
|
||||
return GetShortcutString(tmp);
|
||||
}
|
||||
|
||||
char *EscapeWM_CLASS(char *name, char *class)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
Reference in New Issue
Block a user