xmonad-contrib/XMonad/Layout/VoidBorders.hs
Wilson Sales 5fd8ff86e9
add XMonad.Layout.VoidBorders
This module contains a modifier that simply sets X11 window border width
to 0 for every window in the layout it modifies. No efforts are made to
bring the border back, which can be annoying if windows are moved to a
different workspace, but it prevents the "border flash" you get with
XMonad.Layout.NoBorders.
2020-10-17 00:08:40 -03:00

65 lines
2.2 KiB
Haskell

{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Layout.VoidBorders
-- Copyright : Wilson Sales <spoonm@spoonm.org>
-- License : BSD-style (see LICENSE)
--
-- Maintainer : <spoonm@spoonm.org>
-- Stability : unstable
-- Portability : unportable
--
-- Modifies a layout to set borders to 0 for all windows in the workspace.
-- Unlike XMonad.Layout.NoBorders, this modifier will not restore the window
-- border if the windows are moved to a different workspace or the layout is
-- changed.
--
-- This modifier's primary use is to eliminate the "border flash" you get
-- while switching workspaces with the `noBorders` modifier. It won't return
-- the borders to their original width, however.
--
-----------------------------------------------------------------------------
module XMonad.Layout.VoidBorders ( -- * Usage
-- $usage
voidBorders
) where
import XMonad
import XMonad.Layout.LayoutModifier
import XMonad.StackSet (integrate)
-- $usage
-- You can use this module with the following in your ~\/.xmonad/xmonad.hs
-- file:
--
-- > import XMonad.Layout.VoidBorders
--
-- and modify the layouts to call 'voidBorders' on the layouts you want to
-- remove borders from windows:
--
-- > layoutHook = ... ||| voidBorders Full ||| ...
--
-- For more detailed instructions on editing the layoutHook see:
--
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
data VoidBorders a = VoidBorders deriving (Read, Show)
voidBorders :: l Window -> ModifiedLayout VoidBorders l Window
voidBorders = ModifiedLayout VoidBorders
instance LayoutModifier VoidBorders Window where
modifierDescription = const "VoidBorders"
redoLayout VoidBorders _ Nothing wrs = return (wrs, Nothing)
redoLayout VoidBorders _ (Just s) wrs = do
mapM_ setZeroBorder $ integrate s
return (wrs, Nothing)
-- | Sets border width to 0 for every window from the specified layout.
setZeroBorder :: Window -> X ()
setZeroBorder w = withDisplay $ \d -> io $ setWindowBorderWidth d w 0