[Xmonad] darcs patch: add SimpleStacking module to make Combo and Tabbed wor...

David Roundy droundy at darcs.net
Thu Jun 21 11:11:36 EDT 2007


Hi all,

This module gets Combo working with Tabbed again, by adding a
SimpleStacking layout modifier, which mimics the old stacking behavior,
using Spencer's latest patch.  However, this is fragile, and I think it's
fragile because of a design problem that is easily fixed--but not before
work this morning.

The trouble is that within doLayout, there's no way for a layout to modify
itself, because it can't tell which layout it is... and because it may not
be a "root" layout at all.  The solution seems simple:  redefine

data Layout a = Layout { doLayout :: Rectangle -> Stack a
                                  -> X ([(a, Rectangle)], Maybe (Layout a))
                       , modifyLayout :: SomeMessage -> X (Maybe (Layout a)) }

so doLayout can modify itself.  This makes all the Layout transformers a
little harder to write, but a helper module ought to be able to fix that.

And it makes me wonder yet again whether we should be defining a class

class Layout l a where
   doLayout :: l -> X Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (Layout a)
   modifyLayout :: l -> SomeMessage -> X (Maybe (Layout a))
   serializeLayout :: l -> String
   readLayout :: String -> Maybe (l, String) -- or some other parser-like thing

data Layout a = forall l. Layout l a => Layout a

This might lend itself to somewhat prettier Layout code that is more
"data-structure-based" rather than self-modifying-function-based.  I
imagine this would lead to friendly interfaces for easy-to-write layout
modifiers.

David

P.S. I'd be curious to see implemented a "popularity-contest" module for
xmonad once we've got serialization, which could use the logging mechanism
to report on the most frequently used layouts.  And yes, this would be in
XMonadContrib and only manually enabled.  I have no idea how many people
are actually using Tabbed, and how likely this is to break folks' Config
files.

Thu Jun 21 07:55:00 PDT 2007  David Roundy <droundy at darcs.net>
  * add SimpleStacking module to make Combo and Tabbed work together.
  WARNING! This change will break existing Tabbed configurations.  The
  problem is that there is no way within a Layout's "doLayout" to safely
  modify the layout itself.  This makes LayoutHooks fragile, and more to the
  point, makes SimpleStacking fragile, so we can't safely define a
  
  tabbed' = simpleStacking . tabbed
  
  A workaround would have been to duplicate the tabbed code, but I'd rather
  leave the ugliness and get this fixed.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-darcs-patch
Size: 27552 bytes
Desc: A darcs patch for your repository!
Url : http://www.haskell.org/pipermail/xmonad/attachments/20070621/e061f3c7/attachment-0001.bin


More information about the Xmonad mailing list