aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Hooks
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Hooks')
-rw-r--r--src/Rahm/Desktop/Hooks/WindowChange.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Rahm/Desktop/Hooks/WindowChange.hs b/src/Rahm/Desktop/Hooks/WindowChange.hs
index 32c854b..0902f53 100644
--- a/src/Rahm/Desktop/Hooks/WindowChange.hs
+++ b/src/Rahm/Desktop/Hooks/WindowChange.hs
@@ -26,11 +26,18 @@ import qualified XMonad.Util.ExtensibleState as XS (get, put)
type WindowStack = StackSet WorkspaceId () Window ScreenId ScreenDetail
-- Type of hook. Takes the last WindowStack and the new WindowStack
-type StackChangeHook = WindowStack -> WindowStack -> X ()
+newtype StackChangeHook = StackChangeHook (WindowStack -> WindowStack -> X ())
newtype LastState = LastState (Maybe WindowStack)
deriving (Read, Show)
+instance Semigroup StackChangeHook where
+ StackChangeHook f1 <> StackChangeHook f2 =
+ StackChangeHook $ \l c -> f1 l c >> f2 l c
+
+instance Monoid StackChangeHook where
+ mempty = StackChangeHook $ \_ _ -> return ()
+
instance Default LastState where
def = LastState def
@@ -45,7 +52,7 @@ instance ExtensionClass LastState where
--
-- If the first window is Nothing, this is the first time XMonad started.
withStackChangeHook :: StackChangeHook -> XConfig l -> XConfig l
-withStackChangeHook fn config =
+withStackChangeHook (StackChangeHook fn) config =
config
{ logHook = do
logHook config