From 539bbd4045c010bedc785f5859e29b03814b5796 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 3 Aug 2022 16:04:48 -0600 Subject: Add preferred window for some Workspace jumps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wml workspace @w refers to the workspace that contains the window marked 'w', however when jumping to that workspace, an arbitrary window is focused. It's more intuitive to set focus to the window 'w'. This means that @• is the same as •. --- src/Rahm/Desktop/Keys/Wml.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index 34dabd2..d6289bd 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -94,6 +94,22 @@ justWorkspace s = , extraWorkspaceData = () } +justWorkspaceWithPreferredWindow :: Window -> String -> Workspace +justWorkspaceWithPreferredWindow w s = + Workspace { + moveLocationToWorkspaceFn = flip moveLocationToWorkspace s + , gotoWorkspaceFn = do + windows $ \ws' -> + let ws = W.greedyView s ws' + l = W.integrate' $ W.stack $ W.workspace $ W.current ws in + if w `elem` l + then W.focusWindow w ws + else ws + + , workspaceName = Just s + , extraWorkspaceData = () + } + blackHoleWorkspace :: Workspace blackHoleWorkspace = Workspace { @@ -272,7 +288,7 @@ readNextWorkspace = MaybeT $ fromX $ withWindowSet $ \ws -> return $ do win <- locationWindow =<< head loc winLocation <- W.findWindow ws win - (justWorkspace . W.tag) <$> W.getLocationWorkspace winLocation + (justWorkspaceWithPreferredWindow win . W.tag) <$> W.getLocationWorkspace winLocation (_, _, "~") -> justWorkspace . accompaningWorkspace <$> readNextWorkspaceName -- cgit