aboutsummaryrefslogtreecommitdiffstats
path: root/ManageDocks.hs
diff options
context:
space:
mode:
authormail <mail@joachim-breitner.de>2007-10-07 12:31:16 +0200
committermail <mail@joachim-breitner.de>2007-10-07 12:31:16 +0200
commit802450ed9fa6c5fd2e0a27f398cc01dcd5a1c864 (patch)
treec0f90c671e8d39d44e327c3d01574940c2834ff1 /ManageDocks.hs
parent5f6adec51d6c5c65b9f918f0882c57047080ee8f (diff)
downloadXMonadContrib-802450ed9fa6c5fd2e0a27f398cc01dcd5a1c864.tar.gz
XMonadContrib-802450ed9fa6c5fd2e0a27f398cc01dcd5a1c864.tar.xz
XMonadContrib-802450ed9fa6c5fd2e0a27f398cc01dcd5a1c864.zip
ManageDocks now handles STRUT windows as well
It now also detects window with STRUT set and modifies the gap accordingly. Cheveats: * Only acts on STRUT apps on creation, not if you move or close them * To reset the gap, press Mod-b twice and restart xmonad (Mod-q) darcs-hash:20071007103116-c9905-8582a9f756d9ef8a61c7f118d677159796b00c40.gz
Diffstat (limited to 'ManageDocks.hs')
-rw-r--r--ManageDocks.hs51
1 files changed, 46 insertions, 5 deletions
diff --git a/ManageDocks.hs b/ManageDocks.hs
index f487a60..2f702e8 100644
--- a/ManageDocks.hs
+++ b/ManageDocks.hs
@@ -9,7 +9,14 @@
-- Portability : unportable
--
-- Makes xmonad detect windows with type DOCK and does not put them in
--- layouts.
+-- layouts. It also detects window with STRUT set and modifies the
+-- gap accordingly.
+--
+-- Cheveats:
+--
+-- * Only acts on STRUT apps on creation, not if you move or close them
+--
+-- * To reset the gap, press Mod-b twice and restart xmonad (Mod-q)
-----------------------------------------------------------------------------
module XMonadContrib.ManageDocks (
-- * Usage
@@ -23,6 +30,7 @@ import Operations
import qualified StackSet as W
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Extras
+import Data.Word
-- $usage
-- Add the imports to your configuration file and add the mangeHook:
@@ -37,10 +45,13 @@ import Graphics.X11.Xlib.Extras
-- |
--- Deteckts if the given window is of type DOCK and if so, reveals it, but does
--- not manage it
+-- Detects if the given window is of type DOCK and if so, reveals it, but does
+-- not manage it. If the window has the STRUT property set, adjust the gap accordingly.
manageDocksHook :: Window -> X (WindowSet -> WindowSet)
manageDocksHook w = do
+ hasStrut <- getStrut w
+ maybe (return ()) setGap hasStrut
+
isDock <- checkDock w
if isDock then do
reveal w
@@ -48,12 +59,42 @@ manageDocksHook w = do
else do
return id
+-- |
+-- Checks if a window is a DOCK window
checkDock :: Window -> X (Bool)
checkDock w = do
a <- getAtom "_NET_WM_WINDOW_TYPE"
d <- getAtom "_NET_WM_WINDOW_TYPE_DOCK"
- mbr <- withDisplay $ \dpy -> do
- io $ getWindowProperty32 dpy a w
+ mbr <- getProp a w
case mbr of
Just [r] -> return (r == d)
_ -> return False
+
+-- |
+-- Gets the STRUT config, if present, in xmonad gap order
+getStrut :: Window -> X (Maybe (Int, Int, Int, Int))
+getStrut w = do
+ a <- getAtom "_NET_WM_STRUT"
+ mbr <- getProp a w
+ case mbr of
+ Just [l,r,t,b] -> return (Just (
+ fromIntegral t,
+ fromIntegral b,
+ fromIntegral l,
+ fromIntegral r))
+ _ -> return Nothing
+
+-- |
+-- Helper to read a property
+getProp :: Atom -> Window -> X (Maybe [Word32])
+getProp a w = withDisplay $ \dpy -> io $ getWindowProperty32 dpy a w
+
+-- |
+-- Modifies the gap, setting new max
+setGap :: (Int, Int, Int, Int) -> X ()
+setGap gap = modifyGap (\_ -> max4 gap)
+
+-- |
+-- Piecewise maximum of a 4-tuple of Ints
+max4 :: (Int, Int, Int, Int) -> (Int, Int, Int, Int) -> (Int, Int, Int, Int)
+max4 (a1,a2,a3,a4) (b1,b2,b3,b4) = (max a1 b1, max a2 b2, max a3 b3, max a4 b4)