[Xmonad] Configurable tiling algos

David Roundy droundy at darcs.net
Wed May 2 21:57:37 EDT 2007


On Thu, May 03, 2007 at 11:41:18AM +1000, Donald Bruce Stewart wrote:
> Regarding configurable tiling, a simple strategy would be to have 
> user-specified tiling functions available from Config.hs, of the type
> 
>     tile :: Rational -> Rectangle -> [Window] -> [(Window, Rectangle)]
>     type Tiler =Rational -> Rectangle -> [Window] -> [(Window, Rectangle)]
> 
> so,
> 
>     myTile :: [Tiler]
>     myTile = [someTileAlgo
>              ,someOtherAlgo
>              ]
> 
> These functions are then added to the list of algos to cycle through in
> mod-space, and would allow custom pure functions.
> 
> David, I suspect you actually want 'tile' to live in X, so you can do
> window name lookups and so on?

Possibly.  I'd actually probably prefer passing in something like
[(ExtraWindowInformation,Windowj)] instead of just [Window].  The downside
would be that we'd have to get the ExtraWindowInformation (title, class,
etc) whether we need it or not, but I suspect that wouldn't cause too much
trouble.  Or perhaps we'd want to define a new data type:

data PureWindow = PureWindow { thewindow :: Window
                             , thename :: String
                             , ... }

It's a little annoying (to me, anyhow) that the Eq instance of Window
sometimes returns true between an old closed window and a newly opened
window, so creating a new data type that doesn't have that issue might be
handy.

But my first and primary objection is that you've constrained all tiling
algorithms to have at most one Rational of user-configurable data.  To
quote an early version of my extensible layout patch, I'd prefer something
more like this as a starting point

+data Layout = Layout { doLayout :: Rectangle -> [Window] -> [(Window, Rectangle)]
+                     , modifyLayout :: String -> Maybe Layout }

This allows each layout to have an arbitrary amount of user-configured data
which can be configured at runtime.  See my mosaic module for a layout in
which the prefered size and aspect ratio of each window may be individually
tailored (although I didn't implement arbitrary aspect ratios for each
windows, it's either square or all the same configurable value).

Then the available layouts are a [Layout] as in your case.

The key is in the modifyLayout method, which allows you to pass new data to
the layout (e.g. changing a window size or something).



With mutual recursion (yuck), we'd probably want:

data Layout = Layout { doLayout :: Rectangle -> [Window] -> [(Window, Rectangle)]
                     , modifyLayout :: LayoutMessage -> Maybe Layout }

where LayoutMessage is defined in Config.  But I really hate mutual
recursion.  Not that I have much experience with it, since I never use
it...
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Xmonad mailing list