
hpa:
Hello List,
I just recently found out about xmonad and I am addicted already :) Thanks for this great window manager.
I have written a function that will rotate all windows in the stack except the master, while leaving the focus where it is. I use it with the TwoPane layout: In this layout, the first window after the master window will be raised whenever the master gets the focus, which I found annoying. If that window has the focus, and you use my rotateSlaves function to change to another window, this window will still be visible when you change the focus to the master window. It is also nice to be able to change the window visible in the second pane without loosing focus in the master window.
Ii think this is a nice idea, and should definitely go in the contrib module. We want to keep the core api very small, and just let people pick and choose their extensions.
I was not sure whether I should put this in XMonadContrib, since I think it's a candidate for Operations.hs.
Anyway, here is the function:
rotSlaves :: SS.StackSet i a s sd -> SS.StackSet i a s sd rotSlaves = SS.modify' rotSlaves'
rotSlaves' :: SS.Stack a -> SS.Stack a rotSlaves' (SS.Stack t ls rs) | (null ls) = SS.Stack t [] ((rearRs)++(frontRs)) --Master has focus | otherwise = SS.Stack t' (reverse ((master)++revls')) rs' --otherwise where (frontRs, rearRs) = splitAt (max 0 ((length rs) - 1) rs (ils, master) = splitAt (max 0 ((length ls) - 1) ls toBeRotated = (reverse ils)++(t:rs) (revls',t':rs') = splitAt (length ils) ((last toBeRotated):(init toBeRotated))
a keybinding looks like:
, ((modMask .|. shiftMask, xK_Tab ), windows rotSlaves)
I hope someone else will find that usefull...
Nice, feel free to submit it as a contrib module (and perhaps with some internal quickcheck properties to ensure the invariant that the master doesn't move, and that focus is kept where it starts. (have a look in tests/Properties.hs for example QC tests for this kind of thing). -- Don