From b3bd9c90d18197819d43c57b7961200bdf19d32a Mon Sep 17 00:00:00 2001 From: Solomon Bothwell Date: Thu, 9 Sep 2021 10:25:24 -0700 Subject: [PATCH 1/2] Adds withUnfocused function to XMonad.Operations --- CHANGES.md | 3 +++ src/XMonad/Operations.hs | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 0f5bf10..5895343 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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. diff --git a/src/XMonad/Operations.hs b/src/XMonad/Operations.hs index 074f3be..32d0293 100644 --- a/src/XMonad/Operations.hs +++ b/src/XMonad/Operations.hs @@ -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 From ebce32d891eec4360d2ff394626eadf87841c2d2 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Tue, 14 Sep 2021 11:08:48 +0100 Subject: [PATCH 2/2] Minor cleanups of Solomon's PR --- CHANGES.md | 6 +++--- src/XMonad/Operations.hs | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5895343..e197442 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,9 +2,6 @@ ## 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. @@ -73,6 +70,9 @@ of processing messages in `broadcastMessage`. Previously, `runOnWorkspaces` processed the hidden workspaces first. + * Added `withUnfocused` function to `XMonad.Operations`, allowing for + `X` operations to be applied to unfocused windows. + ## 0.15 (September 30, 2018) * Reimplement `sendMessage` to deal properly with windowset changes made diff --git a/src/XMonad/Operations.hs b/src/XMonad/Operations.hs index 32d0293..f865ad1 100644 --- a/src/XMonad/Operations.hs +++ b/src/XMonad/Operations.hs @@ -18,10 +18,11 @@ module XMonad.Operations ( manage, unmanage, killWindow, kill, isClient, setInitialProperties, setWMState, setWindowBorderWithFallback, hide, reveal, tileWindow, - setTopFocus, focus, withFocused, + setTopFocus, focus, -- * Manage Windows - windows, refresh, rescreen, modifyWindowSet, windowBracket, windowBracket_, clearEvents, getCleanedScreenInfo, withUnfocused, + windows, refresh, rescreen, modifyWindowSet, windowBracket, windowBracket_, clearEvents, getCleanedScreenInfo, + withFocused, withUnfocused, -- * Keyboard and Mouse cleanMask, extraModifiers, @@ -481,7 +482,7 @@ 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. +-- | Apply an 'X' operation to all unfocused windows on the current workspace, if there are any. withUnfocused :: (Window -> X ()) -> X () withUnfocused f = withWindowSet $ \ws -> whenJust (W.peek ws) $ \w ->