From fe826ca8db5543c496c6645d8390554cb9f9d126 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Sat, 23 Nov 2024 14:44:29 +0000 Subject: [PATCH] X.L.NoBorders: Listen to DestroyWindowEvents and garbage collect Previously, it was necessary to use `borderEventHook` to make sure the `alwaysHidden`/`neverHidden` lists are garbage collected when a window is destroyed, but this was largely undocumented. Since xmonad v0.17.0, the DestroyWindowEvent is broadcast to layouts, so we can just use that instead and deprecate the event hook. --- CHANGES.md | 7 +++++++ XMonad/Layout/NoBorders.hs | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1c9d8dfd2..16c903bd1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,13 @@ used to avoid flicker and unnecessary workspace reshuffling if multiple `xrandr` commands are used to reconfigure the display layout. + * `XMonad.Layout.NoBorders` + + - It's no longer necessary to use `borderEventHook` to garbage collect + `alwaysHidden`/`neverHidden` lists. The layout listens to + `DestroyWindowEvent` messages instead, which are broadcast to layouts + since xmonad v0.17.0. + ## 0.18.1 (August 20, 2024) ### Breaking Changes diff --git a/XMonad/Layout/NoBorders.hs b/XMonad/Layout/NoBorders.hs index a333bd714..6262d0350 100644 --- a/XMonad/Layout/NoBorders.hs +++ b/XMonad/Layout/NoBorders.hs @@ -143,10 +143,8 @@ data ConfigurableBorder p w = ConfigurableBorder -- | Only necessary with 'BorderMessage' - remove non-existent windows from the -- 'alwaysHidden' or 'neverHidden' lists. +{-# DEPRECATED borderEventHook "No longer needed." #-} borderEventHook :: Event -> X All -borderEventHook DestroyWindowEvent{ ev_window = w } = do - broadcastMessage $ ResetBorder w - return $ All True borderEventHook _ = return $ All True instance (Read p, Show p, SetsAmbiguous p) => LayoutModifier (ConfigurableBorder p) Window where @@ -167,14 +165,17 @@ instance (Read p, Show p, SetsAmbiguous p) => LayoutModifier (ConfigurableBorder in ConfigurableBorder gh <$> consNewIf ah (not b) <*> consNewIf nh b <*> pure ch - | Just (ResetBorder w) <- fromMessage m = + | Just (ResetBorder w) <- fromMessage m = resetBorder w + | Just DestroyWindowEvent { ev_window = w } <- fromMessage m = resetBorder w + | otherwise = Nothing + where + resetBorder w = let delete' e l = if e `elem` l then (True,delete e l) else (False,l) (da,ah') = delete' w ah (dn,nh') = delete' w nh in if da || dn then Just cb { alwaysHidden = ah', neverHidden = nh' } else Nothing - | otherwise = Nothing -- | SetsAmbiguous allows custom actions to generate lists of windows that -- should not have borders drawn through 'ConfigurableBorder'