aboutsummaryrefslogtreecommitdiffstats
path: root/LayoutHints.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-06-04 23:37:16 +0200
committerDavid Roundy <droundy@darcs.net>2007-06-04 23:37:16 +0200
commit67ee2708fb7c2687d1e34297b6bdc19ebf02e1ec (patch)
tree35f9caa81a3f6b8db0b5943e374d08ef2eb3bd00 /LayoutHints.hs
parent7f9bcc415f34b5b8da3ac5d836796de11b1f5564 (diff)
downloadXMonadContrib-67ee2708fb7c2687d1e34297b6bdc19ebf02e1ec.tar.gz
XMonadContrib-67ee2708fb7c2687d1e34297b6bdc19ebf02e1ec.tar.xz
XMonadContrib-67ee2708fb7c2687d1e34297b6bdc19ebf02e1ec.zip
add new LayoutHints module that makes layouts respect size hints.
darcs-hash:20070604213716-72aca-b09984b5ef776ec28fa5b0c077025cb1651d7276.gz
Diffstat (limited to 'LayoutHints.hs')
-rw-r--r--LayoutHints.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/LayoutHints.hs b/LayoutHints.hs
new file mode 100644
index 0000000..b24dc4a
--- /dev/null
+++ b/LayoutHints.hs
@@ -0,0 +1,21 @@
+module XMonadContrib.LayoutHints ( layoutHints ) where
+
+-- to use:
+-- defaultLayouts = [ layoutHints tiled, layoutHints $ mirror tiled , full ]
+
+import Operations ( applySizeHints )
+import Graphics.X11.Xlib
+import Graphics.X11.Xlib.Extras ( getWMNormalHints )
+import XMonad hiding ( trace )
+
+layoutHints :: Layout -> Layout
+layoutHints l = Layout { doLayout = \r x -> doLayout l r x >>= applyHints
+ , modifyLayout = \x -> layoutHints `fmap` modifyLayout l x }
+
+applyHints :: [(Window, Rectangle)] -> X [(Window, Rectangle)]
+applyHints xs = mapM applyHint xs
+ where applyHint (w,Rectangle a b c d) =
+ withDisplay $ \disp ->
+ do sh <- io $ getWMNormalHints disp w
+ let (c',d') = applySizeHints sh (c,d)
+ return (w, Rectangle a b c' d')