mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 04:31:52 -07:00
change withUrgencyHookC api
Now it takes an UrgencyConfig record type.
This commit is contained in:
@@ -52,7 +52,8 @@ module XMonad.Hooks.UrgencyHook (
|
|||||||
|
|
||||||
-- * Stuff for your config file:
|
-- * Stuff for your config file:
|
||||||
withUrgencyHook, withUrgencyHookC,
|
withUrgencyHook, withUrgencyHookC,
|
||||||
suppressWhen, SuppressWhen(..),
|
UrgencyConfig(..), urgencyConfig,
|
||||||
|
SuppressWhen(..),
|
||||||
focusUrgent,
|
focusUrgent,
|
||||||
dzenUrgencyHook,
|
dzenUrgencyHook,
|
||||||
DzenUrgencyHook(..), seconds,
|
DzenUrgencyHook(..), seconds,
|
||||||
@@ -194,31 +195,33 @@ import Foreign (unsafePerformIO)
|
|||||||
|
|
||||||
-- | This is the method to enable an urgency hook. It suppresses urgency status
|
-- | This is the method to enable an urgency hook. It suppresses urgency status
|
||||||
-- for windows that are currently visible. If you'd like to change that behavior,
|
-- for windows that are currently visible. If you'd like to change that behavior,
|
||||||
-- use withUrgencyHookC.
|
-- use 'withUrgencyHookC'.
|
||||||
withUrgencyHook :: (LayoutClass l Window, UrgencyHook h) =>
|
withUrgencyHook :: (LayoutClass l Window, UrgencyHook h) =>
|
||||||
h -> XConfig l -> XConfig (HandleEvent (WithUrgencyHook h) l)
|
h -> XConfig l -> XConfig (HandleEvent (WithUrgencyHook h) l)
|
||||||
withUrgencyHook hook conf = withUrgencyHookC hook id conf
|
withUrgencyHook hook conf = withUrgencyHookC hook urgencyConfig conf
|
||||||
|
|
||||||
-- | If you'd like to configure *when* to trigger the urgency hook, call this
|
-- | If you'd like to configure *when* to trigger the urgency hook, call this
|
||||||
-- function with an extra mutator function. Or, by example:
|
-- function with a custom 'UrgencyConfig'. Or, by example:
|
||||||
--
|
--
|
||||||
-- > withUrgencyHookC dzenUrgencyHook { ... } (suppressWhen Focused)
|
-- > withUrgencyHookC dzenUrgencyHook { ... } urgencyConfig { suppressWhen = Focused }
|
||||||
--
|
--
|
||||||
-- (Don't type the @...@, you dolt.) See documentation on your options at 'SuppressWhen'.
|
-- (Don't type the @...@, you dolt.) See documentation on your options at 'SuppressWhen'.
|
||||||
withUrgencyHookC :: (LayoutClass l Window, UrgencyHook h) =>
|
withUrgencyHookC :: (LayoutClass l Window, UrgencyHook h) =>
|
||||||
h -> (WithUrgencyHook h -> WithUrgencyHook h) -> XConfig l
|
h -> UrgencyConfig -> XConfig l -> XConfig (HandleEvent (WithUrgencyHook h) l)
|
||||||
-> XConfig (HandleEvent (WithUrgencyHook h) l)
|
withUrgencyHookC hook urgConf conf = conf {
|
||||||
withUrgencyHookC hook hookMod conf = conf {
|
layoutHook = eventHook (WithUrgencyHook hook urgConf) $ layoutHook conf,
|
||||||
layoutHook = eventHook withUrgency $ layoutHook conf,
|
logHook = cleanupUrgents (suppressWhen urgConf) >> logHook conf
|
||||||
logHook = cleanupUrgents sw >> logHook conf
|
|
||||||
}
|
}
|
||||||
where withUrgency@(WithUrgencyHook _ sw) = hookMod $ WithUrgencyHook hook Visible
|
|
||||||
|
|
||||||
-- | See 'withUrgencyHookC' for an example use. 'suppressWhen' is a global configuration
|
-- | Global configuration, applicable to all types of 'UrgencyHook'.
|
||||||
-- option, applicable to all urgency hooks, whereas the stuff inside the @{ ... }@ is
|
data UrgencyConfig = UrgencyConfig
|
||||||
-- type-specific.
|
{ suppressWhen :: SuppressWhen -- ^ see 'SuppressWhen' for options
|
||||||
suppressWhen :: UrgencyHook h => SuppressWhen -> WithUrgencyHook h -> WithUrgencyHook h
|
} deriving (Read, Show)
|
||||||
suppressWhen sw (WithUrgencyHook hook _) = WithUrgencyHook hook sw
|
|
||||||
|
-- | The default 'UrgencyConfig'. Use a variation of this in your config just
|
||||||
|
-- as you use a variation of defaultConfig for your xmonad definition.
|
||||||
|
urgencyConfig :: UrgencyConfig
|
||||||
|
urgencyConfig = UrgencyConfig { suppressWhen = Visible }
|
||||||
|
|
||||||
-- | A set of choices as to /when/ you should (or rather, shouldn't) be notified of an urgent window.
|
-- | A set of choices as to /when/ you should (or rather, shouldn't) be notified of an urgent window.
|
||||||
-- The default is 'Visible'. Prefix each of the following with \"don't bug me when\":
|
-- The default is 'Visible'. Prefix each of the following with \"don't bug me when\":
|
||||||
@@ -252,7 +255,7 @@ readUrgents = io $ readIORef urgents
|
|||||||
withUrgents :: ([Window] -> X a) -> X a
|
withUrgents :: ([Window] -> X a) -> X a
|
||||||
withUrgents f = readUrgents >>= f
|
withUrgents f = readUrgents >>= f
|
||||||
|
|
||||||
data WithUrgencyHook h = WithUrgencyHook h SuppressWhen deriving (Read, Show)
|
data WithUrgencyHook h = WithUrgencyHook h UrgencyConfig deriving (Read, Show)
|
||||||
|
|
||||||
-- The Non-ICCCM Manifesto:
|
-- The Non-ICCCM Manifesto:
|
||||||
-- Note: Some non-standard choices have been made in this implementation to
|
-- Note: Some non-standard choices have been made in this implementation to
|
||||||
@@ -291,7 +294,7 @@ adjustUrgents :: ([Window] -> [Window]) -> X ()
|
|||||||
adjustUrgents f = io $ modifyIORef urgents f
|
adjustUrgents f = io $ modifyIORef urgents f
|
||||||
|
|
||||||
callUrgencyHook :: UrgencyHook h => WithUrgencyHook h -> Window -> X ()
|
callUrgencyHook :: UrgencyHook h => WithUrgencyHook h -> Window -> X ()
|
||||||
callUrgencyHook (WithUrgencyHook hook sw) w =
|
callUrgencyHook (WithUrgencyHook hook UrgencyConfig { suppressWhen = sw }) w =
|
||||||
whenX (not <$> shouldSuppress sw w)
|
whenX (not <$> shouldSuppress sw w)
|
||||||
(userCode $ urgencyHook hook w)
|
(userCode $ urgencyHook hook w)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user