From 87b103a4995fd2b6bbd1e72c446fd789caf5a050 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 7 Dec 2023 00:50:01 -0700 Subject: Experimental ability to pin a window using Mod+p A pinned window will always try to stay on the same screen in the sname position if it can. --- src/Rahm/Desktop/Hooks/WindowChange.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Rahm/Desktop/Hooks') 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 -- cgit