avoid grabbing all keys when a keysym is undefined

XKeysymToKeycode() returns zero if the keysym is undefined. Zero also happens
to be the value of AnyKey.
This commit is contained in:
Jason Creighton
2007-04-28 18:00:46 +00:00
parent 0dd75f9d68
commit 90b4eb607c

View File

@@ -94,7 +94,9 @@ grabKeys dpy rootw = do
ungrabKey dpy '\0' {-AnyKey-} anyModifier rootw
flip mapM_ (M.keys keys) $ \(mask,sym) -> do
kc <- keysymToKeycode dpy sym
mapM_ (grab kc) [mask, mask .|. numlockMask, mask .|. lockMask, mask .|. numlockMask .|. lockMask]
-- "If the specified KeySym is not defined for any KeyCode,
-- XKeysymToKeycode() returns zero."
when (kc /= '\0') $ mapM_ (grab kc . (mask .|.)) $ [0, numlockMask, lockMask, numlockMask .|. lockMask]
where
grab kc m = grabKey dpy kc m rootw True grabModeAsync grabModeAsync