diff options
| author | Josh Rahm <rahm@google.com> | 2022-04-01 16:49:07 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:46 -0600 |
| commit | 255e93111fe464bb035bfe4fcc79311404746471 (patch) | |
| tree | dcccd5792feb7cff6c9781536205b59466cde434 /src/Internal/Submap.hs | |
| parent | edd905971d9f0b7b7b09d65fe8ee9cc8337f4172 (diff) | |
| download | rde-255e93111fe464bb035bfe4fcc79311404746471.tar.gz rde-255e93111fe464bb035bfe4fcc79311404746471.tar.bz2 rde-255e93111fe464bb035bfe4fcc79311404746471.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 |