EwmhDesktops: _NET_CLIENT_LIST_STACKING: In focus order

Order workspaces based on the visibility, before collecting windows.
`_NET_CLIENT_LIST_STACKING` is supposed to be in the focus order.
This commit is contained in:
Illia Bobyr 2022-10-28 22:15:17 -07:00
parent e0d1f177ea
commit cf975d082e
No known key found for this signature in database
GPG Key ID: 4D72E6A090EB3E9E
2 changed files with 35 additions and 4 deletions

View File

@ -55,6 +55,14 @@
- Deprecated the entire module, use `XMonad.Actions.WithAll` - Deprecated the entire module, use `XMonad.Actions.WithAll`
instead. instead.
* `XMonad.Hooks.EwmhDesktops`
- `_NET_CLIENT_LIST_STACKING` puts windows in the current workspace at the
top in bottom-to-top order, followed by visible workspaces, followed by
invisible workspaces. Within visible and invisible groups, workspaces are
ordered lexicographically, as before. Currently focused window will
always be the topmost, meaning the last in the list.
### New Modules ### New Modules
* `XMonad.Hooks.OnPropertyChange`: * `XMonad.Hooks.OnPropertyChange`:

View File

@ -320,10 +320,33 @@ ewmhDesktopsLogHook' EwmhDesktopsConfig{workspaceSort, workspaceRename} = withWi
let clientList = nub . concatMap (W.integrate' . W.stack) $ ws let clientList = nub . concatMap (W.integrate' . W.stack) $ ws
whenChanged (ClientList clientList) $ setClientList clientList whenChanged (ClientList clientList) $ setClientList clientList
-- Set stacking client list which should have bottom-to-top -- @ws@ is sorted in the "workspace order", which, by default, is
-- stacking order, i.e. focused window should be last -- the lexicographical sorting on @WorkspaceId@.
let clientListStacking = nub . concatMap (maybe [] (\(W.Stack x l r) -> reverse l ++ r ++ [x]) . W.stack) $ ws -- @_NET_CLIENT_LIST_STACKING@ is expected to be in the "bottom-to-top
whenChanged (ClientListStacking clientListStacking) $ setClientListStacking clientListStacking -- stacking order". It is unclear what that would mean for windows on
-- invisible workspaces, but it seems reasonable to assume that windows on
-- the current workspace should be "at the top". With the focused window to
-- be the top most, meaning the last.
--
-- There has been a number of discussions on the order of windows within a
-- workspace. See:
--
-- https://github.com/xmonad/xmonad-contrib/issues/567
-- https://github.com/xmonad/xmonad-contrib/pull/568
-- https://github.com/xmonad/xmonad-contrib/pull/772
let clientListStacking =
let wsInFocusOrder = W.hidden s
++ (map W.workspace . W.visible) s
++ [W.workspace $ W.current s]
stackWindows (W.Stack cur up down) = reverse up ++ down ++ [cur]
workspaceWindows = maybe [] stackWindows . W.stack
-- In case a window is a member of multiple workspaces, we keep
-- only the last occurrence in the list. One that is closer to
-- the top in the focus order.
uniqueKeepLast = reverse . nub . reverse
in uniqueKeepLast $ concatMap workspaceWindows wsInFocusOrder
whenChanged (ClientListStacking clientListStacking) $
setClientListStacking clientListStacking
-- Set current desktop number -- Set current desktop number
let current = W.currentTag s `elemIndex` map W.tag ws let current = W.currentTag s `elemIndex` map W.tag ws