diff options
Diffstat (limited to 'src/Rahm/Desktop/Workspaces.hs')
| -rw-r--r-- | src/Rahm/Desktop/Workspaces.hs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Rahm/Desktop/Workspaces.hs b/src/Rahm/Desktop/Workspaces.hs index 50a04d2..96e4d99 100644 --- a/src/Rahm/Desktop/Workspaces.hs +++ b/src/Rahm/Desktop/Workspaces.hs @@ -18,6 +18,8 @@ module Rahm.Desktop.Workspaces getWorkspaceToTheLeft, getWorkspaceAbove, getWorkspaceBelow, + getNextWorkspaceInOrder, + getPrevWorkspaceInOrder, WorkspaceState (..), ) where @@ -142,6 +144,41 @@ adjacentWorkspace (Selector selector) from = let tags = sort $ W.tag . snd <$> getPopulatedWorkspaces ss in return $ fromMaybe from $ selector (== from) tags +getNextWorkspaceInOrder :: WorkspaceId -> X WorkspaceId +getNextWorkspaceInOrder from = + withWindowSet $ \ss -> + let screens = getOrderedScreens ss + tags = map (W.tag . W.workspace . snd) screens + tagsWithHidden = map (W.tag . snd) $ getPopulatedWorkspaces ss + orderedTags = filter (\t -> t `elem` tagsWithHidden) tags + getIndex [] _ = Nothing + getIndex (x : xs) target = + if x == target + then + if null xs + then Just $ head orderedTags -- wrap around + else Just $ head xs + else getIndex xs target + in return $ fromMaybe from $ getIndex orderedTags from + +getPrevWorkspaceInOrder :: WorkspaceId -> X WorkspaceId +getPrevWorkspaceInOrder from = + withWindowSet $ \ss -> + let screens = getOrderedScreens ss + tags = map (W.tag . W.workspace . snd) screens + tagsWithHidden = map (W.tag . snd) $ getPopulatedWorkspaces ss + orderedTags = filter (\t -> t `elem` tagsWithHidden) tags + reverseTags = reverse orderedTags + getIndex [] _ = Nothing + getIndex (x : xs) target = + if x == target + then + if null xs + then Just $ head reverseTags -- wrap around + else Just $ head xs + else getIndex xs target + in return $ fromMaybe from $ getIndex reverseTags from + viewAdjacent :: Selector -> X () viewAdjacent sel = gotoWorkspace =<< (adjacentWorkspaceNotVisible sel =<< getCurrentWorkspace) |