xmonad-contrib/XMonad/Layout/SimplestFloat.hs
Tony Zorman 3d65a6bf72 Refer to the tutorial instead of X.D.Extending more often
Essentially, whenever the tutorial actually has decent material on the
subject matter.  The replacement is roughly done as follows:

  - logHook → tutorial
  - keybindings → tutorial, as this is thoroughly covered
  - manageHook → tutorial + X.D.Extending, as the manageHook stuff the
    tutorial talks about is a little bit of an afterthought.
  - X.D.Extending (on its own) → tutorial + X.D.Extending
  - layoutHook → tutorial + X.D.Extending, as the tutorial, while
    talking about layouts, doesn't necessarily have a huge focus there.
  - mouse bindings → leave this alone, as the tutorial does not at all
    talk about them.
2022-10-21 09:17:43 +02:00

65 lines
2.2 KiB
Haskell

{-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses, TupleSections #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Layout.SimplestFloat
-- Description : Like "XMonad.Layout.SimpleFloat" but without the decoration.
-- Copyright : (c) 2008 Jussi Mäki
-- License : BSD-style (see xmonad/LICENSE)
--
-- Maintainer : joamaki@gmail.com
-- Stability : unstable
-- Portability : unportable
--
-- A basic floating layout like SimpleFloat but without the decoration.
-----------------------------------------------------------------------------
module XMonad.Layout.SimplestFloat
( -- * Usage:
-- $usage
simplestFloat
, SimplestFloat
) where
import XMonad.Prelude (fi)
import XMonad
import qualified XMonad.StackSet as S
import XMonad.Layout.WindowArranger
import XMonad.Layout.LayoutModifier
-- $usage
-- You can use this module with the following in your
-- @~\/.xmonad\/xmonad.hs@:
--
-- > import XMonad.Layout.SimplestFloat
--
-- Then edit your @layoutHook@ by adding the SimplestFloat layout:
--
-- > myLayout = simplestFloat ||| Full ||| etc..
-- > main = xmonad def { layoutHook = myLayout }
--
-- For more detailed instructions on editing the layoutHook see
-- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial> and
-- "XMonad.Doc.Extending#Editing_the_layout_hook".
-- | A simple floating layout where every window is placed according
-- to the window's initial attributes.
simplestFloat :: Eq a => (ModifiedLayout WindowArranger SimplestFloat) a
simplestFloat = windowArrangeAll SF
data SimplestFloat a = SF deriving (Show, Read)
instance LayoutClass SimplestFloat Window where
doLayout SF sc (S.Stack w l r) = (, Nothing)
<$> mapM (getSize sc) (w : reverse l ++ r)
description _ = "SimplestFloat"
getSize :: Rectangle -> Window -> X (Window,Rectangle)
getSize (Rectangle rx ry _ _) w = do
d <- asks display
bw <- asks (borderWidth . config)
wa <- io $ getWindowAttributes d w
let x = max rx $ fi $ wa_x wa
y = max ry $ fi $ wa_y wa
wh = fi (wa_width wa) + (bw * 2)
ht = fi (wa_height wa) + (bw * 2)
return (w, Rectangle x y wh ht)