diff options
author | Devin Mullins <me@twifkak.com> | 2008-05-13 09:52:47 +0200 |
---|---|---|
committer | Devin Mullins <me@twifkak.com> | 2008-05-13 09:52:47 +0200 |
commit | 80b3682dfcfd51f43a3223e53dd0795684449085 (patch) | |
tree | 7ddb010582bab623224b6d6ed971db5150cadac8 | |
parent | 1c9ed9faac0040021ae78a14039891527989f48e (diff) | |
download | XMonadContrib-80b3682dfcfd51f43a3223e53dd0795684449085.tar.gz XMonadContrib-80b3682dfcfd51f43a3223e53dd0795684449085.tar.xz XMonadContrib-80b3682dfcfd51f43a3223e53dd0795684449085.zip |
pull suppressWhen logic into main WithUrgencyHook handler
In order for this to work, I added a new UrgencyHook method to communicate the
SuppressWhen value. I'm not sure if this is actually better than just providing
a convenience function, but it's an easy switch.
darcs-hash:20080513075247-78224-760cd588622855d35f7acaae1084396f38b7b634.gz
-rw-r--r-- | XMonad/Hooks/UrgencyHook.hs | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/XMonad/Hooks/UrgencyHook.hs b/XMonad/Hooks/UrgencyHook.hs index 5553381..bdb7c61 100644 --- a/XMonad/Hooks/UrgencyHook.hs +++ b/XMonad/Hooks/UrgencyHook.hs @@ -27,7 +27,7 @@ module XMonad.Hooks.UrgencyHook ( SpawnUrgencyHook(..), dzenUrgencyHook, DzenUrgencyHook(..), UrgencyHook(urgencyHook), - whenShouldTrigger, seconds, + seconds, SuppressWhen(..) ) where @@ -127,16 +127,14 @@ instance UrgencyHook h => EventHook (WithUrgencyHook h) where WMHints { wmh_flags = flags } <- io $ getWMHints dpy w if (testBit flags urgencyHintBit) then do -- Call the urgencyHook. - userCode $ urgencyHook hook w + callUrgencyHook hook w -- Add to list of urgents. adjustUrgents (\ws -> if elem w ws then ws else w : ws) - -- Call logHook after IORef has been modified. - userCode =<< asks (logHook . config) else do -- Remove from list of urgents. adjustUrgents (delete w) - -- Call logHook after IORef has been modified. - userCode =<< asks (logHook . config) + -- Call logHook after IORef has been modified. + userCode =<< asks (logHook . config) DestroyWindowEvent {ev_window = w} -> do adjustUrgents (delete w) _ -> @@ -149,12 +147,10 @@ urgencyLayoutHook :: (UrgencyHook h, LayoutClass l Window) => h -> l Window -> HandleEvent (WithUrgencyHook h) l Window urgencyLayoutHook hook = eventHook $ WithUrgencyHook hook --------------------------------------------------------------------------------- --- Urgency Hooks - --- | The class definition, and some pre-defined instances. - --- TODO: factor SuppressWhen stuff into WithUrgencyHook +callUrgencyHook :: UrgencyHook h => h -> Window -> X () +callUrgencyHook hook w = + whenX (not `fmap` shouldSuppress (suppressWhenSetting hook) w) + (userCode $ urgencyHook hook w) data SuppressWhen = Visible | OnScreen | Focused | Never deriving (Read, Show) @@ -164,13 +160,17 @@ shouldSuppress OnScreen w = gets $ elem w . W.index . windowset shouldSuppress Focused w = gets $ maybe False (w ==) . W.peek . windowset shouldSuppress Never _ = return False --- | Convenience method for those writing UrgencyHooks. -whenShouldTrigger :: SuppressWhen -> Window -> X () -> X () -whenShouldTrigger sw w = whenX (not `fmap` shouldSuppress sw w) +-------------------------------------------------------------------------------- +-- Urgency Hooks + +-- | The class definition, and some pre-defined instances. class (Read h, Show h) => UrgencyHook h where urgencyHook :: h -> Window -> X () + suppressWhenSetting :: h -> SuppressWhen + suppressWhenSetting _ = Visible + data NoUrgencyHook = NoUrgencyHook deriving (Read, Show) instance UrgencyHook NoUrgencyHook where @@ -182,14 +182,15 @@ data DzenUrgencyHook = DzenUrgencyHook { duration :: Int, deriving (Read, Show) instance UrgencyHook DzenUrgencyHook where - urgencyHook DzenUrgencyHook { duration = d, args = a, suppressWhen = sw } w = do + urgencyHook DzenUrgencyHook { duration = d, args = a } w = do name <- getName w ws <- gets windowset whenJust (W.findTag w ws) (flash name) where flash name index = - whenShouldTrigger sw w $ dzenWithArgs (show name ++ " requests your attention on workspace " ++ index) a d + suppressWhenSetting = suppressWhen + -- | Flashes when a window requests your attention and you can't see it. Configurable -- duration and args to dzen, and when to suppress the urgency flash. dzenUrgencyHook :: DzenUrgencyHook |