aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/Submap.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-04-08 11:42:15 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:46 -0600
commit6678c04be3d2175714d200af506d0e3c7a2215c6 (patch)
treef0840718f005b43f7a5778c4c6093d3c016ad4cb /src/Internal/Submap.hs
parent31198b2e165f50aa48a99a6a181e68a0bd4ece34 (diff)
downloadrde-6678c04be3d2175714d200af506d0e3c7a2215c6.tar.gz
rde-6678c04be3d2175714d200af506d0e3c7a2215c6.tar.bz2
rde-6678c04be3d2175714d200af506d0e3c7a2215c6.zip
Add more bindings to the "g" command.
Diffstat (limited to 'src/Internal/Submap.hs')
-rw-r--r--src/Internal/Submap.hs27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/Internal/Submap.hs b/src/Internal/Submap.hs
index 32dda2a..0e54c43 100644
--- a/src/Internal/Submap.hs
+++ b/src/Internal/Submap.hs
@@ -1,5 +1,6 @@
module Internal.Submap (
mapNextString,
+ mapNextStringWithKeysym,
submapButtonsWithKey,
nextButton,
nextMotion,
@@ -13,15 +14,20 @@ import Data.Map (Map)
import XMonad.Actions.Submap as X
-{- Like submap fram XMonad.Actions.Submap, but sends the string from
- - XLookupString to the function rather than the KeySym.
+{-
+ - Like submap fram XMonad.Actions.Submap, but sends the string from
+ - XLookupString to the function along side the keysym.
+ -
+ - This function allows mappings where the mapped string might be important,
+ - but also allows submappings for keys that may not have a character associated
+ - with them (for example, the function keys).
-}
-mapNextString :: (KeyMask -> String -> X a) -> X a
-mapNextString fn = do
+mapNextStringWithKeysym :: (KeyMask -> KeySym -> String -> X a) -> X a
+mapNextStringWithKeysym fn = do
XConf { theRoot = root, display = d } <- ask
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
- (m, str) <- io $ allocaXEvent $ \p -> fix $ \nextkey -> do
+ (m, str, keysym) <- io $ allocaXEvent $ \p -> fix $ \nextkey -> do
maskEvent d keyPressMask p
KeyEvent { ev_keycode = code, ev_state = m } <- getEvent p
keysym <- keycodeToKeysym d code 0
@@ -29,12 +35,17 @@ mapNextString fn = do
if isModifierKey keysym
then nextkey
- else return (m, str)
+ else return (m, str, keysym)
io $ ungrabKeyboard d currentTime
- fn m str
+ fn m keysym str
+{- Like submap, but on the character typed rather than the kysym. -}
+mapNextString :: (KeyMask -> String -> X a) -> X a
+mapNextString fn = mapNextStringWithKeysym (\m _ s -> fn m s)
+
+{- Grabs the mouse and returns the next button press. -}
nextButton :: X (ButtonMask, Button)
nextButton = do
XConf { theRoot = root, display = d } <- ask
@@ -49,6 +60,7 @@ nextButton = do
return ret
+{- Grabs the mouse and reports the next mouse motion. -}
nextMotion :: X (Int, Int)
nextMotion = do
XConf { theRoot = root, display = d } <- ask
@@ -63,6 +75,7 @@ nextMotion = do
return ret
+{- Grabs the mouse and reports the next mouse motion or button press. -}
nextMotionOrButton :: X (Either (Int, Int) (ButtonMask, Button))
nextMotionOrButton = do
XConf { theRoot = root, display = d } <- ask