mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 04:31:52 -07:00
X.A.GroupNavigation, X.H.WorkspaceHistory: Leak fix cleanups
Simplify stuff a bit. Prevent memory leaks additionally in: `workspaceHistoryTransaction` and `workspaceHistoryModify`. Related: https://github.com/xmonad/xmonad-contrib/pull/653
This commit is contained in:
@@ -169,9 +169,7 @@ instance ExtensionClass HistoryDB where
|
||||
-- | Action that needs to be executed as a logHook to maintain the
|
||||
-- focus history of all windows as the WindowSet changes.
|
||||
historyHook :: X ()
|
||||
historyHook = do
|
||||
db' <- XS.get >>= updateHistory
|
||||
db' `deepseq` XS.put db'
|
||||
historyHook = (XS.put $!) . force =<< updateHistory =<< XS.get
|
||||
|
||||
-- Updates the history in response to a WindowSet change
|
||||
updateHistory :: HistoryDB -> X HistoryDB
|
||||
|
@@ -84,10 +84,10 @@ workspaceHistoryHook = workspaceHistoryHookExclude []
|
||||
-- | Like 'workspaceHistoryHook', but with the ability to exclude
|
||||
-- certain workspaces.
|
||||
workspaceHistoryHookExclude :: [WorkspaceId] -> X ()
|
||||
workspaceHistoryHookExclude ws = do
|
||||
s <- gets windowset
|
||||
let update' = force . updateLastActiveOnEachScreenExclude ws s
|
||||
XS.modify' update'
|
||||
workspaceHistoryHookExclude ws = XS.modify' . update =<< gets windowset
|
||||
where
|
||||
update :: WindowSet -> WorkspaceHistory -> WorkspaceHistory
|
||||
update s = force . updateLastActiveOnEachScreenExclude ws s
|
||||
|
||||
workspaceHistoryWithScreen :: X [(ScreenId, WorkspaceId)]
|
||||
workspaceHistoryWithScreen = XS.gets history
|
||||
@@ -110,7 +110,7 @@ workspaceHistoryTransaction action = do
|
||||
startingHistory <- XS.gets history
|
||||
action
|
||||
new <- flip updateLastActiveOnEachScreen (WorkspaceHistory startingHistory) <$> gets windowset
|
||||
XS.put new
|
||||
XS.put $! force new
|
||||
|
||||
-- | Update the last visible workspace on each monitor if needed
|
||||
-- already there, or move it to the front if it is.
|
||||
@@ -134,4 +134,4 @@ updateLastActiveOnEachScreenExclude ws StackSet {current = cur, visible = vis} w
|
||||
|
||||
-- | Modify a the workspace history with a given pure function.
|
||||
workspaceHistoryModify :: ([(ScreenId, WorkspaceId)] -> [(ScreenId, WorkspaceId)]) -> X ()
|
||||
workspaceHistoryModify action = XS.modify $ WorkspaceHistory . action . history
|
||||
workspaceHistoryModify action = XS.modify' $ force . WorkspaceHistory . action . history
|
||||
|
Reference in New Issue
Block a user