From b23b66f8544e641f26809613aac1cfdf33abe16f Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Mon, 12 May 2008 06:18:52 +0200 Subject: UrgencyHook: extract whenNotVisible darcs-hash:20080512041852-78224-4d0176999f15eeed84428ad20fec485c0af7d114.gz --- XMonad/Hooks/UrgencyHook.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'XMonad/Hooks') diff --git a/XMonad/Hooks/UrgencyHook.hs b/XMonad/Hooks/UrgencyHook.hs index 1b895aa..26ea1dd 100644 --- a/XMonad/Hooks/UrgencyHook.hs +++ b/XMonad/Hooks/UrgencyHook.hs @@ -27,7 +27,7 @@ module XMonad.Hooks.UrgencyHook ( SpawnUrgencyHook(..), dzenUrgencyHook, DzenUrgencyHook(..), UrgencyHook(urgencyHook), - seconds + whenNotVisible, seconds ) where import XMonad @@ -153,6 +153,12 @@ urgencyLayoutHook hook = eventHook $ WithUrgencyHook hook -- | The class definition, and some pre-defined instances. +-- | Convenience method for those writing UrgencyHooks. +whenNotVisible :: Window -> X () -> X () +whenNotVisible w act = do + visibles <- gets mapped + when (not $ S.member w visibles) act + class (Read h, Show h) => UrgencyHook h where urgencyHook :: h -> Window -> X () @@ -166,12 +172,11 @@ data DzenUrgencyHook = DzenUrgencyHook { duration :: Int, args :: [String] } instance UrgencyHook DzenUrgencyHook where urgencyHook DzenUrgencyHook { duration = d, args = a } w = do - visibles <- gets mapped name <- getName w ws <- gets windowset - whenJust (W.findTag w ws) (flash name visibles) - where flash name visibles index = - when (not $ S.member w visibles) $ + whenJust (W.findTag w ws) (flash name) + where flash name index = + whenNotVisible w $ dzenWithArgs (show name ++ " requests your attention on workspace " ++ index) a d -- | Flashes when a window requests your attention and you can't see it. Configurable -- cgit v1.2.3