aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-03 16:04:48 -0600
committerJosh Rahm <rahm@google.com>2022-08-03 16:04:48 -0600
commit539bbd4045c010bedc785f5859e29b03814b5796 (patch)
tree4b0e80ae567c441e33b47495b7dda4504d45752b /src
parent6122cd030e03945382dad927c32a259c077bd468 (diff)
downloadrde-539bbd4045c010bedc785f5859e29b03814b5796.tar.gz
rde-539bbd4045c010bedc785f5859e29b03814b5796.tar.bz2
rde-539bbd4045c010bedc785f5859e29b03814b5796.zip
Add preferred window for some Workspace jumps.
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 <H-g>@• is the same as <H-w>•.
Diffstat (limited to 'src')
-rw-r--r--src/Rahm/Desktop/Keys/Wml.hs18
1 files changed, 17 insertions, 1 deletions
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