    -----------------------------------------------------------------------------
    -- |
    -- Module      :  XMonad.Actions.NoBorders
    -- Copyright   :  (c) Lukas Mai
    -- License     :  BSD3-style (see LICENSE)
    --
    -- Maintainer  :  Lukas Mai <l.mai@web.de>
    -- Stability   :  stable
    -- Portability :  unportable
    --
    -- This module provides helper functions for dealing with window borders.
    --
    -----------------------------------------------------------------------------

    module XMonad.Actions.NoBorders (
        toggleBorder
    ) where

    import XMonad

    -- | Toggle the border of the currently focused window. To use it, add a
    -- keybinding like so:
    --
    -- > , ((modm,  xK_g ),   withFocused toggleBorder)
    --
    toggleBorder :: Window -> X ()
    toggleBorder :: Window -> X ()
    toggleBorder w :: Window
    w = do
        Dimension
    bw <- (XConf -> Dimension) -> X Dimension
    forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
    asks (XConfig Layout -> Dimension
    forall (l :: * -> *). XConfig l -> Dimension
    borderWidth (XConfig Layout -> Dimension)
    -> (XConf -> XConfig Layout) -> XConf -> Dimension
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . XConf -> XConfig Layout
    config)
        (Display -> X ()) -> X ()
    forall a. (Display -> X a) -> X a
    withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
    forall a b. (a -> b) -> a -> b
    $ \d :: Display
    d -> IO () -> X ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    io (IO () -> X ()) -> IO () -> X ()
    forall a b. (a -> b) -> a -> b
    $ do
            CInt
    cw <- WindowAttributes -> CInt
    wa_border_width (WindowAttributes -> CInt) -> IO WindowAttributes -> IO CInt
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    `fmap` Display -> Window -> IO WindowAttributes
    getWindowAttributes Display
    d Window
    w
            if CInt
    cw CInt -> CInt -> Bool
    forall a. Eq a => a -> a -> Bool
    == 0
                then Display -> Window -> Dimension -> IO ()
    setWindowBorderWidth Display
    d Window
    w Dimension
    bw
                else Display -> Window -> Dimension -> IO ()
    setWindowBorderWidth Display
    d Window
    w 0