xmonad/xmonad-contrib

Create a new CenterMainFluid layout

slotThe opened this issue · 1 comments

The LeftWM window manager has a layout called CenterMainFluid. It's akin to our XMonad.Layout.CenteredIfSingle in that it's best suited for ultrawide montiors, where a single stretched window might be annoying. Quoting from the LeftWM documentation, it works like so:

 1st               2nd
 stack     main    stack
+-----+-----------+-----+
|     |           |     |
|     |           +-----+
|     |           |     |
|     |           +-----+
|     |           |     |
+-----+-----------+-----+
  1st      main     2nd
 stack             stack

+-----+-----------+-----+
|     |           |.....|
|     |           |.....|  unoccupied
|     |           |.....|  space is
|     |           |.....|  reserved
|     |           |.....|
+-----+-----------+-----+
  1st      main
 stack

+-----+-----------+-----+
|.....|           |.....|
|.....|           |.....|  unoccupied
|.....|           |.....|  space is
|.....|           |.....|  reserved
|.....|           |.....|
+-----+-----------+-----+
           main

User archie-dev on Reddit already presents a minimal working example:

{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module CenterMain ( CenterMain (..) ) where

import XMonad hiding (tile)
import qualified XMonad.StackSet as W

data CenterMain a = CenterMain deriving (Show, Read)

instance LayoutClass CenterMain a where
    pureLayout CenterMain r s = layout
      where ws = W.integrate s
            rs = tile r (length ws)
            layout = zip ws rs

tile :: Rectangle -> Int -> [Rectangle]
tile r n = lefts ++ middle ++ rights
  where lefts  = [middleR]
        middle = [leftR]
        rights = splitVertically (n - 2) rightR
        [leftR,middleR,rightR] = splitHorizontally 3 r