mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-03 13:41:54 -07:00
Grab all keycodes linked to each keysym, not just one
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.
This commit is contained in:
@@ -353,13 +353,18 @@ grabKeys :: X ()
|
|||||||
grabKeys = do
|
grabKeys = do
|
||||||
XConf { display = dpy, theRoot = rootw } <- ask
|
XConf { display = dpy, theRoot = rootw } <- ask
|
||||||
let grab kc m = io $ grabKey dpy kc m rootw True grabModeAsync grabModeAsync
|
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
|
io $ ungrabKey dpy anyKey anyModifier rootw
|
||||||
ks <- asks keyActions
|
ks <- asks keyActions
|
||||||
forM_ (M.keys ks) $ \(mask,sym) -> do
|
-- build a map from keysyms to lists of keysyms (doing what
|
||||||
kc <- io $ keysymToKeycode dpy sym
|
-- XGetKeyboardMapping would do if the X11 package bound it)
|
||||||
-- "If the specified KeySym is not defined for any KeyCode,
|
syms <- forM allCodes $ \code -> io (keycodeToKeysym dpy code 0)
|
||||||
-- XKeysymToKeycode() returns zero."
|
let keysymMap = M.fromListWith (++) (zip syms [[code] | code <- allCodes])
|
||||||
when (kc /= 0) $ mapM_ (grab kc . (mask .|.)) =<< extraModifiers
|
keysymToKeycodes sym = M.findWithDefault [] sym keysymMap
|
||||||
|
forM_ (M.keys ks) $ \(mask,sym) ->
|
||||||
|
forM_ (keysymToKeycodes sym) $ \kc ->
|
||||||
|
mapM_ (grab kc . (mask .|.)) =<< extraModifiers
|
||||||
|
|
||||||
-- | XXX comment me
|
-- | XXX comment me
|
||||||
grabButtons :: X ()
|
grabButtons :: X ()
|
||||||
|
Reference in New Issue
Block a user