The idea of having more than one master window is brilliant. The `tile' layout in current hg tip basically splits the master and slave areas vertically, and tiles windows in each of the two areas using a vertical stacking algorithm. The `ncol' layout does it slightly differently by tilling the master windows using a horizontal stacking algorithm. The `n?bstack' layout also does it slightly differently, by splitting the master and slave areas horizontally, and tiles windows in each of them using a horizontal stacking algorithm.
All of these layouts fit in a generalized model. Basically, there're two things that differentiate one master-slave layout from another: 1. How the master and slave areas are separated. Practically, the most useful way to do this is simply split the screen in two parts, either vertically, or horizontally. 2. What layout is used in each of the master and slave areas. We can use different layouts for the masters and the slaves. We should reuse the layout algorithms when we can. With this model in mind, I came up with the function apply_mslts(), i.e. "apply master-slave layouts", which takes care of the two things stated above. The actual layout algorithms are defined in the lt_* functions: lt_hstack tiles windows in a horizontal stack, i.e. columns. lt_vstack tiles windows in a vertical stack, i.e. rows. lt_grid tiles windows in a (gapless) grid. lt_monocle stacks windows, each maximized to fill the "booth". The "booth" is the box in which the layout is performed. Such functions are simpler and easier to read. And they are reusable. To define a master-slave layout is as simple as: static void grid(Monitor *m) { apply_mslts(m, False, lt_vstack, lt_grid); } Here `False` means split master and slave areas vertically; lt_vstack is applied to the master area, and lt_grid to the slaves. I've never seen such a layout before, you may find it interesting too. To test this out, simply grab the hg tip, #include mslts.c in config.h, add some example layouts such as `grid', bind a key combo, `make`, and run. Adjust the nmaster value with Mod + d/i, and mfact with Mod + h/l to see the effects. Also, this approach accepts nmaster being 0, in which case, all windows are slaves, and are thus tiled using the slaves' layout algorithm. This should be the case for the current hg tip, too, IMO. Finally, I'm not really good at C yet, so the code could probably use a whole lot of improvement. I'd really appreciate it if you could review the code and help me improve it, because I really like this idea. The code is in the attachment. /* Resend this due to missing [dwm] tag in the subject, and an error in the code. Sorry for the inconvenience. */