diff options
author | Tomas Janousek <tomi@nomi.cz> | 2011-06-15 17:03:33 +0200 |
---|---|---|
committer | Tomas Janousek <tomi@nomi.cz> | 2011-06-15 17:03:33 +0200 |
commit | 08ba531488beb0cbca824dfa8cac225226e6a81b (patch) | |
tree | 68b522082ddffb83c3b7d63041e57d2ff7926c19 /XMonad | |
parent | 268b1a4fe9cea1ab6bb0aead945abeffcb6ebf82 (diff) | |
download | XMonadContrib-08ba531488beb0cbca824dfa8cac225226e6a81b.tar.gz XMonadContrib-08ba531488beb0cbca824dfa8cac225226e6a81b.tar.xz XMonadContrib-08ba531488beb0cbca824dfa8cac225226e6a81b.zip |
X.L.LayoutHints: refresh only if hints are not satisfied
Ignore-this: e081f5fbd6a721e260212548d830ff6b
darcs-hash:20110615150333-c9ff5-c0a9b5307c5309778e21ae7aeca89a9946647242.gz
Diffstat (limited to '')
-rw-r--r-- | XMonad/Layout/LayoutHints.hs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/XMonad/Layout/LayoutHints.hs b/XMonad/Layout/LayoutHints.hs index 94dadd1..cf15295 100644 --- a/XMonad/Layout/LayoutHints.hs +++ b/XMonad/Layout/LayoutHints.hs @@ -25,7 +25,9 @@ module XMonad.Layout.LayoutHints import XMonad(LayoutClass(runLayout), mkAdjust, Window, Dimension, Position, Rectangle(Rectangle), D, - X, refresh, Event(..), propertyNotify, wM_NORMAL_HINTS) + X, refresh, Event(..), propertyNotify, wM_NORMAL_HINTS, + (<&&>), io, applySizeHints, whenX, isClient, withDisplay, + getWindowAttributes, getWMNormalHints, WindowAttributes(..)) import qualified XMonad.StackSet as W import XMonad.Layout.Decoration(isInStack) @@ -249,8 +251,16 @@ centerPlacement' cf root assigned -- | Event hook that refreshes the layout whenever a window changes its hints. hintsEventHook :: Event -> X All -hintsEventHook (PropertyEvent { ev_event_type = t, ev_atom = a }) +hintsEventHook (PropertyEvent { ev_event_type = t, ev_atom = a, ev_window = w }) | t == propertyNotify && a == wM_NORMAL_HINTS = do - refresh + whenX (isClient w <&&> hintsMismatch w) $ refresh return (All True) hintsEventHook _ = return (All True) + +-- | True if the window's current size does not satisfy its size hints. +hintsMismatch :: Window -> X Bool +hintsMismatch w = withDisplay $ \d -> io $ do + wa <- getWindowAttributes d w + sh <- getWMNormalHints d w + let dim = (fromIntegral $ wa_width wa, fromIntegral $ wa_height wa) + return $ dim /= applySizeHints 0 sh dim |