Merge pull request #284 from skewerr/master

X.A.DynamicWorkspaceOrder: add transformation-aware withNthWorkspace
This commit is contained in:
Brent Yorgey 2019-02-13 05:49:42 -06:00 committed by GitHub
commit 2ce876c330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

@ -89,6 +89,11 @@
* `XMonad.Actions.MessageHandling` * `XMonad.Actions.MessageHandling`
Refresh-performing functions updated to better reflect the new `sendMessage`. Refresh-performing functions updated to better reflect the new `sendMessage`.
* `XMonad.Actions.DynamicProjects`
Add a version of `withNthWorkspace` that takes a `[WorkspaceId] ->
[WorkspaceId]` transformation to apply over the list of workspace tags
resulting from the dynamic order.
## 0.14 ## 0.14
### Breaking Changes ### Breaking Changes

View File

@ -30,6 +30,7 @@ module XMonad.Actions.DynamicWorkspaceOrder
, moveToGreedy , moveToGreedy
, shiftTo , shiftTo
, withNthWorkspace'
, withNthWorkspace , withNthWorkspace
) where ) where
@ -183,13 +184,19 @@ moveToGreedy dir t = doTo dir t getSortByOrder (windows . W.greedyView)
shiftTo :: Direction1D -> WSType -> X () shiftTo :: Direction1D -> WSType -> X ()
shiftTo dir t = doTo dir t getSortByOrder (windows . W.shift) shiftTo dir t = doTo dir t getSortByOrder (windows . W.shift)
-- | Do something with the nth workspace in the dynamic order after
-- transforming it. The callback is given the workspace's tag as well
-- as the 'WindowSet' of the workspace itself.
withNthWorkspace' :: ([WorkspaceId] -> [WorkspaceId]) -> (String -> WindowSet -> WindowSet) -> Int -> X ()
withNthWorkspace' tr job wnum = do
sort <- getSortByOrder
ws <- gets (tr . map W.tag . sort . W.workspaces . windowset)
case drop wnum ws of
(w:_) -> windows $ job w
[] -> return ()
-- | Do something with the nth workspace in the dynamic order. The -- | Do something with the nth workspace in the dynamic order. The
-- callback is given the workspace's tag as well as the 'WindowSet' -- callback is given the workspace's tag as well as the 'WindowSet'
-- of the workspace itself. -- of the workspace itself.
withNthWorkspace :: (String -> WindowSet -> WindowSet) -> Int -> X () withNthWorkspace :: (String -> WindowSet -> WindowSet) -> Int -> X ()
withNthWorkspace job wnum = do withNthWorkspace = withNthWorkspace' id
sort <- getSortByOrder
ws <- gets (map W.tag . sort . W.workspaces . windowset)
case drop wnum ws of
(w:_) -> windows $ job w
[] -> return ()