From ef3313d9b698172a8d81cea7b4fd74878c6b6709 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Tue, 27 Nov 2007 20:37:17 +0100 Subject: Warp: haddock updates darcs-hash:20071127193717-bd4d7-4dfd41ff076c194926210900f4b83dc3a01ccb3d.gz --- XMonad/Actions/Warp.hs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'XMonad/Actions') diff --git a/XMonad/Actions/Warp.hs b/XMonad/Actions/Warp.hs index bc7bacc..4f3bd5c 100644 --- a/XMonad/Actions/Warp.hs +++ b/XMonad/Actions/Warp.hs @@ -3,20 +3,19 @@ -- Module : XMonad.Actions.Warp -- Copyright : (c) daniel@wagner-home.com -- License : BSD3-style (see LICENSE) --- +-- -- Maintainer : daniel@wagner-home.com -- Stability : unstable -- Portability : unportable -- --- This can be used to make a keybinding that warps the pointer to a given --- window or screen. +-- Warp the pointer to a given window or screen. -- ----------------------------------------------------------------------------- module XMonad.Actions.Warp ( -- * Usage -- $usage - warpToScreen, + warpToScreen, warpToWindow ) where @@ -30,26 +29,24 @@ import XMonad import XMonad.StackSet as W {- $usage -This can be used to make a keybinding that warps the pointer to a given -window or screen. For example, I've added the following keybindings to -my Config.hs: +You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: + +> import XMonad.Actions.Warp + +then add appropriate keybindings to warp the pointer; for example: -> , ((modMask, xK_z ), warpToWindow (1%2) (1%2)) -- @@ Move pointer to currently focused window -> +> , ((modMask x, xK_z ), warpToWindow (1%2) (1%2)) -- @@ Move pointer to currently focused window +> >-- mod-ctrl-{w,e,r} @@ Move mouse pointer to screen 1, 2, or 3 -> -> [((modMask .|. controlMask, key), warpToScreen sc (1%2) (1%2)) +> +> [((modMask x .|. controlMask, key), warpToScreen sc (1%2) (1%2)) > | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]] Note that warping to a particular screen may change the focus. -} --- %import XMonad.Actions.Warp --- %keybind , ((modMask, xK_z ), warpToWindow (1%2) (1%2)) -- @@ Move pointer to currently focused window --- %keybindlist ++ --- %keybindlist -- mod-ctrl-{w,e,r} @@ Move mouse pointer to screen 1, 2, or 3 --- %keybindlist [((modMask .|. controlMask, key), warpToScreen sc (1%2) (1%2)) --- %keybindlist | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]] +-- For detailed instructions on editing your key bindings, see +-- "XMonad.Doc.Extending#Editing_key_bindings". fraction :: (Integral a, Integral b) => Rational -> a -> b fraction f x = floor (f * fromIntegral x) @@ -57,6 +54,8 @@ fraction f x = floor (f * fromIntegral x) warp :: Window -> Position -> Position -> X () warp w x y = withDisplay $ \d -> io $ warpPointer d none w 0 0 0 0 x y +-- | Warp the pointer to a given position relative to the currently +-- focused window. Top left = (0,0), bottom right = (1,1). warpToWindow :: Rational -> Rational -> X () warpToWindow h v = withDisplay $ \d -> @@ -64,6 +63,8 @@ warpToWindow h v = wa <- io $ getWindowAttributes d w warp w (fraction h (wa_width wa)) (fraction v (wa_height wa)) +-- | Warp the pointer to the given position (top left = (0,0), bottom +-- right = (1,1)) on the given screen. warpToScreen :: ScreenId -> Rational -> Rational -> X () warpToScreen n h v = do root <- asks theRoot -- cgit v1.2.3