From ec146171238b10eacc220bef3d6d2123ff27d3ad Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Tue, 23 Mar 2021 01:39:34 +0000 Subject: [PATCH] X.H.ManageDocks: React to strut updates of override_redirect docks We only requested PropertyChange events from docks in the `manageDocks` manageHook, but that only gets called for normal windows, not override_redirect ones. Therefore, xmobar in its default configuration wouldn't get its struts refreshed on changes. This resulted in gaps not updating after xmobar repositions itself on xrandr changes. If one wanted to handle that repositioning in xmonad, it was possible to configure xmobar with `overrideRedirect = False`, which is meant for window managers with proper EWMH stacking order support [1], so in xmonad it resulted in xmobar covering fullscreen windows. That can be worked around by adding `checkDock --> doLower` to manageHook, but it starts to smell of too many workarounds. [1]: https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#STACKINGORDER The fix is to request PropertyChange events for all windows that we treat as docks. Related: https://github.com/xmonad/xmonad-contrib/pull/490 --- CHANGES.md | 11 ++++++++++- XMonad/Hooks/ManageDocks.hs | 15 ++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index aea30232..8fcbc6b2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -343,7 +343,16 @@ - Export `AvoidStruts` constructor - Restored compatibility with pre-0.13 configs by making the startup hook - unnecessary for correct functioning. + unnecessary for correct functioning (strut cache is initialized on-demand). + + - Fixed ignoring of strut updates from override-redirect windows, which is + default for xmobar. + + Previously, if one wanted xmobar to reposition itself after xrandr + changes and have xmonad handle that repositioning, one would need to + configure xmobar with `overrideRedirect = False`, which would disable + lowering on start and thus cause other problems. This is no longer + necessary. * `XMonad.Hooks.ManageHelpers` diff --git a/XMonad/Hooks/ManageDocks.hs b/XMonad/Hooks/ManageDocks.hs index 3f64cba6..69a1dac6 100644 --- a/XMonad/Hooks/ManageDocks.hs +++ b/XMonad/Hooks/ManageDocks.hs @@ -130,17 +130,22 @@ maybeInitStrutCache = maybe (queryDocks >>= foldlM (flip updateStrut) M.empty) p updateStrut :: Window -> WindowStruts -> X WindowStruts updateStrut w cache = do + when (w `M.notMember` cache) $ requestDockEvents w strut <- getStrut w pure $ M.insert w strut cache -- | Detects if the given window is of type DOCK and if so, reveals -- it, but does not manage it. manageDocks :: ManageHook -manageDocks = checkDock --> (doIgnore <+> setDocksMask) - where setDocksMask = do - ask >>= \win -> liftX $ withDisplay $ \dpy -> - io $ selectInput dpy win (propertyChangeMask .|. structureNotifyMask) - mempty +manageDocks = checkDock --> (doIgnore <+> doRequestDockEvents) + where + doRequestDockEvents = ask >>= liftX . requestDockEvents >> mempty + +-- | Request events for a dock window. +-- (Only if not already a client to avoid overriding 'clientMask') +requestDockEvents :: Window -> X () +requestDockEvents w = whenX (not <$> isClient w) $ withDisplay $ \dpy -> + io $ selectInput dpy w (propertyChangeMask .|. structureNotifyMask) -- | Checks if a window is a DOCK or DESKTOP window checkDock :: Query Bool