Merge pull request #791 from pbrisbin/pb/desktop-viewport

Add EWMH configuration to not set _NET_DESKTOP_VIEWPORT
This commit is contained in:
Tony Zorman 2023-01-05 07:51:37 +01:00 committed by GitHub
commit 4e8857ecee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 4 deletions

View File

@ -144,6 +144,13 @@
- Fixed an issue where the bottom right window would not respond to - Fixed an issue where the bottom right window would not respond to
`MirrorShrink` and `MirrorExpand` messages. `MirrorShrink` and `MirrorExpand` messages.
* `XMonad.Hooks.EwmhDesktops`
- Added `disableEwmhManageDesktopViewport` to avoid setting the
`_NET_DESKTOP_VIEWPORT` property, as it can lead to issues with
some status bars (see this
[polybar issue](https://github.com/polybar/polybar/issues/2603)).
### Other changes ### Other changes
## 0.17.1 (September 3, 2022) ## 0.17.1 (September 3, 2022)

View File

@ -40,6 +40,10 @@ module XMonad.Hooks.EwmhDesktops (
-- $customActivate -- $customActivate
setEwmhActivateHook, setEwmhActivateHook,
-- ** @_NET_DESKTOP_VIEWPORT@
-- $customManageDesktopViewport
disableEwmhManageDesktopViewport,
-- * Standalone hooks (deprecated) -- * Standalone hooks (deprecated)
ewmhDesktopsStartup, ewmhDesktopsStartup,
ewmhDesktopsLogHook, ewmhDesktopsLogHook,
@ -102,6 +106,8 @@ data EwmhDesktopsConfig =
-- ^ configurable workspace rename (see 'XMonad.Hooks.StatusBar.PP.ppRename') -- ^ configurable workspace rename (see 'XMonad.Hooks.StatusBar.PP.ppRename')
, activateHook :: ManageHook , activateHook :: ManageHook
-- ^ configurable handling of window activation requests -- ^ configurable handling of window activation requests
, manageDesktopViewport :: Bool
-- ^ manage @_NET_DESKTOP_VIEWPORT@?
} }
instance Default EwmhDesktopsConfig where instance Default EwmhDesktopsConfig where
@ -109,6 +115,7 @@ instance Default EwmhDesktopsConfig where
{ workspaceSort = getSortByIndex { workspaceSort = getSortByIndex
, workspaceRename = pure pure , workspaceRename = pure pure
, activateHook = doFocus , activateHook = doFocus
, manageDesktopViewport = True
} }
@ -228,6 +235,26 @@ setEwmhWorkspaceRename f = XC.modifyDef $ \c -> c{ workspaceRename = f }
setEwmhActivateHook :: ManageHook -> XConfig l -> XConfig l setEwmhActivateHook :: ManageHook -> XConfig l -> XConfig l
setEwmhActivateHook h = XC.modifyDef $ \c -> c{ activateHook = h } setEwmhActivateHook h = XC.modifyDef $ \c -> c{ activateHook = h }
-- $customManageDesktopViewport
-- Setting @_NET_DESKTOP_VIEWPORT@ is typically desired but can lead to a
-- confusing workspace list in polybar, where this information is used to
-- re-group the workspaces by monitor. See
-- <https://github.com/polybar/polybar/issues/2603 polybar#2603>.
--
-- To avoid this, you can use:
--
-- > main = xmonad $ … . disableEwmhManageDesktopViewport . ewmh . … $ def{…}
--
-- Note that if you apply this configuration in an already running environment,
-- the property may remain at its previous value. It can be removed by running:
--
-- > xprop -root -remove _NET_DESKTOP_VIEWPORT
--
-- Which should immediately fix your bar.
--
disableEwmhManageDesktopViewport :: XConfig l -> XConfig l
disableEwmhManageDesktopViewport = XC.modifyDef $ \c -> c{ manageDesktopViewport = False }
-- | Initializes EwmhDesktops and advertises EWMH support to the X server. -- | Initializes EwmhDesktops and advertises EWMH support to the X server.
{-# DEPRECATED ewmhDesktopsStartup "Use ewmh instead." #-} {-# DEPRECATED ewmhDesktopsStartup "Use ewmh instead." #-}
@ -303,7 +330,7 @@ whenChanged :: (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged = whenX . XS.modified . const whenChanged = whenX . XS.modified . const
ewmhDesktopsLogHook' :: EwmhDesktopsConfig -> X () ewmhDesktopsLogHook' :: EwmhDesktopsConfig -> X ()
ewmhDesktopsLogHook' EwmhDesktopsConfig{workspaceSort, workspaceRename} = withWindowSet $ \s -> do ewmhDesktopsLogHook' EwmhDesktopsConfig{workspaceSort, workspaceRename, manageDesktopViewport} = withWindowSet $ \s -> do
sort' <- workspaceSort sort' <- workspaceSort
let ws = sort' $ W.workspaces s let ws = sort' $ W.workspaces s
@ -365,6 +392,7 @@ ewmhDesktopsLogHook' EwmhDesktopsConfig{workspaceSort, workspaceRename} = withWi
whenChanged (ActiveWindow activeWindow') $ setActiveWindow activeWindow' whenChanged (ActiveWindow activeWindow') $ setActiveWindow activeWindow'
-- Set desktop Viewport -- Set desktop Viewport
when manageDesktopViewport $ do
let visibleScreens = W.current s : W.visible s let visibleScreens = W.current s : W.visible s
currentTags = map (W.tag . W.workspace) visibleScreens currentTags = map (W.tag . W.workspace) visibleScreens
whenChanged (MonitorTags currentTags) $ mkViewPorts s (map W.tag ws) whenChanged (MonitorTags currentTags) $ mkViewPorts s (map W.tag ws)