summaryrefslogtreecommitdiffstats
path: root/Main.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-08-07 22:16:16 +0200
committerDavid Roundy <droundy@darcs.net>2007-08-07 22:16:16 +0200
commitba0bf3d271175ce396fb8fadad23e6d62cb8b942 (patch)
tree456042107b404faec9c0b5113d4ebb2f0ef8fdfa /Main.hs
parentd7a2bd0029f841061819cbc8f3a124b94cdfd002 (diff)
downloadmetatile-ba0bf3d271175ce396fb8fadad23e6d62cb8b942.tar
metatile-ba0bf3d271175ce396fb8fadad23e6d62cb8b942.zip
move event loop out of mouseDrag.
darcs-hash:20070807201616-72aca-80f5d15118592f79aca8a2e928c4ad4f29fdf8b1
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs19
1 files changed, 18 insertions, 1 deletions
diff --git a/Main.hs b/Main.hs
index efa7ab1..fc12bce 100644
--- a/Main.hs
+++ b/Main.hs
@@ -65,7 +65,8 @@ main = do
{ windowset = winset
, layouts = M.fromList [(w, safeLayouts) | w <- [0 .. W workspaces - 1]]
, mapped = S.empty
- , waitingUnmap = M.empty }
+ , waitingUnmap = M.empty
+ , dragging = Nothing }
xSetErrorHandler -- in C, I'm too lazy to write the binding: dons
@@ -183,6 +184,22 @@ handle e@(MappingNotifyEvent {ev_window = w}) = do
io $ refreshKeyboardMapping e
when (ev_request e == mappingKeyboard) $ withDisplay $ io . flip grabKeys w
+-- handle button release, which may finish dragging.
+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
+
+-- 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
+
-- click on an unfocused window, makes it focused on this workspace
handle e@(ButtonEvent {ev_window = w,ev_event_type = t,ev_button = b })
| t == buttonPress = do