From d48e7a09bb12ade68ed7dc4616210be94b77ed28 Mon Sep 17 00:00:00 2001 From: audunskaugen Date: Mon, 14 Dec 2009 14:51:19 +0100 Subject: Add support for fullscreen through the _NET_WM_STATE protocol Ignore-this: 430ca3c6779e36383f8ce8e477ee9622 This patch adds support for applications using the gtk_window_fullscreen function, and other applications using _NET_WM_STATE for the same purpose. darcs-hash:20091214135119-c4ed7-074a3df86fd22b8b0002c1020a5a94f89d8f597c.gz --- XMonad/Hooks/EwmhDesktops.hs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'XMonad') diff --git a/XMonad/Hooks/EwmhDesktops.hs b/XMonad/Hooks/EwmhDesktops.hs index a0f70b3..a82e449 100644 --- a/XMonad/Hooks/EwmhDesktops.hs +++ b/XMonad/Hooks/EwmhDesktops.hs @@ -19,7 +19,8 @@ module XMonad.Hooks.EwmhDesktops ( ewmhDesktopsStartup, ewmhDesktopsLogHook, ewmhDesktopsLogHookCustom, - ewmhDesktopsEventHook + ewmhDesktopsEventHook, + fullscreenEventHook ) where import Codec.Binary.UTF8.String (encode) @@ -34,6 +35,7 @@ import qualified XMonad.StackSet as W import XMonad.Hooks.SetWMName import XMonad.Util.XUtils (fi) import XMonad.Util.WorkspaceCompare +import XMonad.Util.WindowProperties (getProp32) -- $usage -- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: @@ -154,6 +156,39 @@ handle ClientMessageEvent { return () handle _ = return () +-- | +-- An event hook to handle applications that wish to fullscreen using the +-- _NET_WM_STATE protocol. This includes users of the gtk_window_fullscreen() +-- function, such as Totem, Evince and OpenOffice.org. +fullscreenEventHook :: Event -> X All +fullscreenEventHook (ClientMessageEvent _ _ _ dpy win typ dat) = do + state <- getAtom "_NET_WM_STATE" + fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN" + wstate' <- getProp32 state win + let wstate = case wstate' of + Just ps -> ps + Nothing -> [] + isFull = fromIntegral fullsc `elem` wstate + + -- Constants for the _NET_WM_STATE protocol: + remove = 0 + add = 1 + toggle = 2 + + action = head dat + ptype = 4 -- The atom property type for changeProperty + + when (typ == state && fromIntegral fullsc `elem` tail dat) $ do + when (action == add || (action == toggle && not isFull)) $ do + io $ changeProperty32 dpy win state ptype propModeReplace (fromIntegral fullsc:wstate) + windows $ W.float win $ W.RationalRect 0 0 1 1 + when (action == remove || (action == toggle && isFull)) $ do + io $ changeProperty32 dpy win state ptype propModeReplace (delete (fromIntegral fullsc) wstate) + windows $ W.sink win + + return $ All True + +fullscreenEventHook _ = return $ All True setNumberOfDesktops :: (Integral a) => a -> X () setNumberOfDesktops n = withDisplay $ \dpy -> do -- cgit v1.2.3