From 08ba531488beb0cbca824dfa8cac225226e6a81b Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Wed, 15 Jun 2011 17:03:33 +0200 Subject: X.L.LayoutHints: refresh only if hints are not satisfied Ignore-this: e081f5fbd6a721e260212548d830ff6b darcs-hash:20110615150333-c9ff5-c0a9b5307c5309778e21ae7aeca89a9946647242.gz --- XMonad/Layout/LayoutHints.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'XMonad/Layout/LayoutHints.hs') 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 -- cgit v1.2.3