diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-07-06 19:34:57 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-07-06 19:34:57 +0200 |
commit | fc9abd6f6f6f90f5a9beaca3ca647d45dab2240f (patch) | |
tree | 08170343d1e953ef7a395087e547d80402d59481 /dotfiles/xmonad.hs | |
parent | Xmonad: Add ewmh support (diff) | |
download | nixos-config-fc9abd6f6f6f90f5a9beaca3ca647d45dab2240f.tar.gz nixos-config-fc9abd6f6f6f90f5a9beaca3ca647d45dab2240f.tar.bz2 nixos-config-fc9abd6f6f6f90f5a9beaca3ca647d45dab2240f.zip |
XMonad: Add proper fullscreen capabilities
On toggling fullscreen we hide xmobar, hide borders, set fullscreen and set the _NET_WM_STATE_FULLSCREEN window prop for programs such as firefox to adjust acoordingly to fullscreen mode
Diffstat (limited to 'dotfiles/xmonad.hs')
-rw-r--r-- | dotfiles/xmonad.hs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/dotfiles/xmonad.hs b/dotfiles/xmonad.hs index e5e16ab..95f36a2 100644 --- a/dotfiles/xmonad.hs +++ b/dotfiles/xmonad.hs @@ -106,8 +106,7 @@ tiledLayout = renamed [Replace "[]"] $ tiled layouts = tiledLayout -myLayout = smartBorders - $ mkToggle (NOBORDERS ?? FULL ?? EOT) +myLayout = mkToggle (NOBORDERS ?? NBFULL ?? EOT) $ avoidStruts $ myGaps $ addSpace $ layouts @@ -120,6 +119,27 @@ myBorderWidth = 1 myNormalBorderColor = "#000000" myFocusedBorderColor = "#005577" +--This sets the "_NET_WM_STATE_FULLSCREEN" window property, helping some programs such as firefox to adjust acoordingly to fullscreen mode +--In a perfect world we shouldnt need to do this manually but it seems like ewmhFullscreen/others dont implement this functionality +setFullscreenProp :: Bool -> Window -> X () +setFullscreenProp b win = withDisplay $ \dpy -> do + state <- getAtom "_NET_WM_STATE" + fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN" + if b + then io $ changeProperty32 dpy win state 4 propModeReplace [fromIntegral fullsc] + else io $ changeProperty32 dpy win state 4 propModeReplace [] + +--Hide xmobar -> Hide borders -> Set fullscreen -> Set fullscreenprops +toggleFullScreen :: X() +toggleFullScreen = do + mIsFullScreen <- withWindowSet (isToggleActive NBFULL . W.workspace . W.current) + case mIsFullScreen of + Just isFullScreen -> if isFullScreen + then withFocused (setFullscreenProp False) >> sendMessage (Toggle NBFULL) >> sendMessage ToggleStruts + else sendMessage ToggleStruts >> sendMessage (Toggle NBFULL) >> withFocused (setFullscreenProp True) + Nothing -> return () + + ------------------------------------------------------------------------ -- External commands myCommands :: [(String, X ())] @@ -134,7 +154,7 @@ myCommands = , ("swap-with-prev" , windows W.swapUp ) , ("swap-with-next" , windows W.swapDown ) , ("swap-with-master" , windows W.swapMaster ) - , ("togglefullscreen" , sendMessage $ Toggle FULL ) + , ("togglefullscreen" , toggleFullScreen ) , ("togglefloating" , withFocused toggleFloat ) , ("next-layout" , sendMessage NextLayout ) , ("cycle-workspace" , toggleWS ) |