Last active
June 2, 2016 17:25
-
-
Save aplaice/51137da641abdbe33139 to your computer and use it in GitHub Desktop.
Enable firefox fullscreen within tile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- BSD | |
module MyEventHook (fullscreenEventHook') where | |
import Data.List | |
import Data.Maybe | |
import Data.Monoid | |
import XMonad | |
import Control.Monad | |
import XMonad.Util.XUtils (fi) | |
import XMonad.Util.WindowProperties (getProp32) | |
-- heavily based on | |
-- XMonad.Hooks.EwmhDesktops | |
fullscreenEventHook' :: Event -> X All | |
fullscreenEventHook' (ClientMessageEvent _ _ _ dpy win typ (action:dats)) = do | |
wmstate <- getAtom "_NET_WM_STATE" | |
fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN" | |
wstate <- fromMaybe [] `fmap` getProp32 wmstate win | |
let isFull = fromIntegral fullsc `elem` wstate | |
-- Constants for the _NET_WM_STATE protocol: | |
remove = 0 | |
add = 1 | |
toggle = 2 | |
ptype = 4 -- The atom property type for changeProperty | |
chWstate f = io $ changeProperty32 dpy win wmstate ptype propModeReplace (f wstate) | |
when (typ == wmstate && fi fullsc `elem` dats) $ do | |
when (action == add || (action == toggle && not isFull)) $ do | |
chWstate (fi fullsc:) | |
when (action == remove || (action == toggle && isFull)) $ do | |
chWstate $ filter (/= (fi fullsc )) -- have to delete all instances, as firefox adds additional "_NET_WM_STATE_FULLSCREEN" atoms every time you switch workspaces | |
return $ All True | |
fullscreenEventHook' _ = return $ All True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enables firefox fullscreen within tile (i.e. upon pressing , the URL bar and tabs hide, but firefox stays within its tile and does not go into the floating layer or take up the entire screen). The code is not firefox-specific, but simply tries to route around firefox's bug #1189622. As far as I'm aware it does not cause issues with other applications.
Snippet heavily based on
fullScreenEventHook
fromXMonad.Hooks.EwmhDesktops
— only two lines were removed from the function definition and one was changed.To use:
~/.xmonad/lib/
and addimport MyEventHook
to youxmonad.hs
OR copy-paste the code (without themodule...
line) directly into yourxmonad.hs
fullscreenEventHook'
to yourhandleEventHook
.