Added withFirstMinimized and withFirstMinimized'.

Also changed the order of the `L.intersect` line to prevent the map key ordering from changing the minimizedStack.
This commit is contained in:
spoonm 2017-06-17 10:20:49 -03:00
parent 12227d37ca
commit 8266feba95
2 changed files with 18 additions and 1 deletions

View File

@ -124,6 +124,11 @@
changed and you want to re-sort windows into the appropriate changed and you want to re-sort windows into the appropriate
sub-layout. sub-layout.
* `XMonad.Actions.Minimize`
- Now has `withFirstMinimized` and `withFirstMinimized'` so you can perform
actions with both the last and first minimized windows easily.
## 0.13 (February 10, 2017) ## 0.13 (February 10, 2017)
### Breaking Changes ### Breaking Changes

View File

@ -29,6 +29,8 @@ module XMonad.Actions.Minimize
, maximizeWindowAndFocus , maximizeWindowAndFocus
, withLastMinimized , withLastMinimized
, withLastMinimized' , withLastMinimized'
, withFirstMinimized
, withFirstMinimized'
, withMinimized , withMinimized
) where ) where
@ -85,7 +87,7 @@ modified f = XS.modified $
in Minimized { rectMap = newRectMap in Minimized { rectMap = newRectMap
, minimizedStack = (newWindows L.\\ oldStack) , minimizedStack = (newWindows L.\\ oldStack)
++ ++
(newWindows `L.intersect` oldStack) (oldStack `L.intersect` newWindows)
} }
@ -115,6 +117,16 @@ maximizeWindow = maximizeWindowAndChangeWSet $ const id
maximizeWindowAndFocus :: Window -> X () maximizeWindowAndFocus :: Window -> X ()
maximizeWindowAndFocus = maximizeWindowAndChangeWSet W.focusWindow maximizeWindowAndFocus = maximizeWindowAndChangeWSet W.focusWindow
-- | Perform an action with first minimized window on current workspace
-- or do nothing if there is no minimized windows on current workspace
withFirstMinimized :: (Window -> X ()) -> X ()
withFirstMinimized action = withFirstMinimized' (flip whenJust action)
-- | Like withFirstMinimized but the provided action is always invoked with a
-- 'Maybe Window', that will be nothing if there is no first minimized window.
withFirstMinimized' :: (Maybe Window -> X ()) -> X ()
withFirstMinimized' action = withMinimized (action . listToMaybe . reverse)
-- | Perform an action with last minimized window on current workspace -- | Perform an action with last minimized window on current workspace
-- or do nothing if there is no minimized windows on current workspace -- or do nothing if there is no minimized windows on current workspace
withLastMinimized :: (Window -> X ()) -> X () withLastMinimized :: (Window -> X ()) -> X ()