---
svkbd.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/svkbd.c b/svkbd.c
index 92ddf23..04b5cc8 100644
--- a/svkbd.c
+++ b/svkbd.c
_AT_@ -13,6 +13,7 @@
#include <X11/Xutil.h>
#include <X11/Xproto.h>
#include <X11/extensions/XTest.h>
+#include <X11/XKBlib.h>
/* macros */
#define MAX(a, b) ((a) > (b) ? (a) : (b))
_AT_@ -244,8 +245,16 @@ drawkey(Key *k) {
XRectangle r = { k->x, k->y, k->w, k->h};
const char *l;
ulong *col;
+ Bool pressed = k->pressed;
- if(k->pressed)
+ // For the caps lock key get the state to still show it as pressed
+ if (k->keysym == XK_Caps_Lock && !pressed)
+ {
+ unsigned int atom = XInternAtom(dpy, "Caps Lock", False);
+ XkbGetNamedIndicator(dpy, atom, NULL, &pressed, NULL, NULL);
+ }
+
+ if(pressed)
col = dc.press;
else if(k->highlighted)
col = dc.high;
_AT_@ -380,6 +389,18 @@ press(Key *k, KeySym mod) {
}
}
}
+ else if (k->keysym == XK_Caps_Lock)
+ {
+ // Special case for caps lock
+ // Unlike other modifier keys it's not meant to be held down
+ XTestFakeKeyEvent(dpy,
+ XKeysymToKeycode(dpy, k->keysym),
+ True, 0);
+ k->pressed = False;
+ XTestFakeKeyEvent(dpy,
+ XKeysymToKeycode(dpy, k->keysym),
+ False, 0);
+ }
drawkey(k);
}
--
1.9.1
Received on Tue May 23 2017 - 16:20:19 CEST
This archive was generated by hypermail 2.3.0 : Tue May 23 2017 - 16:48:16 CEST