Hi all!<br><br>This may end up being a long e-mail.&nbsp; Executive summary:<br><br>&nbsp; 1. PerWorkspace is an inelegant hack with several icky problems:<br>&nbsp;&nbsp;&nbsp;&nbsp; - &#39;description&#39; is not in the X monad so can&#39;t figure out the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; current workspace<br>&nbsp;&nbsp;&nbsp;&nbsp; - the currently focused workspace might not even be the correct<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; one anyway, in the case of xinerama or message handling.<br><br>&nbsp; 2. Andrea&#39;s LayoutCombinator class and core patch to move the result<br>
&nbsp;&nbsp;&nbsp;&nbsp; of the description function into the X monad will help with some<br>&nbsp;&nbsp;&nbsp;&nbsp; but not all of the problems.&nbsp; In particular it still won&#39;t work<br>&nbsp;&nbsp;&nbsp;&nbsp; with xinerama.<br><br>&nbsp; 3. It would be nice to have the PerWorkspace functionality supported<br>
&nbsp;&nbsp;&nbsp;&nbsp; in the core, and I have a nice, elegant way to do it.&nbsp; This would<br>&nbsp;&nbsp;&nbsp;&nbsp; fix all the problems.&nbsp; ...The only catch is that it would also<br>&nbsp;&nbsp;&nbsp;&nbsp; require going back to requiring existential Layout wrappers<br>&nbsp;&nbsp;&nbsp;&nbsp; everywhere. =(<br>
<br>&nbsp; 4. Well, crap.<br><br><br><br>I had recently been thinking about PerWorkspace and ways to improve<br>it, but hadn&#39;t yet gotten around to really doing anything about it.<br>Andrea&#39;s new emptyLayout function, and then in particular his<br>
reimplementation of PerWorkspace using the new LayoutCombinator<br>framework obviously motivated me to get around to it!&nbsp; So I&#39;d like to<br>explain some of the problems with PerWorkspace and possible future<br>directions. <br>
<br>First, the basics: although the xmonad core tracks layouts separately<br>for each workspace, it is not possible to *specify* a different<br>starting layout on a per-workspace basis.&nbsp; Only a single layout may be<br>specified in the XConfig record, and this layout is duplicated across<br>
all workspaces on xmonad startup.&nbsp; PerWorkspace attempts to get around this<br>limitation by providing a layout which dynamically decides on which of two sub-layouts<br>to use, based on the current workspace tag.&nbsp; All workspaces still have the<br>
same layout, but that one layout acts differently depending on the current workspace.&nbsp; <br>You can see from the beginning that this is something of a hack.<br><br>This approach has two major limitations, each of which leads to one or<br>
more problems.<br><br>&nbsp; * To find out the current workspace obviously requires access to the<br>&nbsp;&nbsp;&nbsp; X monad.&nbsp; For doLayout and handleMessage this is obviously not a<br>&nbsp;&nbsp;&nbsp; problem.&nbsp; The description method, however, is a pure function.&nbsp; I<br>
&nbsp;&nbsp;&nbsp; solved this in a very hackish way before by having a call to<br>&nbsp;&nbsp;&nbsp; doLayout return a modified PerWorkspace layout structure with a<br>&nbsp;&nbsp;&nbsp; cached value remembering which of the two layouts should be used.<br>&nbsp;&nbsp;&nbsp; description could then use this cached value to decide on the<br>
&nbsp;&nbsp;&nbsp; description to return.&nbsp; Andrea&#39;s current reimplementation of<br>&nbsp;&nbsp;&nbsp; PerWorkspace does not do this caching, which is why the<br>&nbsp;&nbsp;&nbsp; description method is currently broken.&nbsp; I can reimplement this,<br>&nbsp;&nbsp;&nbsp; and the new emptyLayout method will help, but it still feels very<br>
&nbsp;&nbsp;&nbsp; inelegant.<br><br>&nbsp; * A more insidious problem is that it is not possible, in general,<br>&nbsp;&nbsp;&nbsp; for doLayout or doMessage to figure out which workspace they<br>&nbsp;&nbsp;&nbsp; belong to, and hence which layout to use.&nbsp; PerWorkspace currently<br>
&nbsp;&nbsp;&nbsp; works by retrieving the tag of the currently focused workspace<br>&nbsp;&nbsp;&nbsp; from the xmonad state, but there are several situations in which<br>&nbsp;&nbsp;&nbsp; doLayout or handleMessage are called on a workspace which is<br>&nbsp;&nbsp;&nbsp; not the currently focused workspace:<br>
<br>&nbsp;&nbsp;&nbsp; - If xinerama is in use, doLayout will be called for all the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; visible workspaces as well as the focused workspace.<br>&nbsp;&nbsp;&nbsp; - Messages can be broadcast to all workspaces, in which case<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handleMessage will be called for all workspaces, including<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; non-focused or even hidden workspaces.<br><br>&nbsp;&nbsp;&nbsp; In either of these situations, PerWorkspace may choose the wrong<br>&nbsp;&nbsp;&nbsp; layout.&nbsp; The message problem can be solved by simply passing along<br>&nbsp;&nbsp;&nbsp; any messages to all layouts, without trying to decide on the<br>
&nbsp;&nbsp;&nbsp; correct one: it cannot hurt to pass messages to unintended<br>&nbsp;&nbsp;&nbsp; recipients, especially if the unintended recipient layouts will<br>&nbsp;&nbsp;&nbsp; never be used anyway!&nbsp; The xinerama problem seems insoluble,<br>&nbsp;&nbsp;&nbsp; however.&nbsp; PerWorkspace simply cannot work on xinerama because it<br>
&nbsp;&nbsp;&nbsp; cannot get the information it needs to decide which layout to<br>&nbsp;&nbsp;&nbsp; use.<br><br>So, what is the way forward?&nbsp; It looks like I can get PerWorkspace<br>back to its original level of workingness --- thanks to the<br>LayoutCombinator class it will be a lot shorter, but it still won&#39;t<br>
work with xinerama, and it will still be an ugly, fragile hack.<br><br>I had been intending to suggest adding support for per-workspace<br>layouts to the xmonad core.&nbsp; After all, xmonad does track and<br>save/restore layouts on a per-workspace basis, so why shouldn&#39;t it<br>
allow configuring them on a per-workspace basis too?&nbsp; I intended to keep<br>the current layoutHook (specifying the default layout to be used on<br>all workspaces not otherwise specified) as well as adding a new field<br>to the config which would store a list of (workspace tag, layout)<br>
pairs.&nbsp; The core modifications necessary to support this are not too<br>hard and end up being fairly elegant -- in fact, I have made these<br>modifications in a local branch.<br><br>The catch? Having a bunch of layouts in a list like this requires<br>
going back to wrapping everything with Layout existentials in user<br>configs! =( This doesn&#39;t sound like much fun either.<br><br>So, I am at something of a loss.&nbsp; Any thoughts or suggestions for moving forward<br>are appreciated!<br>
<br>-Brent