mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 20:51: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
|
-- | Action that needs to be executed as a logHook to maintain the
|
||||||
-- focus history of all windows as the WindowSet changes.
|
-- focus history of all windows as the WindowSet changes.
|
||||||
historyHook :: X ()
|
historyHook :: X ()
|
||||||
historyHook = do
|
historyHook = (XS.put $!) . force =<< updateHistory =<< XS.get
|
||||||
db' <- XS.get >>= updateHistory
|
|
||||||
db' `deepseq` XS.put db'
|
|
||||||
|
|
||||||
-- Updates the history in response to a WindowSet change
|
-- Updates the history in response to a WindowSet change
|
||||||
updateHistory :: HistoryDB -> X HistoryDB
|
updateHistory :: HistoryDB -> X HistoryDB
|
||||||
|
@@ -84,10 +84,10 @@ workspaceHistoryHook = workspaceHistoryHookExclude []
|
|||||||
-- | Like 'workspaceHistoryHook', but with the ability to exclude
|
-- | Like 'workspaceHistoryHook', but with the ability to exclude
|
||||||
-- certain workspaces.
|
-- certain workspaces.
|
||||||
workspaceHistoryHookExclude :: [WorkspaceId] -> X ()
|
workspaceHistoryHookExclude :: [WorkspaceId] -> X ()
|
||||||
workspaceHistoryHookExclude ws = do
|
workspaceHistoryHookExclude ws = XS.modify' . update =<< gets windowset
|
||||||
s <- gets windowset
|
where
|
||||||
let update' = force . updateLastActiveOnEachScreenExclude ws s
|
update :: WindowSet -> WorkspaceHistory -> WorkspaceHistory
|
||||||
XS.modify' update'
|
update s = force . updateLastActiveOnEachScreenExclude ws s
|
||||||
|
|
||||||
workspaceHistoryWithScreen :: X [(ScreenId, WorkspaceId)]
|
workspaceHistoryWithScreen :: X [(ScreenId, WorkspaceId)]
|
||||||
workspaceHistoryWithScreen = XS.gets history
|
workspaceHistoryWithScreen = XS.gets history
|
||||||
@@ -110,7 +110,7 @@ workspaceHistoryTransaction action = do
|
|||||||
startingHistory <- XS.gets history
|
startingHistory <- XS.gets history
|
||||||
action
|
action
|
||||||
new <- flip updateLastActiveOnEachScreen (WorkspaceHistory startingHistory) <$> gets windowset
|
new <- flip updateLastActiveOnEachScreen (WorkspaceHistory startingHistory) <$> gets windowset
|
||||||
XS.put new
|
XS.put $! force new
|
||||||
|
|
||||||
-- | Update the last visible workspace on each monitor if needed
|
-- | Update the last visible workspace on each monitor if needed
|
||||||
-- already there, or move it to the front if it is.
|
-- 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.
|
-- | Modify a the workspace history with a given pure function.
|
||||||
workspaceHistoryModify :: ([(ScreenId, WorkspaceId)] -> [(ScreenId, WorkspaceId)]) -> X ()
|
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