diff options
author | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-08-10 23:39:40 +0200 |
---|---|---|
committer | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-08-10 23:39:40 +0200 |
commit | 74be11b60da8ad9373d26fb2a669ba3c4852b6a7 (patch) | |
tree | 82c8db11853eb793f5a949750e18c9d73418f5b7 | |
parent | ba0bf3d271175ce396fb8fadad23e6d62cb8b942 (diff) | |
download | metatile-74be11b60da8ad9373d26fb2a669ba3c4852b6a7.tar metatile-74be11b60da8ad9373d26fb2a669ba3c4852b6a7.zip |
Cleanup
darcs-hash:20070810213940-a5988-7baa041cdf9a07038cb36645f314eb48bb8423aa
-rw-r--r-- | Main.hs | 10 | ||||
-rw-r--r-- | Operations.hs | 19 |
2 files changed, 16 insertions, 13 deletions
@@ -189,16 +189,16 @@ handle e@(ButtonEvent {ev_event_type = t}) | t == buttonRelease = do drag <- gets dragging case drag of - Just (_,f) -> modify (\s -> s { dragging = Nothing }) >> f - -- we're done dragging and have released the mouse - Nothing -> broadcastMessage e + -- we're done dragging and have released the mouse: + Just (_,f) -> modify (\s -> s { dragging = Nothing }) >> f + Nothing -> broadcastMessage e -- handle motionNotify event, which may mean we are dragging. handle e@(MotionEvent {ev_event_type = t, ev_x = x, ev_y = y}) = do drag <- gets dragging case drag of - Just (d,_) -> d (fromIntegral x) (fromIntegral y) -- we're dragging - Nothing -> broadcastMessage e + Just (d,_) -> d (fromIntegral x) (fromIntegral y) -- we're dragging + Nothing -> broadcastMessage e -- click on an unfocused window, makes it focused on this workspace handle e@(ButtonEvent {ev_window = w,ev_event_type = t,ev_button = b }) diff --git a/Operations.hs b/Operations.hs index c8a9d7a..3e2a561 100644 --- a/Operations.hs +++ b/Operations.hs @@ -511,14 +511,17 @@ mouseDrag :: (Position -> Position -> X ()) -> X () -> X () mouseDrag f done = do drag <- gets dragging case drag of - Just _ -> return () -- error case? we're already dragging - Nothing -> do XConf { theRoot = root, display = d } <- ask - io $ grabPointer d root False (buttonReleaseMask .|. pointerMotionMask) - grabModeAsync grabModeAsync none none currentTime - let cleanup = do io $ ungrabPointer d currentTime - modify $ \s -> s { dragging = Nothing } - done - modify $ \s -> s { dragging = Just (f, cleanup) } + Just _ -> return () -- error case? we're already dragging + Nothing -> 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) } + where + cleanup = do + withDisplay $ io . flip ungrabPointer currentTime + modify $ \s -> s { dragging = Nothing } + done mouseMoveWindow :: Window -> X () mouseMoveWindow w = whenX (isClient w) $ withDisplay $ \d -> do |