summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-08-20 02:23:51 +0200
committerDavid Roundy <droundy@darcs.net>2007-08-20 02:23:51 +0200
commit05ae4c679e249fef3c4babf91c3aeaaa6c14023c (patch)
tree7a465ea2e51b7ebc9d4d5472e1b1c192d058840a
parent86b0e545ae54981bd3822282ad9f9dad70cde61e (diff)
downloadmetatile-05ae4c679e249fef3c4babf91c3aeaaa6c14023c.tar
metatile-05ae4c679e249fef3c4babf91c3aeaaa6c14023c.zip
clear out motion events when processing one motion event.
This is important if the hook is slow (e.g. try adding "float w" to the window-dragging hook), as it allows xmonad to keep up with the motion of the mouse. darcs-hash:20070820002351-72aca-f59cce28736104def77ae4c87da1c6832f092c16
-rw-r--r--Operations.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/Operations.hs b/Operations.hs
index 6e21120..5441476 100644
--- a/Operations.hs
+++ b/Operations.hs
@@ -184,7 +184,7 @@ windows f = do
-- given a position by a layout now.
mapM_ hide (nub oldvisible \\ visible)
- clearEnterEvents
+ clearEvents enterWindowMask
-- | setWMState. set the WM_STATE property
setWMState :: Window -> Int -> X ()
@@ -231,12 +231,12 @@ setInitialProperties w = withDisplay $ \d -> io $ do
refresh :: X ()
refresh = windows id
--- | clearEnterEvents. Remove all window entry events from the event queue.
-clearEnterEvents :: X ()
-clearEnterEvents = withDisplay $ \d -> io $ do
+-- | clearEvents. Remove all events of a given type from the event queue.
+clearEvents :: EventMask -> X ()
+clearEvents mask = withDisplay $ \d -> io $ do
sync d False
allocaXEvent $ \p -> fix $ \again -> do
- more <- checkMaskEvent d enterWindowMask p
+ more <- checkMaskEvent d mask p
when more again -- beautiful
-- | tileWindow. Moves and resizes w such that it fits inside the given
@@ -515,12 +515,15 @@ mouseDrag f done = do
XConf { theRoot = root, display = d } <- ask
io $ grabPointer d root False (buttonReleaseMask .|. pointerMotionMask)
grabModeAsync grabModeAsync none none currentTime
- modify $ \s -> s { dragging = Just (f, cleanup) }
+ modify $ \s -> s { dragging = Just (motion, cleanup) }
where
cleanup = do
withDisplay $ io . flip ungrabPointer currentTime
modify $ \s -> s { dragging = Nothing }
done
+ motion x y = do z <- f x y
+ clearEvents pointerMotionMask
+ return z
mouseMoveWindow :: Window -> X ()
mouseMoveWindow w = whenX (isClient w) $ withDisplay $ \d -> do