aboutsummaryrefslogtreecommitdiffstats
path: root/ConstrainedResize.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
commit4866f2e367dfcf22a9591231ba40948826a1b438 (patch)
tree7a245caee3f146826b267d773b7eaa80386a818e /ConstrainedResize.hs
parent47589e1913fb9530481caedb543978a30d4323ea (diff)
downloadXMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.gz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.xz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.zip
Hierarchify
darcs-hash:20071101201059-a5988-fc1f1262bec1b69e13ba18ae7cefeafc8c4471d4.gz
Diffstat (limited to 'ConstrainedResize.hs')
-rw-r--r--ConstrainedResize.hs58
1 files changed, 0 insertions, 58 deletions
diff --git a/ConstrainedResize.hs b/ConstrainedResize.hs
deleted file mode 100644
index 5e54861..0000000
--- a/ConstrainedResize.hs
+++ /dev/null
@@ -1,58 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : XMonadContrib.ConstrainedResize
--- Copyright : (c) Dougal Stanton
--- License : BSD3-style (see LICENSE)
---
--- Maintainer : <dougal@dougalstanton.net>
--- Stability : unstable
--- Portability : unportable
---
--- Lets you constrain the aspect ratio of a floating
--- window by holding shift while you resize.
---
--- Useful for making a nice circular XClock window.
---
------------------------------------------------------------------------------
-
-module XMonadContrib.ConstrainedResize (
- -- * Usage
- -- $usage
- XMonadContrib.ConstrainedResize.mouseResizeWindow
-) where
-
-import XMonad
-import XMonad.Operations
-import Graphics.X11.Xlib
-import Graphics.X11.Xlib.Extras
-
--- $usage
--- Put something like this in your Config.hs file:
---
--- > import qualified XMonadContrib.ConstrainedResize as Sqr
--- > mouseBindings = M.fromList
--- > [ ...
--- > , ((modMask, button3), (\w -> focus w >> Sqr.mouseResizeWindow w False))
--- > , ((modMask .|. shiftMask, button3), (\w -> focus w >> Sqr.mouseResizeWindow w True )) ]
---
--- The line without the shiftMask replaces the standard mouse resize function call, so it's
--- not completely necessary but seems neater this way.
-
--- %import qualified XMonadContrib.ConstrainedResize as Sqr
--- %mousebind , ((modMask, button3), (\\w -> focus w >> Sqr.mouseResizeWindow w False))
--- %mousebind , ((modMask .|. shiftMask, button3), (\\w -> focus w >> Sqr.mouseResizeWindow w True))
-
--- | Resize (floating) window with optional aspect ratio constraints.
-mouseResizeWindow :: Window -> Bool -> X ()
-mouseResizeWindow w c = whenX (isClient w) $ withDisplay $ \d -> do
- io $ raiseWindow d w
- wa <- io $ getWindowAttributes d w
- sh <- io $ getWMNormalHints d w
- io $ warpPointer d none w 0 0 0 0 (fromIntegral (wa_width wa)) (fromIntegral (wa_height wa))
- mouseDrag (\ex ey -> do
- let x = ex - fromIntegral (wa_x wa)
- y = ey - fromIntegral (wa_y wa)
- sz = if c then (max x y, max x y) else (x,y)
- io $ resizeWindow d w `uncurry`
- applySizeHints sh sz)
- (float w)