From a3012eaa279caa7dd0489787edfa530ec35daea7 Mon Sep 17 00:00:00 2001 From: rayes Date: Sun, 30 Jan 2022 20:49:32 -0700 Subject: [PATCH 1/2] X.L.VoidBorders: Add ability to reset borders for certain layouts --- CHANGES.md | 6 +++++ XMonad/Layout/VoidBorders.hs | 43 +++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 88b359b7..69c1dfce 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -110,6 +110,12 @@ different X property) to communicate trayer resize events to XMobar so that padding space may be reserved on xmobar for the tray. Requires `xmobar` version 0.40 or higher. + +- `XMonad.Layout.VoidBorders` + + - Added new layout modifier `normalBorders` which can be used for + resetting borders back in layouts where you want borders after calling + `voidBorders`. ## 0.17.0 (October 27, 2021) diff --git a/XMonad/Layout/VoidBorders.hs b/XMonad/Layout/VoidBorders.hs index 02c8972c..b7454a8c 100644 --- a/XMonad/Layout/VoidBorders.hs +++ b/XMonad/Layout/VoidBorders.hs @@ -13,19 +13,18 @@ -- Portability : unportable -- -- Modifies a layout to set borders to 0 for all windows in the workspace. --- Unlike XMonad.Layout.NoBorders, this modifier will not restore the window --- border if the windows are moved to a different workspace or the layout is --- changed. +-- It can also restore the window border if the window is moved to a different +-- workspace or if the layout is changed. -- -- This modifier's primary use is to eliminate the "border flash" you get --- while switching workspaces with the `noBorders` modifier. It won't return --- the borders to their original width, however. +-- while switching workspaces with the `noBorders` modifier. -- ----------------------------------------------------------------------------- module XMonad.Layout.VoidBorders ( -- * Usage -- $usage voidBorders + , normalBorders ) where import XMonad @@ -39,9 +38,10 @@ import XMonad.StackSet (integrate) -- > import XMonad.Layout.VoidBorders -- -- and modify the layouts to call 'voidBorders' on the layouts you want to --- remove borders from windows: +-- remove borders from windows, and 'normalBorders' on the layouts you want +-- to keep borders for: -- --- > layoutHook = ... ||| voidBorders Full ||| ... +-- > layoutHook = ... ||| voidBorders Full ||| normalBorders Tall ... -- -- For more detailed instructions on editing the layoutHook see: -- @@ -49,9 +49,6 @@ import XMonad.StackSet (integrate) data VoidBorders a = VoidBorders deriving (Read, Show) -voidBorders :: l Window -> ModifiedLayout VoidBorders l Window -voidBorders = ModifiedLayout VoidBorders - instance LayoutModifier VoidBorders Window where modifierDescription = const "VoidBorders" @@ -60,6 +57,30 @@ instance LayoutModifier VoidBorders Window where mapM_ setZeroBorder $ integrate s return (wrs, Nothing) +voidBorders :: l Window -> ModifiedLayout VoidBorders l Window +voidBorders = ModifiedLayout VoidBorders + +data NormalBorders a = NormalBorders deriving (Read, Show) + +instance LayoutModifier NormalBorders Window where + modifierDescription = const "NormalBorders" + + redoLayout NormalBorders _ Nothing wrs = return (wrs, Nothing) + redoLayout NormalBorders _ (Just s) wrs = do + mapM_ resetBorders $ integrate s + return (wrs, Nothing) + +normalBorders :: l Window -> ModifiedLayout NormalBorders l Window +normalBorders = ModifiedLayout NormalBorders + -- | Sets border width to 0 for every window from the specified layout. setZeroBorder :: Window -> X () -setZeroBorder w = withDisplay $ \d -> io $ setWindowBorderWidth d w 0 +setZeroBorder w = setBorders w 0 + +-- | Resets the border to the value read from the current configuration. +resetBorders :: Window -> X () +resetBorders w = asks (borderWidth . config) >>= setBorders w + +setBorders :: Window -> Dimension -> X () +setBorders w bw = withDisplay $ \d -> io $ setWindowBorderWidth d w bw + From c4d718be9aae34ebc125939a88363eb73767ac48 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Tue, 1 Feb 2022 18:39:33 +0000 Subject: [PATCH 2/2] X.L.VoidBorders: Improve doc a bit --- CHANGES.md | 2 +- XMonad/Layout/VoidBorders.hs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 69c1dfce..7ecd6144 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -110,7 +110,7 @@ different X property) to communicate trayer resize events to XMobar so that padding space may be reserved on xmobar for the tray. Requires `xmobar` version 0.40 or higher. - + - `XMonad.Layout.VoidBorders` - Added new layout modifier `normalBorders` which can be used for diff --git a/XMonad/Layout/VoidBorders.hs b/XMonad/Layout/VoidBorders.hs index b7454a8c..680ad8ce 100644 --- a/XMonad/Layout/VoidBorders.hs +++ b/XMonad/Layout/VoidBorders.hs @@ -13,11 +13,14 @@ -- Portability : unportable -- -- Modifies a layout to set borders to 0 for all windows in the workspace. --- It can also restore the window border if the window is moved to a different --- workspace or if the layout is changed. +-- +-- Unlike "XMonad.Layout.NoBorders", the 'voidBorders' modifier will not +-- restore the window border if the windows are moved to a different workspace +-- or the layout is changed. There is, however, a companion 'normalBorders' +-- modifier which explicitly restores the border. -- -- This modifier's primary use is to eliminate the "border flash" you get --- while switching workspaces with the `noBorders` modifier. +-- while switching workspaces with the "XMonad.Layout.NoBorders" modifier. -- ----------------------------------------------------------------------------- @@ -83,4 +86,3 @@ resetBorders w = asks (borderWidth . config) >>= setBorders w setBorders :: Window -> Dimension -> X () setBorders w bw = withDisplay $ \d -> io $ setWindowBorderWidth d w bw -