diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2026-03-01 15:23:09 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2026-03-01 15:23:09 -0700 |
| commit | 2bcd8842dab3a8e62b5ad7cba6cbfbe3fc648f0d (patch) | |
| tree | dc01ce2b6ae461a9f9fc5e01799fc51885c4d4df | |
| parent | 5e678c0c4cad37ecbf91c43cbd829087d8340b2f (diff) | |
| download | rde-2bcd8842dab3a8e62b5ad7cba6cbfbe3fc648f0d.tar.gz rde-2bcd8842dab3a8e62b5ad7cba6cbfbe3fc648f0d.tar.bz2 rde-2bcd8842dab3a8e62b5ad7cba6cbfbe3fc648f0d.zip | |
[fix] get rid of "horizontally ordered screens"
order the screens top-to-bottom left-to-right.
| -rw-r--r-- | src/Rahm/Desktop/Keys/Wml.hs | 16 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Workspaces.hs | 26 |
2 files changed, 24 insertions, 18 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index 9122ccb..00c8139 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -8,8 +8,8 @@ -- @a // All windows on workspace 'a' or the workspace with window 'a' -- ,. // The workspace to to the right of the current one. -- @,. // All windows on the workspace to the right of the current one. --- @,^ // All the windows on the screen second from the left --- &z!~@,,^ // The window tagged with z and The last window on the screen third from the left +-- @,^ // All the windows on the screen second from the top (in reading order) +-- &z!~@,,^ // The window tagged with z and The last window on the screen third from the top (in reading order) -- @@s // All the windows that share a workspace with the window tagged s -- \%@s // All windows except those on workspace 's' module Rahm.Desktop.Keys.Wml @@ -480,11 +480,11 @@ readNextWorkspace = case key of (mask, keysym, _) | (Just macro) <- Map.lookup (mask, keysym) macros -> do - pushKeys macro - readNextWorkspace + pushKeys macro + readNextWorkspace (_, _, [ch]) | isAlphaNum ch || ch == '*' -> - return $ justWorkspace [ch] + return $ justWorkspace [ch] (_, _, "[") -> justWorkspace <$> ( lift1 (adjacentWorkspaceNotVisible prev) @@ -518,7 +518,7 @@ readNextWorkspace = ) . head ) - (getHorizontallyOrderedScreens ws) + (getOrderedScreens ws) -- The last workspace in history. (_, _, "'") -> justWorkspace . locationWorkspace <$> liftXMaybe lastLocation @@ -531,7 +531,7 @@ readNextWorkspace = withWindowSet $ \ws -> return $ (fmap (justWorkspace . W.tag . W.workspace . snd) . last) - (getHorizontallyOrderedScreens ws) + (getOrderedScreens ws) -- Modify the next workspace as a "floating" workspace. (Windows sent to -- it will float). (_, _, ":") -> @@ -682,7 +682,7 @@ readNextLocationSet' = -- Windows in a workspace (_, _, s) | s == "\t" || s == "@" || s == "\n" -> - (liftXToFeed . workspaceWindows) =<< readNextWorkspace + (liftXToFeed . workspaceWindows) =<< readNextWorkspace -- The first window in the next window set. (_, _, "!") -> (: []) <$> absorbMaybe (head <$> readNextLocationSet) -- The windows except the first in a window set. diff --git a/src/Rahm/Desktop/Workspaces.hs b/src/Rahm/Desktop/Workspaces.hs index 72e929b..50a04d2 100644 --- a/src/Rahm/Desktop/Workspaces.hs +++ b/src/Rahm/Desktop/Workspaces.hs @@ -6,7 +6,7 @@ module Rahm.Desktop.Workspaces lastWorkspaceId, firstWorkspaceId, windowsInCurrentWorkspace, - getHorizontallyOrderedScreens, + getOrderedScreens, accompanyingWorkspace, adjacentWorkspaceNotVisible, adjacentWorkspace, @@ -93,15 +93,21 @@ windowsInCurrentWorkspace = withWindowSet $ \(W.StackSet (W.Screen (W.Workspace _ _ s) _ _) _ _ _) -> do return $ W.integrate' s -getHorizontallyOrderedScreens :: +getOrderedScreens :: W.StackSet wid l a ScreenId ScreenDetail -> [(Bool, W.Screen wid l a ScreenId ScreenDetail)] --- ^ Returns a list of screens ordered from leftmost to rightmost. -getHorizontallyOrderedScreens windowSet = - flip sortBy screens $ \sc1 sc2 -> - let (SD (Rectangle x1 _ _ _)) = W.screenDetail (snd sc1) - (SD (Rectangle x2 _ _ _)) = W.screenDetail (snd sc2) - in x1 `compare` x2 +-- ^ Returns a list of screens ordered top to bottom, left to right (based on center point). +getOrderedScreens windowSet = + flip sortBy screens $ \(b1, sc1) (b2, sc2) -> + let (SD (Rectangle x1 y1 w1 h1)) = W.screenDetail sc1 + (SD (Rectangle x2 y2 w2 h2)) = W.screenDetail sc2 + xCenter1 = fromIntegral x1 + (fromIntegral w1 / 2) + yCenter1 = fromIntegral y1 + (fromIntegral h1 / 2) + xCenter2 = fromIntegral x2 + (fromIntegral w2 / 2) + yCenter2 = fromIntegral y2 + (fromIntegral h2 / 2) + in case yCenter1 `compare` yCenter2 of + EQ -> xCenter1 `compare` xCenter2 + other -> other where screens = (True, W.current windowSet) : map (False,) (W.visible windowSet) @@ -157,14 +163,14 @@ viewAdjacentTo wsM (Selector sel) = runMaybeT_ $ do adjacentScreen :: Selector -> X WorkspaceId adjacentScreen (Selector f) = do (screens, current) <- - withWindowSet $ return . (getHorizontallyOrderedScreens &&& W.current) + withWindowSet $ return . (getOrderedScreens &&& W.current) return $ W.tag $ W.workspace $ maybe current snd (f fst screens) withScreen :: (WorkspaceId -> WindowSet -> WindowSet) -> Int -> X () withScreen fn n = do windows $ \windowSet -> - case map snd (getHorizontallyOrderedScreens windowSet) !! n of + case map snd (getOrderedScreens windowSet) !! n of Nothing -> windowSet Just screen -> fn (W.tag $ W.workspace screen) windowSet |