diff options
author | Daniel Wagner <daniel@wagner-home.com> | 2013-01-18 23:54:46 +0100 |
---|---|---|
committer | Daniel Wagner <daniel@wagner-home.com> | 2013-01-18 23:54:46 +0100 |
commit | 8085d99c2c81d4b6d65dbcf7f85e9d57fb95643e (patch) | |
tree | b5871a84ab009d563235a18a14c7b2df49303cab | |
parent | 02d3e045d43d958007ddfeabfef6aaf7ce84598e (diff) | |
download | xmonad-8085d99c2c81d4b6d65dbcf7f85e9d57fb95643e.tar.gz xmonad-8085d99c2c81d4b6d65dbcf7f85e9d57fb95643e.tar.xz xmonad-8085d99c2c81d4b6d65dbcf7f85e9d57fb95643e.zip |
Grab all keycodes linked to each keysym, not just one
Ignore-this: 1a6c001560f68f99d75d5f550e7e83
This patch is based heavily on the one contributed by
svein.ove@aas.no, but updated to avoid causing a conflict and to work
with the newest X11 bindings. The name of the patch (and comment
below) are copied verbatim from his patch.
XKeysymToKeycode only gives the first code bound to a given symbol. To
handle the case where multiple keys are bound to the same symbol,
XKeycodeToKeysym is used instead, searching through all possible
keycodes for each sym.
darcs-hash:20130118225446-76d51-ae01f4eb151409ff1b9c57e93d26f1d75cc8aac6.gz
-rw-r--r-- | XMonad/Main.hsc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/XMonad/Main.hsc b/XMonad/Main.hsc index c459f14..0176187 100644 --- a/XMonad/Main.hsc +++ b/XMonad/Main.hsc @@ -353,13 +353,18 @@ grabKeys :: X () grabKeys = do XConf { display = dpy, theRoot = rootw } <- ask let grab kc m = io $ grabKey dpy kc m rootw True grabModeAsync grabModeAsync + (minCode, maxCode) = displayKeycodes dpy + allCodes = [fromIntegral minCode .. fromIntegral maxCode] io $ ungrabKey dpy anyKey anyModifier rootw ks <- asks keyActions - forM_ (M.keys ks) $ \(mask,sym) -> do - kc <- io $ keysymToKeycode dpy sym - -- "If the specified KeySym is not defined for any KeyCode, - -- XKeysymToKeycode() returns zero." - when (kc /= 0) $ mapM_ (grab kc . (mask .|.)) =<< extraModifiers + -- build a map from keysyms to lists of keysyms (doing what + -- XGetKeyboardMapping would do if the X11 package bound it) + syms <- forM allCodes $ \code -> io (keycodeToKeysym dpy code 0) + let keysymMap = M.fromListWith (++) (zip syms [[code] | code <- allCodes]) + keysymToKeycodes sym = M.findWithDefault [] sym keysymMap + forM_ (M.keys ks) $ \(mask,sym) -> + forM_ (keysymToKeycodes sym) $ \kc -> + mapM_ (grab kc . (mask .|.)) =<< extraModifiers -- | XXX comment me grabButtons :: X () |