import XMonad import XMonad.Hooks.ManageHelpers import qualified XMonad.StackSet as W import Monad import Data.Monoid (All (All)) main = xmonad $ defaultConfig {handleEventHook = evHook} -- Helper functions to fullscreen the window fullFloat, tileWin :: Window -> X () fullFloat w = windows $ W.float w r where r = W.RationalRect 0 0 1 1 tileWin w = windows $ W.sink w evHook :: Event -> X All evHook (ClientMessageEvent _ _ _ dpy win typ dat) = do state <- getAtom "_NET_WM_STATE" fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN" isFull <- runQuery isFullscreen win -- Constants for the _NET_WM_STATE protocol let remove = 0 add = 1 toggle = 2 -- The ATOM property type for changeProperty ptype = 4 action = head dat 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] fullFloat win when (head dat == remove || (action == toggle && isFull)) $ do io $ changeProperty32 dpy win state ptype propModeReplace [] tileWin win -- It shouldn't be necessary for xmonad to do anything more with this event return $ All False evHook _ = return $ All True