aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Actions/Warp.hs
diff options
context:
space:
mode:
authorgwern0 <gwern0@gmail.com>2008-06-29 22:20:47 +0200
committergwern0 <gwern0@gmail.com>2008-06-29 22:20:47 +0200
commit676468957bc88b7b2b5da64f4122bd8a3a1aee52 (patch)
treee2cc5ee2d6f3687a1485351f3fc174ebe7f8254d /XMonad/Actions/Warp.hs
parent54164f5158089d30a0ad367f529245879cd7f63a (diff)
downloadXMonadContrib-676468957bc88b7b2b5da64f4122bd8a3a1aee52.tar.gz
XMonadContrib-676468957bc88b7b2b5da64f4122bd8a3a1aee52.tar.xz
XMonadContrib-676468957bc88b7b2b5da64f4122bd8a3a1aee52.zip
fillout banish example in Warp.hs
We also include a nice little type to avoid specifying 0 0 stuff. darcs-hash:20080629202047-f7719-a47e44620d347c3c9dcff14a6ecbc5a48bae8a45.gz
Diffstat (limited to '')
-rw-r--r--XMonad/Actions/Warp.hs30
1 files changed, 22 insertions, 8 deletions
diff --git a/XMonad/Actions/Warp.hs b/XMonad/Actions/Warp.hs
index d943c5f..4298995 100644
--- a/XMonad/Actions/Warp.hs
+++ b/XMonad/Actions/Warp.hs
@@ -15,6 +15,8 @@
module XMonad.Actions.Warp (
-- * Usage
-- $usage
+ banish,
+ Corner(..),
warpToScreen,
warpToWindow
) where
@@ -39,19 +41,31 @@ then add appropriate keybindings to warp the pointer; for example:
> | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]]
Note that warping to a particular screen may change the focus.
-
-'warpToScreen' and 'warpToWindow' can be used in a variety of
-ways. Suppose you wanted to emulate Ratpoison's \'banish\' command,
-which moves the mouse pointer to a corner; you could define:
-
-> banish :: X ()
-> banish = warpToWindow 1 1 -- lower right
-
-}
-- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings".
+
+data Corner = UpperLeft | UpperRight | LowerLeft | LowerRight
+
+{- | Move the mouse cursor to a corner of the screen. Useful for
+ uncluttering things.
+
+ Internally, this uses numerical parameters. We parametrize on the 'Corner'
+ type so the user need not see the violence inherent in
+ the system.
+
+ 'warpToScreen' and 'warpToWindow' can be used in a variety of
+ ways. Suppose you wanted to emulate Ratpoison's \'banish\' command,
+ which moves the mouse pointer to a corner? warpToWindow can do that! -}
+banish :: Corner -> X ()
+banish direction = case direction of
+ LowerRight -> warpToWindow 1 1
+ LowerLeft -> warpToWindow 0 1
+ UpperLeft -> warpToWindow 0 0
+ UpperRight -> warpToWindow 1 0
+
fraction :: (Integral a, Integral b) => Rational -> a -> b
fraction f x = floor (f * fromIntegral x)