aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraudunskaugen <audunskaugen@gmail.com>2009-12-14 14:51:19 +0100
committeraudunskaugen <audunskaugen@gmail.com>2009-12-14 14:51:19 +0100
commitd48e7a09bb12ade68ed7dc4616210be94b77ed28 (patch)
treeae5d87d969c750b8693fa1a2608c098a467e9944
parent7c6a058ae4814151a245b2c8a786caa5b3b307b4 (diff)
downloadXMonadContrib-d48e7a09bb12ade68ed7dc4616210be94b77ed28.tar.gz
XMonadContrib-d48e7a09bb12ade68ed7dc4616210be94b77ed28.tar.xz
XMonadContrib-d48e7a09bb12ade68ed7dc4616210be94b77ed28.zip
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
-rw-r--r--XMonad/Hooks/EwmhDesktops.hs37
1 files changed, 36 insertions, 1 deletions
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