
On Thu, Jan 31, 2008 at 2:42 PM, Spencer Janssen
On Wed, Jan 30, 2008 at 07:29:58PM -0500, Brent Yorgey wrote:
1. PerWorkspace is an inelegant hack with several icky problems:
Agreed. It is approaching the limits of xmonad's layout design. However, I think we can accomplish PerWorkspace behavior without changing too much.
\begin{code} data PerWS = PerWS { selected :: Maybe Layout , choices :: Map WorkspaceId Layout , default :: Layout } \end{code}
'selected' is Nothing until we either figure out which workspace the layout is on, or we're forced to render before we figure it out. 'choices' maps workspaceids to desired layouts. 'default' is used when the WorkspaceId isn't in our 'choices' map, or we're forced to render before we know which workspace
we're on.
This is similar to what I had before, except I very much like the idea of storing a "Maybe Layout" instead of just a "Maybe Bool". Much less of a headache. =)
Now, the million dollar question: how do we figure out which workspace a layout is on?
\begin{code} data YouAreHere = YAH WorkspaceId deriving Typeable instance Message YouAreHere \end{code}
Ah, excellent! I hadn't thought of the idea of a special message.
Now we just need to arrange for this message to be sent. I see two options:
- add a 'startupHook :: X ()' that is executed when xmonad starts. This might be useful for other applications too. A minor issue is that the user will have to edit startupHook and layoutHook to use PerWorkspace successfully.
This option makes more sense to me. In fact, the other day someone was asking about the possibility of just such a hook; I played around with it for a bit but wasn't sure of the best place to add a call to it in the core. Would it really be possible to implement a function to correctly send all the YouAreHere messages, with no other support from the core than just calling the startupHook? I'll have to look into it. If so this seems the way to go.
- have the core send YouAreHere messages to each visible workspace during each refresh. This is easier for the user, but it requires adding more to the core.
This sounds sort of ugly to me. Again, it's the principle of making a bunch of very specific changes to the core which have not much purpose other than to support a single extension. -Brent