diff options
| author | Josh Rahm <rahm@google.com> | 2022-04-01 16:49:07 -0600 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2022-04-01 16:49:07 -0600 |
| commit | c194a9be4e43bc4514070d172024fcf3354fb662 (patch) | |
| tree | dcccd5792feb7cff6c9781536205b59466cde434 /src/Internal/Submap.hs | |
| parent | 346c9b3da170cd51e5fd4e2bb19f7c1990243942 (diff) | |
| download | rde-c194a9be4e43bc4514070d172024fcf3354fb662.tar.gz rde-c194a9be4e43bc4514070d172024fcf3354fb662.tar.bz2 rde-c194a9be4e43bc4514070d172024fcf3354fb662.zip | |
More experimental MouseMotion
Diffstat (limited to 'src/Internal/Submap.hs')
| -rw-r--r-- | src/Internal/Submap.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Internal/Submap.hs b/src/Internal/Submap.hs index c51f9b6..32dda2a 100644 --- a/src/Internal/Submap.hs +++ b/src/Internal/Submap.hs @@ -3,6 +3,7 @@ module Internal.Submap ( submapButtonsWithKey, nextButton, nextMotion, + nextMotionOrButton, module X) where import XMonad hiding (keys) @@ -62,6 +63,24 @@ nextMotion = do return ret +nextMotionOrButton :: X (Either (Int, Int) (ButtonMask, Button)) +nextMotionOrButton = do + XConf { theRoot = root, display = d } <- ask + io $ grabPointer d root False (pointerMotionMask .|. buttonPressMask) grabModeAsync grabModeAsync 0 0 currentTime + + ret <- io $ allocaXEvent $ \xEv -> do + maskEvent d (pointerMotionMask .|. buttonPressMask) xEv + ev <- getEvent xEv + case ev of + MotionEvent { ev_x = x, ev_y = y } -> + return $ Left (fromIntegral x, fromIntegral y) + ButtonEvent { ev_button = button, ev_state = m } -> + return $ Right (m, button) + + io $ ungrabPointer d currentTime + + return ret + submapButtonsWithKey :: ((ButtonMask, Button) -> Window -> X ()) -> Map (ButtonMask, Button) (Window -> X ()) -> Window -> X () submapButtonsWithKey defaultAction actions window = do |