aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorLukas Mai <l.mai@web.de>2008-04-04 23:56:15 +0200
committerLukas Mai <l.mai@web.de>2008-04-04 23:56:15 +0200
commitdeb8d4b5822ebb90ff57abb63669603cfab609ed (patch)
tree7a1bd1a617d2192c7d47d79baaa26911ba53773f /XMonad
parent963bccac78b54134f57e17a495157ac8b254a41a (diff)
downloadxmonad-deb8d4b5822ebb90ff57abb63669603cfab609ed.tar.gz
xmonad-deb8d4b5822ebb90ff57abb63669603cfab609ed.tar.xz
xmonad-deb8d4b5822ebb90ff57abb63669603cfab609ed.zip
XMonad.Operations: applySizeHint reshuffle
Make applySizeHints take window borders into account. Move old functionality to applySizeHintsContents. Add new mkAdjust function that generates a custom autohinter for a window. darcs-hash:20080404215615-462cf-e6c1373d13ec4c6b0d675778125c75d76fbc896f.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Operations.hs26
1 files changed, 21 insertions, 5 deletions
diff --git a/XMonad/Operations.hs b/XMonad/Operations.hs
index 7daf309..74505c3 100644
--- a/XMonad/Operations.hs
+++ b/XMonad/Operations.hs
@@ -479,8 +479,8 @@ mouseResizeWindow w = whenX (isClient w) $ withDisplay $ \d -> do
io $ warpPointer d none w 0 0 0 0 (fromIntegral (wa_width wa)) (fromIntegral (wa_height wa))
mouseDrag (\ex ey -> do
io $ resizeWindow d w `uncurry`
- applySizeHints sh (ex - fromIntegral (wa_x wa),
- ey - fromIntegral (wa_y wa)))
+ applySizeHintsContents sh (ex - fromIntegral (wa_x wa),
+ ey - fromIntegral (wa_y wa)))
(float w)
-- ---------------------------------------------------------------------
@@ -488,10 +488,26 @@ mouseResizeWindow w = whenX (isClient w) $ withDisplay $ \d -> do
type D = (Dimension, Dimension)
+-- | Given a window, build an adjuster function that will reduce the given
+-- dimensions according to the window's border width and size hints.
+mkAdjust :: Window -> X (D -> D)
+mkAdjust w = withDisplay $ \d -> liftIO $ do
+ sh <- getWMNormalHints d w
+ bw <- fmap (fromIntegral . wa_border_width) $ getWindowAttributes d w
+ return $ applySizeHints bw sh
+
+-- | Reduce the dimensions if needed to comply to the given SizeHints, taking
+-- window borders into account.
+applySizeHints :: Integral a => Dimension -> SizeHints -> (a, a) -> D
+applySizeHints bw sh =
+ tmap (+ 2 * bw) . applySizeHintsContents sh . tmap (subtract $ 2 * fromIntegral bw)
+ where
+ tmap f (x, y) = (f x, f y)
+
-- | Reduce the dimensions if needed to comply to the given SizeHints.
-applySizeHints :: Integral a => SizeHints -> (a,a) -> D
-applySizeHints sh (w,h) = applySizeHints' sh (fromIntegral $ max 1 w,
- fromIntegral $ max 1 h)
+applySizeHintsContents :: Integral a => SizeHints -> (a, a) -> D
+applySizeHintsContents sh (w, h) =
+ applySizeHints' sh (fromIntegral $ max 1 w, fromIntegral $ max 1 h)
-- | XXX comment me
applySizeHints' :: SizeHints -> D -> D