X.H.EwmhDesktops: optionally advertise fullscreen support in _NET_SUPPORTED

Provide a way to advertise _NET_WM_STATE_FULLSCREEN in _NET_SUPPORTED.
I had this hardcoded for a while but read the mpv manpage recently:

    Specifically, yes will force use of NetWM fullscreen support, even
    if not advertised by the WM. This can be useful for WMs that are
    broken on purpose, like XMonad. (XMonad supposedly doesn't advertise
    fullscreen support, because Flash uses it. Apparently, applications
    which want to use fullscreen anyway are supposed to either ignore
    the NetWM support hints, or provide a workaround. Shame on XMonad
    for deliberately breaking X protocols (as if X isn't bad enough
    already).

I'm not sure Flash is still a good reason these days to not advertise
fullscreen support yet still handle it and look like idiots while doing
so. (And if anyone thinks it is a good reason, their unchanged xmonad
config will continue behaving that way.)
This commit is contained in:
Tomas Janousek 2016-10-30 00:49:39 +02:00
parent dc2b96d575
commit 7bf8544f1c
2 changed files with 49 additions and 8 deletions

View File

@ -4,6 +4,13 @@
### Breaking Changes
* `XMonad.Hooks.EwmhDesktops`
It is no longer recommended to use `fullscreenEventHook` directly.
Instead, use `ewmhFullscreen` which additionally advertises fullscreen
support in `_NET_SUPPORTED` and fixes fullscreening of applications that
explicitly check it, e.g. mupdf-gl, sxiv, …
### New Modules
* `XMonad.Layout.TallMastersCombo`

View File

@ -21,7 +21,9 @@ module XMonad.Hooks.EwmhDesktops (
ewmhDesktopsLogHookCustom,
ewmhDesktopsEventHook,
ewmhDesktopsEventHookCustom,
fullscreenEventHook
ewmhFullscreen,
fullscreenEventHook,
fullscreenStartup
) where
import Codec.Binary.UTF8.String (encode)
@ -47,19 +49,20 @@ import XMonad.Util.WindowProperties (getProp32)
-- > import XMonad
-- > import XMonad.Hooks.EwmhDesktops
-- >
-- > main = xmonad $ ewmh def{ handleEventHook =
-- > handleEventHook def <+> fullscreenEventHook }
-- > main = xmonad $ ewmhFullscreen $ ewmh def
--
-- or, if fullscreen handling is not desired, just
--
-- > main = xmonad $ ewmh def
--
-- You may also be interested in 'docks' from "XMonad.Hooks.ManageDocks".
-- | Add EWMH functionality to the given config. See above for an example.
ewmh :: XConfig a -> XConfig a
ewmh c = c { startupHook = startupHook c +++ ewmhDesktopsStartup
, handleEventHook = handleEventHook c +++ ewmhDesktopsEventHook
, logHook = logHook c +++ ewmhDesktopsLogHook }
-- @@@ will fix this correctly later with the rewrite
where x +++ y = mappend y x
ewmh c = c { startupHook = ewmhDesktopsStartup <+> startupHook c
, handleEventHook = ewmhDesktopsEventHook <+> handleEventHook c
, logHook = ewmhDesktopsLogHook <+> logHook c }
-- |
-- Initializes EwmhDesktops and advertises EWMH support to the X
@ -213,6 +216,23 @@ handle f (ClientMessageEvent {
return ()
handle _ _ = return ()
-- | Add EWMH fullscreen functionality to the given config.
--
-- This must be applied after 'ewmh', like so:
--
-- > main = xmonad $ ewmhFullscreen $ ewmh def
--
-- NOT:
--
-- > main = xmonad $ ewmh $ ewmhFullscreen def
ewmhFullscreen :: XConfig a -> XConfig a
ewmhFullscreen c = c { startupHook = startupHook c <+> fullscreenStartup
, handleEventHook = handleEventHook c <+> fullscreenEventHook }
-- | Advertises EWMH fullscreen support to the X server.
fullscreenStartup :: X ()
fullscreenStartup = setFullscreenSupported
-- |
-- An event hook to handle applications that wish to fullscreen using the
-- _NET_WM_STATE protocol. This includes users of the gtk_window_fullscreen()
@ -298,6 +318,20 @@ setSupported = withDisplay $ \dpy -> do
setWMName "xmonad"
-- TODO: use in SetWMName, UrgencyHook
addSupported :: [String] -> X ()
addSupported props = withDisplay $ \dpy -> do
r <- asks theRoot
a <- getAtom "_NET_SUPPORTED"
fs <- getAtom "_NET_WM_STATE_FULLSCREEN"
newSupportedList <- mapM (fmap fromIntegral . getAtom) props
io $ do
supportedList <- fmap (join . maybeToList) $ getWindowProperty32 dpy a r
changeProperty32 dpy r a aTOM propModeReplace (nub $ newSupportedList ++ supportedList)
setFullscreenSupported :: X ()
setFullscreenSupported = addSupported ["_NET_WM_STATE", "_NET_WM_STATE_FULLSCREEN"]
setActiveWindow :: Window -> X ()
setActiveWindow w = withDisplay $ \dpy -> do
r <- asks theRoot