diff options
author | Don Stewart <dons@cse.unsw.edu.au> | 2007-05-31 10:53:08 +0200 |
---|---|---|
committer | Don Stewart <dons@cse.unsw.edu.au> | 2007-05-31 10:53:08 +0200 |
commit | 101004dd9f0526d12398e42d26b8d6bc5a57812b (patch) | |
tree | 13d75cb23a8fd544bb794c52fcfa6f3a89f121e9 /Main.hs | |
parent | 3de7f66af861fe0842fdcea4a36a7ce379b8ef8c (diff) | |
download | metatile-101004dd9f0526d12398e42d26b8d6bc5a57812b.tar metatile-101004dd9f0526d12398e42d26b8d6bc5a57812b.zip |
clean up mouse code a bit
darcs-hash:20070531085308-9c5c1-73ed940708aa9a369b0345c0d2b2a4708a231e67
Diffstat (limited to 'Main.hs')
-rw-r--r-- | Main.hs | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -26,7 +26,7 @@ import Graphics.X11.Xinerama (getScreenInfo) import XMonad import Config import StackSet (new) -import Operations (manage, unmanage, focus, setFocusX, full, isClient, rescreen, makeFloating, swapMaster) +import Operations -- -- The main entry point @@ -114,16 +114,19 @@ grabKeys dpy rootw = do cleanMask :: KeyMask -> KeyMask cleanMask = (complement (numlockMask .|. lockMask) .&.) +------------------------------------------------------------------------ +-- mouse handling + +-- | Accumulate mouse motion events mouseDrag :: (XMotionEvent -> IO ()) -> X () mouseDrag f = do XConf { theRoot = root, display = d } <- ask - io $ grabPointer d root False (buttonReleaseMask .|. pointerMotionMask) grabModeAsync grabModeAsync none none currentTime - - io $ allocaXEvent $ \p -> fix $ \again -> do + io $ grabPointer d root False (buttonReleaseMask .|. pointerMotionMask) + grabModeAsync grabModeAsync none none currentTime + io $ allocaXEvent $ \p -> fix $ \again -> do -- event loop maskEvent d (buttonReleaseMask .|. pointerMotionMask) p et <- get_EventType p when (et == motionNotify) $ get_MotionEvent p >>= f >> again - io $ ungrabPointer d currentTime mouseMoveWindow :: Window -> X () @@ -132,19 +135,20 @@ mouseMoveWindow w = withDisplay $ \d -> do wa <- io $ getWindowAttributes d w (_, _, _, ox, oy, _, _, _) <- io $ queryPointer d w mouseDrag $ \(_, _, _, ex, ey, _, _, _, _, _) -> - moveWindow d w (fromIntegral (fromIntegral (wa_x wa) + (ex - ox))) (fromIntegral (fromIntegral (wa_y wa) + (ey - oy))) - - makeFloating w + moveWindow d w (fromIntegral (fromIntegral (wa_x wa) + (ex - ox))) + (fromIntegral (fromIntegral (wa_y wa) + (ey - oy))) + float w mouseResizeWindow :: Window -> X () mouseResizeWindow w = withDisplay $ \d -> do io $ raiseWindow d w wa <- io $ getWindowAttributes d w - io $ warpPointer d none w 0 0 0 0 (fromIntegral (wa_width wa)) (fromIntegral (wa_height wa)) + io $ warpPointer d none w 0 0 0 0 (fromIntegral (wa_width wa)) + (fromIntegral (wa_height wa)) mouseDrag $ \(_, _, _, ex, ey, _, _, _, _, _) -> - resizeWindow d w (fromIntegral (max 1 (ex - fromIntegral (wa_x wa)))) (fromIntegral (max 1 (ey - fromIntegral (wa_y wa)))) - - makeFloating w + resizeWindow d w (fromIntegral (max 1 (ex - fromIntegral (wa_x wa)))) + (fromIntegral (max 1 (ey - fromIntegral (wa_y wa)))) + float w -- --------------------------------------------------------------------- -- | Event handler. Map X events onto calls into Operations.hs, which |