diff options
author | Tomas Janousek <tomi@nomi.cz> | 2010-07-06 20:59:25 +0200 |
---|---|---|
committer | Tomas Janousek <tomi@nomi.cz> | 2010-07-06 20:59:25 +0200 |
commit | f75fb2b65f735ecd26597fba210ea76a2b510bcb (patch) | |
tree | 881e5659713d89605815cb796d9d0556a473706b | |
parent | d72088aae409cd15658088a74efa818787f014e6 (diff) | |
download | XMonadContrib-f75fb2b65f735ecd26597fba210ea76a2b510bcb.tar.gz XMonadContrib-f75fb2b65f735ecd26597fba210ea76a2b510bcb.tar.xz XMonadContrib-f75fb2b65f735ecd26597fba210ea76a2b510bcb.zip |
X.L.LayoutHints: event hook to refresh on hints change
Ignore-this: 54eba739c76db176cbb4ef66e30c201f
darcs-hash:20100706185925-c9ff5-2aa842bb1f8f3a67cff43670c20db9a7f0438720.gz
-rw-r--r-- | XMonad/Layout/LayoutHints.hs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/XMonad/Layout/LayoutHints.hs b/XMonad/Layout/LayoutHints.hs index ee3de7f..94dadd1 100644 --- a/XMonad/Layout/LayoutHints.hs +++ b/XMonad/Layout/LayoutHints.hs @@ -20,10 +20,12 @@ module XMonad.Layout.LayoutHints , layoutHintsWithPlacement , layoutHintsToCenter , LayoutHints + , hintsEventHook ) where import XMonad(LayoutClass(runLayout), mkAdjust, Window, - Dimension, Position, Rectangle(Rectangle),D) + Dimension, Position, Rectangle(Rectangle), D, + X, refresh, Event(..), propertyNotify, wM_NORMAL_HINTS) import qualified XMonad.StackSet as W import XMonad.Layout.Decoration(isInStack) @@ -35,6 +37,7 @@ import Control.Arrow(Arrow((***), first, second)) import Control.Monad(join) import Data.Function(on) import Data.List(sortBy) +import Data.Monoid(All(..)) import Data.Set (Set) import qualified Data.Set as Set @@ -62,6 +65,14 @@ import qualified Data.Set as Set -- For more detailed instructions on editing the layoutHook see: -- -- "XMonad.Doc.Extending#Editing_the_layout_hook" +-- +-- To make XMonad reflect changes in window hints immediately, add +-- 'hintsEventHook' to your 'handleEventHook'. +-- +-- > myHandleEventHook = hintsEventHook <+> ... +-- > +-- > main = xmonad defaultConfig { handleEventHook = myHandleEventHook +-- > , ... } layoutHints :: (LayoutClass l a) => l a -> ModifiedLayout LayoutHints l a layoutHints = ModifiedLayout (LayoutHints (0, 0)) @@ -235,3 +246,11 @@ centerPlacement' cf root assigned = (cf $ cx - cwx, cf $ cy - cwy) where (cx,cy) = center root (cwx,cwy) = center 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 }) + | t == propertyNotify && a == wM_NORMAL_HINTS = do + refresh + return (All True) +hintsEventHook _ = return (All True) |