Merge pull request #568 from kurnevsky/ewmh-windows-ordering

Change EWMH windows ordering to be closer to the spec

Fixes: #567
This commit is contained in:
slotThe 2021-07-14 19:36:34 +02:00 committed by GitHub
commit da2fb360b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 5 deletions

View File

@ -48,6 +48,10 @@
`activateLogHook` to your `logHook`. Also, module `X.H.Focus` provides `activateLogHook` to your `logHook`. Also, module `X.H.Focus` provides
additional combinators. additional combinators.
- Ordering of windows that are set to `_NET_CLIENT_LIST` and `_NET_CLIENT_LIST_STACKING`
was changed to be closer to the spec. From now these two lists will have
differently sorted windows.
* All modules still exporting a `defaultFoo` constructor * All modules still exporting a `defaultFoo` constructor
- All of these were now removed. You can use the re-exported `def` from - All of these were now removed. You can use the re-exported `def` from

View File

@ -123,6 +123,14 @@ newtype ClientList = ClientList [Window]
instance ExtensionClass ClientList where instance ExtensionClass ClientList where
initialValue = ClientList [none] initialValue = ClientList [none]
-- |
-- Cached stacking client list (e.g. @_NET_CLIENT_LIST_STACKING@).
newtype ClientListStacking = ClientListStacking [Window]
deriving Eq
instance ExtensionClass ClientListStacking where
initialValue = ClientListStacking [none]
-- | -- |
-- Cached current desktop (e.g. @_NET_CURRENT_DESKTOP@). -- Cached current desktop (e.g. @_NET_CURRENT_DESKTOP@).
newtype CurrentDesktop = CurrentDesktop Int newtype CurrentDesktop = CurrentDesktop Int
@ -171,10 +179,17 @@ ewmhDesktopsLogHookCustom t = withWindowSet $ \s -> do
setNumberOfDesktops (length desktopNames) setNumberOfDesktops (length desktopNames)
setDesktopNames desktopNames setDesktopNames desktopNames
-- Set client list; all windows, with focused windows last -- Set client list which should be sorted by window age. We just
let clientList = nub . concatMap (maybe [] (\(W.Stack x l r) -> reverse l ++ r ++ [x]) . W.stack) $ ws -- guess that StackSet contains windows list in this order which
-- isn't true but at least gives consistency with windows cycling
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
-- stacking order, i.e. focused window should be last
let clientListStacking = nub . concatMap (maybe [] (\(W.Stack x l r) -> reverse l ++ r ++ [x]) . W.stack) $ ws
whenChanged (ClientListStacking clientListStacking) $ setClientListStacking clientListStacking
-- Remap the current workspace to handle any renames that f might be doing. -- Remap the current workspace to handle any renames that f might be doing.
let maybeCurrent' = W.tag <$> listToMaybe (t [W.workspace $ W.current s]) let maybeCurrent' = W.tag <$> listToMaybe (t [W.workspace $ W.current s])
current = flip elemIndex (map W.tag ws) =<< maybeCurrent' current = flip elemIndex (map W.tag ws) =<< maybeCurrent'
@ -354,12 +369,15 @@ setDesktopNames names = withDisplay $ \dpy -> do
setClientList :: [Window] -> X () setClientList :: [Window] -> X ()
setClientList wins = withDisplay $ \dpy -> do setClientList wins = withDisplay $ \dpy -> do
-- (What order do we really need? Something about age and stacking)
r <- asks theRoot r <- asks theRoot
a <- getAtom "_NET_CLIENT_LIST" a <- getAtom "_NET_CLIENT_LIST"
io $ changeProperty32 dpy r a wINDOW propModeReplace (fmap fromIntegral wins) io $ changeProperty32 dpy r a wINDOW propModeReplace (fmap fromIntegral wins)
a' <- getAtom "_NET_CLIENT_LIST_STACKING"
io $ changeProperty32 dpy r a' wINDOW propModeReplace (fmap fromIntegral wins) setClientListStacking :: [Window] -> X ()
setClientListStacking wins = withDisplay $ \dpy -> do
r <- asks theRoot
a <- getAtom "_NET_CLIENT_LIST_STACKING"
io $ changeProperty32 dpy r a wINDOW propModeReplace (fmap fromIntegral wins)
setWindowDesktop :: (Integral a) => Window -> a -> X () setWindowDesktop :: (Integral a) => Window -> a -> X ()
setWindowDesktop win i = withDisplay $ \dpy -> do setWindowDesktop win i = withDisplay $ \dpy -> do