X.L.PerWorkspace does not send messages to right sublayout until activated
Here I'll try to make a bit more formal and informative version of #76
Config that reproduces the bug
import XMonad
import XMonad.Util.EZConfig
main = xmonad def { workspaces = ["1", "2"]
, layoutHook = onWorkspace "1" tiled tiled
} `additionalKeysP`
[ ("M-b", broadcastMessage Expand)
]
where tiled = Tall 1 (1/2) (1/4)
Steps to reproduce
- Start xmonad
- Open two windows
- Shift them to second workspace
- Press "M-b"
- Go to second workspace
Actual results
Two windows are half-splitted
Expected results
Left window should occupy 3/4 of width of the screen
My attemt to explain the bug
Definitions
- A sublayout is one the arguments of
PerWorkspacewhich are instances ofLayoutClass - An active sublayout is the sublayout which is chosen by the
Boolargument ofPerWorkspace - A layout is activated when
runLayoutis called first time for it
Explaination
When PerWorkspace on workspace "2" is not activated, its first sublayout is always active(but after activation the second one will be active). So, when we send message to non-activated PerWorkspace, it retranslates it only to first sublayout but we want it to retranslate that message to second sublayout
Possible fixes
- Get rid of this module and move its functionality into core(I know you're a bit conservative about changing stuff in core; and this fix still can have some problems(e.g. with dynamic workspaces))
- Create third state(for no layout chosen; default state) and accumulate messages for sending them to active sub-layout after activated
- Assume that's right behaviour and explicitely state in the docs that sending messages to non-activated layouts is undefined behaviour
- Activate each layout after it have been created.
- Any other suggestions?
Now I prefer another way(that is close to 4 but is more general): to send some "update" messages to layouts on early startup(just after layouts have been created) and after each WindowSet update(logHook?).
Does anyone has any thought on this?
logHook, yes.
We already fire the logHook very early; before the startupHook in fact, at least 4 times judging by my testing.
That's nice, so the only thing we have to do(if it's the right solution) is to send the "update" messages at the same time when we fire logHook and update all layouts when it fires. But it could be expensive, so I'm wary.