summaryrefslogtreecommitdiffstats
path: root/source/x11-helper.c
diff options
context:
space:
mode:
authorDave Davenport <m.l.p.j.koedam@tue.nl>2015-07-29 09:37:40 +0200
committerDave Davenport <m.l.p.j.koedam@tue.nl>2015-07-29 09:37:40 +0200
commitc68ab67dd88c48d0f2b61a7aff606104a86e71ca (patch)
treee2c63317e739af12d70140f78747889584def74e /source/x11-helper.c
parent681bd5bcbb17a9a5309aea2060b04b2ee5859821 (diff)
Add some comments and cleanups, allow reeloading of keybindings at run-time
Diffstat (limited to 'source/x11-helper.c')
-rw-r--r--source/x11-helper.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source/x11-helper.c b/source/x11-helper.c
index dd43f7b7..2c574e3e 100644
--- a/source/x11-helper.c
+++ b/source/x11-helper.c
@@ -276,6 +276,21 @@ void x11_grab_key ( Display *display, unsigned int modmask, KeySym key )
}
}
+void x11_ungrab_key ( Display *display, unsigned int modmask, KeySym key )
+{
+ Screen *screen = DefaultScreenOfDisplay ( display );
+ Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) );
+ KeyCode keycode = XKeysymToKeycode ( display, key );
+
+ // unbind to combinations of mod and lock masks, so caps and numlock don't confuse people
+ XUngrabKey ( display, keycode, modmask, root );
+ XUngrabKey ( display, keycode, modmask | LockMask, root );
+
+ if ( NumlockMask ) {
+ XUngrabKey ( display, keycode, modmask | NumlockMask, root );
+ XUngrabKey ( display, keycode, modmask | NumlockMask | LockMask, root );
+ }
+}
/**
* @param display The connection to the X server.
*
@@ -345,8 +360,8 @@ void x11_parse_key ( char *combo, unsigned int *mod, KeySym *key )
KeySym sym = XStringToKeysym ( combo + i );
if ( sym == NoSymbol || ( !modmask && ( strchr ( combo, '-' ) || strchr ( combo, '+' ) ) ) ) {
+ // TODO popup
fprintf ( stderr, "sorry, cannot understand key combination: %s\n", combo );
- exit ( EXIT_FAILURE );
}
*key = sym;