diff options
Diffstat (limited to 'src/Rahm/Desktop/Workspaces.hs')
| -rw-r--r-- | src/Rahm/Desktop/Workspaces.hs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/Rahm/Desktop/Workspaces.hs b/src/Rahm/Desktop/Workspaces.hs index 87d112e..2a266b7 100644 --- a/src/Rahm/Desktop/Workspaces.hs +++ b/src/Rahm/Desktop/Workspaces.hs @@ -28,12 +28,13 @@ data WorkspaceState = Current | Hidden | Visible -- -- This function will sort the result by the workspace tag. getPopulatedWorkspaces :: - (Ord i) => W.StackSet i l a sid sd -> [(WorkspaceState, W.Workspace i l a)] + W.StackSet String l a sid sd -> [(WorkspaceState, W.Workspace String l a)] getPopulatedWorkspaces (W.StackSet (W.Screen cur _ _) vis hi _) = - sortOn (W.tag . snd) $ - mapMaybe (\w@(W.Workspace _ _ s) -> fmap (const (Hidden, w)) s) hi ++ - map (\(W.Screen w _ _) -> (Visible, w)) vis ++ - [(Current, cur)] + filter ((/="*") . W.tag . snd) $ + sortOn (W.tag . snd) $ + mapMaybe (\w@(W.Workspace _ _ s) -> fmap (const (Hidden, w)) s) hi ++ + map (\(W.Screen w _ _) -> (Visible, w)) vis ++ + [(Current, cur)] next :: Selector next = Selector $ \f l -> select f l l @@ -46,11 +47,24 @@ prev :: Selector prev = Selector $ \f l -> let (Selector fn) = next in fn f (reverse l) +lastWorkspaceId :: X WorkspaceId +lastWorkspaceId = + W.tag . snd . last <$> withWindowSet (return . getPopulatedWorkspaces) + +firstWorkspaceId :: X WorkspaceId +firstWorkspaceId = + W.tag . snd . head <$> withWindowSet (return . getPopulatedWorkspaces) + getCurrentWorkspace :: X WorkspaceId getCurrentWorkspace = withWindowSet $ \(W.StackSet (W.Screen (W.Workspace t _ _) _ _) _ _ _) -> do return t +windowsInCurrentWorkspace :: X [Window] +windowsInCurrentWorkspace = withWindowSet $ + \(W.StackSet (W.Screen (W.Workspace _ _ s) _ _) _ _ _) -> do + return $ W.integrate' s + getHorizontallyOrderedScreens :: W.StackSet wid l a ScreenId ScreenDetail -> [(Bool, W.Screen wid l a ScreenId ScreenDetail)] @@ -103,7 +117,7 @@ adjacentWorkspace :: Selector -> WorkspaceId -> X WorkspaceId adjacentWorkspace (Selector selector) from = withWindowSet $ \ss -> let tags = sort $ - W.tag . snd <$> (filter (\x -> fst x /= Visible) $ + W.tag . snd <$> filter (\x -> fst x /= Visible) ( getPopulatedWorkspaces ss) in return $ fromMaybe from $ selector (==from) tags @@ -117,7 +131,7 @@ adjacentScreen (Selector f) = do (screens, current) <- withWindowSet $ return . (getHorizontallyOrderedScreens &&& W.current) - return $ W.tag $ W.workspace $ fromMaybe current (snd <$> f fst screens) + return $ W.tag $ W.workspace $ maybe current snd (f fst screens) withScreen :: (WorkspaceId -> WindowSet -> WindowSet) -> Int -> X () withScreen fn n = do |