aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/Submap.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-03-18 17:47:40 -0600
committerJosh Rahm <rahm@google.com>2022-03-18 17:47:40 -0600
commita87cbc7357566b26c7dca7538d4b03da5f8b999a (patch)
treee39df6459a2bf7a42205e84d33fb6c114752803b /src/Internal/Submap.hs
parentb810758e6a418db3eb6c5d1ab504273f01b7b00d (diff)
downloadrde-a87cbc7357566b26c7dca7538d4b03da5f8b999a.tar.gz
rde-a87cbc7357566b26c7dca7538d4b03da5f8b999a.tar.bz2
rde-a87cbc7357566b26c7dca7538d4b03da5f8b999a.zip
Add experimental motion events. Not super useful at the moment, but might be in the future.
Diffstat (limited to 'src/Internal/Submap.hs')
-rw-r--r--src/Internal/Submap.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Internal/Submap.hs b/src/Internal/Submap.hs
index 40becdc..e5968ff 100644
--- a/src/Internal/Submap.hs
+++ b/src/Internal/Submap.hs
@@ -2,6 +2,7 @@ module Internal.Submap (
mapNextString,
submapButtonsWithKey,
nextButton,
+ nextMotion,
module X) where
import XMonad hiding (keys)
@@ -47,6 +48,20 @@ nextButton = do
return ret
+nextMotion :: X (Int, Int)
+nextMotion = do
+ XConf { theRoot = root, display = d } <- ask
+ io $ grabPointer d root False pointerMotionMask grabModeAsync grabModeAsync 0 0 currentTime
+
+ ret <- io $ allocaXEvent $ \xEv -> do
+ maskEvent d pointerMotionMask xEv
+ MotionEvent { ev_x = x, ev_y = y } <- getEvent xEv
+ return (fromIntegral x, fromIntegral y)
+
+ io $ ungrabPointer d currentTime
+
+ return ret
+
submapButtonsWithKey ::
((ButtonMask, Button) -> Window -> X ()) -> (Map (ButtonMask, Button) (Window -> X ())) -> Window -> X ()
submapButtonsWithKey defaultAction actions window = do