Merge pull request #914 from liskin/noborders-resetborder

X.L.NoBorders: Listen to DestroyWindowEvents and garbage collect
This commit is contained in:
Tony Zorman 2024-11-24 10:51:25 +01:00 committed by GitHub
commit 0dc879698d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -24,6 +24,13 @@
used to avoid flicker and unnecessary workspace reshuffling if multiple used to avoid flicker and unnecessary workspace reshuffling if multiple
`xrandr` commands are used to reconfigure the display layout. `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) ## 0.18.1 (August 20, 2024)
### Breaking Changes ### Breaking Changes

View File

@ -143,10 +143,8 @@ data ConfigurableBorder p w = ConfigurableBorder
-- | Only necessary with 'BorderMessage' - remove non-existent windows from the -- | Only necessary with 'BorderMessage' - remove non-existent windows from the
-- 'alwaysHidden' or 'neverHidden' lists. -- 'alwaysHidden' or 'neverHidden' lists.
{-# DEPRECATED borderEventHook "No longer needed." #-}
borderEventHook :: Event -> X All borderEventHook :: Event -> X All
borderEventHook DestroyWindowEvent{ ev_window = w } = do
broadcastMessage $ ResetBorder w
return $ All True
borderEventHook _ = return $ All True borderEventHook _ = return $ All True
instance (Read p, Show p, SetsAmbiguous p) => LayoutModifier (ConfigurableBorder p) Window where 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) in ConfigurableBorder gh <$> consNewIf ah (not b)
<*> consNewIf nh b <*> consNewIf nh b
<*> pure ch <*> 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) let delete' e l = if e `elem` l then (True,delete e l) else (False,l)
(da,ah') = delete' w ah (da,ah') = delete' w ah
(dn,nh') = delete' w nh (dn,nh') = delete' w nh
in if da || dn in if da || dn
then Just cb { alwaysHidden = ah', neverHidden = nh' } then Just cb { alwaysHidden = ah', neverHidden = nh' }
else Nothing else Nothing
| otherwise = Nothing
-- | SetsAmbiguous allows custom actions to generate lists of windows that -- | SetsAmbiguous allows custom actions to generate lists of windows that
-- should not have borders drawn through 'ConfigurableBorder' -- should not have borders drawn through 'ConfigurableBorder'