diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2023-12-07 00:50:01 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2023-12-07 00:50:54 -0700 |
| commit | 87b103a4995fd2b6bbd1e72c446fd789caf5a050 (patch) | |
| tree | 91e54916d8ced30a62b6c75ea278a10ba3a52341 /src/Rahm/Desktop/History.hs | |
| parent | 83543b4972edcebf3d9e568ed6a556ce074daa06 (diff) | |
| download | rde-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/History.hs')
| -rw-r--r-- | src/Rahm/Desktop/History.hs | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/src/Rahm/Desktop/History.hs b/src/Rahm/Desktop/History.hs index ffcb10e..d1a4bb9 100644 --- a/src/Rahm/Desktop/History.hs +++ b/src/Rahm/Desktop/History.hs @@ -58,7 +58,7 @@ zipperDbgPrint _ = "<empty>" pushZipper :: a -> BoundedSeqZipper a -> BoundedSeqZipper a pushZipper e (BoundedSeqZipper maxSize _ (tail :|> _)) | maxSize <= Seq.length tail = - BoundedSeqZipper maxSize mempty (e :<| tail) + BoundedSeqZipper maxSize mempty (e :<| tail) pushZipper e (BoundedSeqZipper maxSize _ tail) = BoundedSeqZipper maxSize mempty (e :<| tail) @@ -133,44 +133,44 @@ data ScreenDiff = ScreenDiff newLocation :: Location } -historyHook :: WindowStack -> WindowStack -> X () +historyHook :: StackChangeHook -- History hook where the 'from' location workspace does not match the 'to' -- location workspace. -historyHook lastWindowSet currentWindowSet = do +historyHook = StackChangeHook $ \lastWindowSet currentWindowSet -> do (History hist) <- XS.get forM_ (getScreenDiffs lastWindowSet currentWindowSet) $ -- Read as "the screen <sid> went from <oloc> to <nloc>" \(ScreenDiff sid oloc nloc) -> let (ows, nws) = (locationWorkspace oloc, locationWorkspace nloc) - - -- The goal here is to preserve history in as intuitive a way as possible - -- When the stackset changes, for each screen that changed in the last - -- windowchange, one of 2 situations are possibel: - -- - -- 1. The workspace on the screen was swapped with an already visible - -- screen - -- - -- 2. The workspace on the screen was swapped with a hidden workspace. - -- - -- In the case of 1, we want to treat it as if the screen was - -- "reseated" to a different monitor, preserving the history for that - -- screen on its new screen. - -- - -- In case of 2, we want to add the old workspace to the history of the - -- screen that changed. - in case () of - () | nws `visibleIn` lastWindowSet, - (Just oscr) <- screenOf nws lastWindowSet -> - -- The last workspace was on a different screen. Swap the current - -- screen's history with the history from the last screen the - -- workspace was on. - XS.modify $ \(History byScreen) -> - History - ( Map.alter - (const $ Map.lookup oscr hist) - sid - byScreen - ) + in -- The goal here is to preserve history in as intuitive a way as possible + -- When the stackset changes, for each screen that changed in the last + -- windowchange, one of 2 situations are possibel: + -- + -- 1. The workspace on the screen was swapped with an already visible + -- screen + -- + -- 2. The workspace on the screen was swapped with a hidden workspace. + -- + -- In the case of 1, we want to treat it as if the screen was + -- "reseated" to a different monitor, preserving the history for that + -- screen on its new screen. + -- + -- In case of 2, we want to add the old workspace to the history of the + -- screen that changed. + case () of + () + | nws `visibleIn` lastWindowSet, + (Just oscr) <- screenOf nws lastWindowSet -> + -- The last workspace was on a different screen. Swap the current + -- screen's history with the history from the last screen the + -- workspace was on. + XS.modify $ \(History byScreen) -> + History + ( Map.alter + (const $ Map.lookup oscr hist) + sid + byScreen + ) -- The new workspace was not originally visible, add to history () | not (nws `visibleIn` lastWindowSet) -> XS.modify $ \(History byScreen) -> @@ -180,7 +180,6 @@ historyHook lastWindowSet currentWindowSet = do sid byScreen ) - -- This is typically not a possible case. It's only possible when a -- screen is unplugged. If that's the case, do nothing. _ -> return () |