diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2021-11-06 00:50:47 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2021-11-06 00:50:47 -0600 |
| commit | d78c2c6f774f0b06b5914fcf99545a879ae8cc10 (patch) | |
| tree | c1f98bb9e4b545207901c089dd305f063060542e /src/Internal/Lib.hs | |
| parent | ea44b017950cbab49a68959190ab0a859d45e7b1 (diff) | |
| parent | 62eccced2d4a756b719dae9c25dc3859360608c2 (diff) | |
| download | rde-d78c2c6f774f0b06b5914fcf99545a879ae8cc10.tar.gz rde-d78c2c6f774f0b06b5914fcf99545a879ae8cc10.tar.bz2 rde-d78c2c6f774f0b06b5914fcf99545a879ae8cc10.zip | |
Merge branch 'master' of github.com:jrahm/xmonad-jrahm
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 |