[xmonad] darcs patch: new contrib module, Layout.PerWorkspace

David Roundy droundy at darcs.net
Tue Nov 20 10:01:19 EST 2007


On Mon, Nov 19, 2007 at 09:54:06PM -0500, Brent Yorgey wrote:
> As seen on xmonad@!  A module which allows you to configure layouts
> per-workspace.  Testing, comments, criticisms, edits, etc. welcome.

This is buggy when multiple screens are in use, because of the following
code:

    -- figure out which layout to use based on the current workspace.
    doLayout (PerWorkspace wsId Nothing l1 l2) r s  = do
        t <- getCurrentTag
        doLayout (PerWorkspace wsId (Just $ wsId == t) l1 l2) r s

There's no guarantee that the *current* screen is the one that's having
doLayout called.  :(

We also have trouble with:

    handleMessage (PerWorkspace wsId Nothing l1 l2) m = do
        t <- getCurrentTag
        handleMessage (PerWorkspace wsId (Just $ wsId == t) l1 l2) m

because the message might have been sent using broadcastMessage rather than
sendMessage, so we again might not be the main workspace.

I'm not sure of the best fix for this.  It'd be tempting to write a
function to send a YouAreWorkspace message to all layouts right at the very
beginning.  We ought to have some sort of an "initialization hook" that
could be called just once on startup.  One could stick this in a key
binding, but that'd be just ugly...

We could also, in doLayout, examine the window stack we are given and
compare it with those in all the visible workspaces to try to figure out
who we are.  This could have the advantage of keeping your elegant user
interface (users don't need to consider what hooks they've got), but would
also suffer from confusion when two workspaces having the same set of
windows.  It'd be relatively ugly to code, but would have the advantage of
being relatively robust.  I think this is what I'd do.  And you could just
ignore any Messages until you've figured out who you are.  I don't think
there are any really important messages that can come to a Layout before
it's ever displayed a window.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the xmonad mailing list