aboutsummaryrefslogtreecommitdiff
path: root/src/Internal
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-03-25 15:55:54 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:45 -0600
commit897ec5a52d90378c3211490c03765a23863790c0 (patch)
tree065d941bcacd0e7b6999405d2e3908986c42b327 /src/Internal
parent4b33192b56ea0f84f97d47e7656c186ec6ab7a68 (diff)
downloadrde-897ec5a52d90378c3211490c03765a23863790c0.tar.gz
rde-897ec5a52d90378c3211490c03765a23863790c0.tar.bz2
rde-897ec5a52d90378c3211490c03765a23863790c0.zip
Another Chrome binding added.
There's a bug where it seems the mappings are applied inconsistently after a restart. Not sure what causes that. Seems bouncing XMonad again fixes it.
Diffstat (limited to 'src/Internal')
-rw-r--r--src/Internal/Intercept.hs17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/Internal/Intercept.hs b/src/Internal/Intercept.hs
index 987733b..c99ce09 100644
--- a/src/Internal/Intercept.hs
+++ b/src/Internal/Intercept.hs
@@ -1,3 +1,7 @@
+
+-- Module for intercepting key presses not explicity mapped in the key bindings.
+-- This uses some deep magic with grabKey and windows and everything else, but
+-- it makes window-specific key bindings awesome!
module Internal.Intercept where
import XMonad
@@ -111,19 +115,10 @@ getKeyCodesForKeysym dpy keysym = do
doGrab :: Display -> Window -> (KeyMask, KeySym) -> X ()
doGrab dpy win (keyMask, keysym) = do
let grab kc m = io $ grabKey dpy kc m win True grabModeAsync grabModeAsync
- (minCode, maxCode) = displayKeycodes dpy
- allCodes = [fromIntegral minCode .. fromIntegral maxCode]
- -- 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' = Map.fromListWith (++) (zip syms [[code] | code <- allCodes])
- -- keycodeToKeysym returns noSymbol for all unbound keycodes, and we don't
- -- want to grab those whenever someone accidentally uses def :: KeySym
- let keysymMap = Map.delete noSymbol keysymMap'
- let keysymToKeycodes sym = Map.findWithDefault [] keysym keysymMap
+ codes <- io $ getKeyCodesForKeysym dpy keysym
- forM_ (keysymToKeycodes keysym) $ \kc ->
+ forM_ codes $ \kc ->
mapM_ (grab kc . (keyMask .|.)) =<< extraModifiers
disableKey :: (KeyMask, KeySym) -> WindowHook