[Xmonad] darcs patch: refactor layout interface. (and 1 more)

Jason Creighton jcreigh at gmail.com
Thu Apr 19 21:10:36 EDT 2007

On Wed, Apr 18, 2007 at 09:27:03PM -0700, David Roundy wrote:
> On Wed, Apr 18, 2007 at 07:06:11PM -0600, Jason Creighton wrote:
> > On Wed, Apr 18, 2007 at 09:05:56AM -0700, David Roundy wrote:
> > > hunk ./Operations.hs 49
> > > -            case layoutType fl of
> > > -                Full -> fmap (flip (,) sc) $ maybeToList $ W.peekStack n ws
> > > -                Tall -> tile  (tileFraction fl) sc $ W.index n ws
> > > -                Wide -> vtile (tileFraction fl) sc $ W.index n ws
> > > +            (doLayout l) sc $ W.index n ws
> > >          whenJust (W.peekStack n ws) (io . raiseWindow d)
> > >      whenJust (W.peek ws) setFocus
> > >      clearEnterEvents
> > > hunk ./Operations.hs 54
> > >  
> > > +full :: Layout
> > > +full = Layout { doLayout = \sc -> map (\w -> (w,sc)), modifyLayout = const Nothing }
> > 
> > If I'm reading this correctly, I don't think that will work. "full"
> > doesn't display the first window in the tiling order, it displays the
> > focused window. So Rectangle -> [Window] -> [(Window, Rectangle)] is not
> > sufficient to support all the cases we have now: The layout function has
> > to somehow know which window is focus. To that end, I think the layout
> > function type is going to have to be something like
> I can assure you that full does work (I just double-checked), although I
> couldn't really explain why--except experimentally.  (By which I mean that
> it displays the focussed window, and no other.)  Perhaps the focussed
> window is always displayed on top of the other windows when they overlap?

Oh, right. "refresh" raises the focused window. So it works, but by

Maybe that's not a fair way of putting it. As xmonad is currently
written, the focused window has to be raised because we don't move the
other windows out of the way. So while it seems kludgey to me, it will
work, as you have noted. But it also seems distasteful to not be able
to, for example, check all the normal properties (non-overlapping
windows among them, I believe) with QC. So my opinion is that it would
be better to pass in the focused window, as you propose below.

> > Rectangle -> Workspace -> [(Window, Rectangle)]
> > 
> > ...where "Workspace" is a magical, as-yet-non-existent datatype that
> > contains a list of windows, which one is focused and the layout
> > description. (Possibly other stuff; that's all I can think of ATM.) And
> > of course StackSet would have to be modified to use "Workspace".
> We certainly could generalize, but I don't think we need a new datatype for
> this.  As far as I can see, all we would need to add is an index to the
> focussed window, since that's all the information that is stored.


> I'm not sure what you mean by the "layout description".  My idea (as
> exemplified in this patch) is that you don't need a layout description, and
> I don't want one--assuming you mean something like a data type.

Well, I was thinking of the LayoutDesc type. (Or, in your patch, the Layout

Specifically, I was thinking that all the properties of a workspace (The
window list, the focused index, and whatever it needs to know about
layout) would be in one datatype, and then we wouldn't need three
seperate maps (layoutDescs in XMonad, stacks in StackSet and focus in
StackSet) to keep track of workspaces.

Now I'm not so sure; maybe the layout stuff should be separate from
StackSet anyway.

But in any case, any sort of refactor like that is unrelated to your
change and isn't something we need to think about right this second.

> > In that scenario, I'm not quite sure where you'd want to parameterize
> > your user-defined message type. Indeed, I'm not quite sure what to do
> > about that in the first place. If the whole X monad takes this type,
> > doesn't that mean that you made up a totally new type, you couldn't mix
> > and match your layout functions with the builtin ones?
> In the scenario I'm imagining, layout functions would define a class
> describing the messages they accept, and the Config file would define a
> data type that is an instance of all those classes.  Thus we can have any
> combination of layouts, which can each accept any number of messages.  The
> Config file needs to "know" the details of the messages in order to set up
> key bindings anyhow.
> In practice, there probably won't be very many such classes, since most
> layouts will accept similar commands.

Hmm. What advantage does using classes have over just having a data type
with multiple constructors, and have layout functions ignore messages
(ie, constructors) they don't know about?

Jason Creighton

More information about the Xmonad mailing list