[Xmonad] Less code smell for xinerama code

Donald Bruce Stewart dons at cse.unsw.edu.au
Mon May 21 02:07:40 EDT 2007


Some more changes to the Xinerama code just landed: we removed the
separate table tracking Xinerama screens to virtual workspaces. Instead
the core data structure now tracks directly the current, visible and
hidden workspaces. Makes policy regarding how workspaces are moved
around on xinerama screens a lot simpler.

The trick is to use the 'one hole context' workspace list (a list with a
hole punched in it to track focus). 

A list of workspaces:
        Workspaces = [w]

The same list, but with a hole punched in it to track focus:

        Cursor = { left    :: [w] 
                 , current ::  w 
                 , right   :: [w] }

We use the partitioning of the this punched list to separate those
workspaces that are visible on a xinerama, but not in focus, and those
that are hidden entirely.

        Cursor = { visible :: [w] 
                 , current ::  w 
                 , hidden  :: [w] }

That is, the workspaces to the 'left' of the currently focused workspace
are now only the xinerama-visisble ones, and those to the 'right' are
those that are completely hidden. The result, much less bookkeeping, and
4 dynamic checks are removed, as the data structure tracks them by
design. 

Moving between current and visible workspaces becomes obvious to
implement and test, and deciding when and how to raise a hidden
workspace also becomes easy.

Finally, we have a natural account for the concept of 'visible  but not
current' workspaces, as managed by Xinerama, directly in the StackSet
data structure. The result being code that doesn't smell quite so much.

-- Don


More information about the Xmonad mailing list