Adds withUnfocused function to XMonad.Operations

This commit is contained in:
Solomon Bothwell
2021-09-09 10:25:24 -07:00
parent 5da25c5413
commit b3bd9c90d1
2 changed files with 11 additions and 1 deletions

View File

@@ -2,6 +2,9 @@
## unknown (unknown)
* Adds `withUnfocused` function to `XMonad.Operations`, allowing for
`X` operations to be applied to all unfocused windows.
* Fixed a bug when using multiple screens with different dimensions,
causing some floating windows to be smaller/larger than the size they
requested.

View File

@@ -21,7 +21,7 @@ module XMonad.Operations (
setTopFocus, focus, withFocused,
-- * Manage Windows
windows, refresh, rescreen, modifyWindowSet, windowBracket, windowBracket_, clearEvents, getCleanedScreenInfo,
windows, refresh, rescreen, modifyWindowSet, windowBracket, windowBracket_, clearEvents, getCleanedScreenInfo, withUnfocused,
-- * Keyboard and Mouse
cleanMask, extraModifiers,
@@ -481,6 +481,13 @@ screenWorkspace sc = withWindowSet $ return . W.lookupWorkspace sc
withFocused :: (Window -> X ()) -> X ()
withFocused f = withWindowSet $ \w -> whenJust (W.peek w) f
-- | Apply an 'X' operation to all unfocused windows, if there are any.
withUnfocused :: (Window -> X ()) -> X ()
withUnfocused f = withWindowSet $ \ws ->
whenJust (W.peek ws) $ \w ->
let unfocusedWindows = filter (/= w) $ W.index ws
in mapM_ f unfocusedWindows
-- | Is the window is under management by xmonad?
isClient :: Window -> X Bool
isClient w = withWindowSet $ return . W.member w