aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Hooks/WindowChange.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-12-07 00:50:01 -0700
committerJosh Rahm <joshuarahm@gmail.com>2023-12-07 00:50:54 -0700
commit87b103a4995fd2b6bbd1e72c446fd789caf5a050 (patch)
tree91e54916d8ced30a62b6c75ea278a10ba3a52341 /src/Rahm/Desktop/Hooks/WindowChange.hs
parent83543b4972edcebf3d9e568ed6a556ce074daa06 (diff)
downloadrde-87b103a4995fd2b6bbd1e72c446fd789caf5a050.tar.gz
rde-87b103a4995fd2b6bbd1e72c446fd789caf5a050.tar.bz2
rde-87b103a4995fd2b6bbd1e72c446fd789caf5a050.zip
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.
Diffstat (limited to 'src/Rahm/Desktop/Hooks/WindowChange.hs')
-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