diff options
| author | Josh Rahm <rahm@google.com> | 2021-11-04 14:10:52 -0600 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2021-11-04 14:10:52 -0600 |
| commit | 523ef127e36d91560851d912a2765fa408ce1100 (patch) | |
| tree | 98f092bff2d67a47632d72c0fddd3366a7422577 /src/Internal/Lib.hs | |
| parent | ebf78e8e8c33ee03d63123a4b4d9cb099485ff4c (diff) | |
| download | rde-523ef127e36d91560851d912a2765fa408ce1100.tar.gz rde-523ef127e36d91560851d912a2765fa408ce1100.tar.bz2 rde-523ef127e36d91560851d912a2765fa408ce1100.zip | |
Fix old bug.
Old bug where shifting workspaces relatively using mod-n/p would not
work as expected where visible workspaces without any windows would be
skipped over or plain not work.
Diffstat (limited to 'src/Internal/Lib.hs')
| -rw-r--r-- | src/Internal/Lib.hs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Internal/Lib.hs b/src/Internal/Lib.hs index feb5f26..3ba1eca 100644 --- a/src/Internal/Lib.hs +++ b/src/Internal/Lib.hs @@ -21,6 +21,9 @@ import XMonad hiding (workspaces, Screen) import XMonad.StackSet hiding (filter, focus) import qualified Data.Map as Map import Internal.DMenu +import Data.Ord (comparing) + +import qualified XMonad.StackSet as S type WorkspaceName = Char newtype Selector = Selector (forall a. (Eq a) => a -> [a] -> a) @@ -31,6 +34,23 @@ instance XPrompt WinPrompt where showXPrompt _ = "[Window] " commandToComplete _ = id +data WorkspaceState = Current | Hidden | Visible + +-- Returns all the workspaces that are either visible, current or Hidden but +-- have windows and that workspace's state. +-- +-- In other words, filters out workspaces that have no windows and are not +-- visible. +-- +-- This function will sort the result by the workspace tag. +getPopulatedWorkspaces :: + (Ord i) => S.StackSet i l a sid sd -> [(WorkspaceState, S.Workspace i l a)] +getPopulatedWorkspaces (S.StackSet (S.Screen cur _ _) vis hi _) = + sortBy (comparing (tag . snd)) $ + mapMaybe (\w@(S.Workspace _ _ s) -> fmap (const (Hidden, w)) s) hi ++ + map (\(S.Screen w _ _) -> (Visible, w)) vis ++ + [(Current, cur)] + getHorizontallyOrderedScreens :: StackSet wid l a ScreenId ScreenDetail -> [Screen wid l a ScreenId ScreenDetail] @@ -91,7 +111,7 @@ getString = runQuery $ do relativeWorkspaceShift :: Selector -> X () relativeWorkspaceShift (Selector selector) = do windows $ \ss -> - let tags = sort $ (tag <$> filter (isJust . stack) (workspaces ss)) + let tags = sort $ (tag . snd <$> getPopulatedWorkspaces ss) from = tag $ workspace $ current ss to = selector from tags in greedyView to ss |