一个xprop
对此类窗口的调用会在其_NET_WM_STATE
属性中显示这两个标志:
WM_STATE(WM_STATE):
window state: Normal
icon window: 0x0
_NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE, _NET_WM_STATE_STICKY
...
WM_NAME(UTF8_STRING) = "Picture in picture"
_NET_WM_NAME(UTF8_STRING) = "Picture in picture"
我们如何设置xmonad尊重这两面旗帜?
答案1
解决办法是:
- 使窗口标记为
_NET_WM_STATE_ABOVE
浮动。 - 将标记为 的窗口复制
_NET_WM_STATE_STICKY
到所有工作区。
import Data.Maybe ( fromMaybe )
import XMonad.Actions.CopyWindow ( copyToAll )
import XMonad.Util.WindowProperties ( getProp32 )
-- Other standard xmonad imports omitted.
myManageHook =
composeAll
$ [ hasNetWMState "_NET_WM_STATE_ABOVE" --> doFloat
, hasNetWMState "_NET_WM_STATE_STICKY" --> doF copyToAll
, ...
]
where
-- | Get the `_NET_WM_STATE` property as a list of atoms.
getNetWMState :: Window -> X [Atom]
getNetWMState w = do
atom <- getAtom "_NET_WM_STATE"
map fromIntegral . fromMaybe [] <$> getProp32 atom w
hasNetWMState :: String -> Query Bool
hasNetWMState state = do
window <- ask
wmstate <- liftX $ getNetWMState window
atom <- liftX $ getAtom state
return $ elem atom wmstate