From 72564ceef760692469dd90b8f41df49fd2511934 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Fri, 18 Jan 2013 23:54:46 +0100 Subject: 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 --- XMonad/Main.hsc | 15 ++++++++++----- 1 file 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 () -- cgit v1.2.3