summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wagner <daniel@wagner-home.com>2013-01-18 23:54:46 +0100
committerDaniel Wagner <daniel@wagner-home.com>2013-01-18 23:54:46 +0100
commit72564ceef760692469dd90b8f41df49fd2511934 (patch)
treeb5871a84ab009d563235a18a14c7b2df49303cab
parent5e6f0b439d474a72af6de3c69d4ddd95b7e6274d (diff)
downloadmetatile-72564ceef760692469dd90b8f41df49fd2511934.tar
metatile-72564ceef760692469dd90b8f41df49fd2511934.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
-rw-r--r--XMonad/Main.hsc15
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 ()