X.U.NamedScratchpads: Check for "new" workspace in nsHideOnFocusLoss

When XMonad was recently restarted, it can happen that the workspace
history is empty, hence the last focused window could actually be the
currently focused one.  In that case, we don't want to go through the
machinery of looking to hide any NSPs, as there is only one window in
the current workspace (the focused one).  This may or may not be a
scratchpad, we don't care.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/779
This commit is contained in:
Tony Zorman 2022-11-20 08:06:07 +01:00
parent 58e7f6d3c3
commit 10c1a93963

View File

@ -286,8 +286,15 @@ allNamedScratchpadAction = someNamedScratchpadAction mapM_ runApplication
nsHideOnFocusLoss :: NamedScratchpads -> X ()
nsHideOnFocusLoss scratches = withWindowSet $ \winSet -> do
let cur = W.currentTag winSet
withRecentsIn cur () $ \lastFocus _ ->
when (lastFocus `elem` W.index winSet && cur /= scratchpadWorkspaceTag) $
withRecentsIn cur () $ \lastFocus curFocus -> do
let isWorthy =
-- Check for the window being on the current workspace; if there
-- is no history (i.e., curFocus ≡ lastFocus), don't do anything
-- because the potential scratchpad is definitely focused.
lastFocus `elem` W.index winSet && lastFocus /= curFocus
-- Don't do anything on the NSP workspace, lest the world explodes.
&& cur /= scratchpadWorkspaceTag
when isWorthy $
whenX (isNSP lastFocus scratches) $
shiftToNSP (W.workspaces winSet) ($ lastFocus)