On Tue, 2006-08-08 at 13:48 +0100, Mike Hearn wrote:
It's not that we need to slow it down - slowing something down is never an acceptable solution to a race. We are missing some kind of synchronisation somewhere,
Actually, I don't think it has to do with synchronization--I think it has to do with window mapping. Today I did some more research on the issue, and I came across the XEmbed spec, and there's a pretty interesting tidbit in there [1] (look under the XEMBED_MAPPED section.) The problem is that the systray window has to be unmapped so that when we dock, the embedder (the systray applet that holds the icon) has to map the client (the systray icon) itself--we can't do it in WINE or we risk having the race conditions that we do (where the window becomes visible as a child of the root window and not the tray, or sometimes both the root window and tray)
So here's the solution that I'm currently using to solve it: don't call XMapWindow on systray icon windows. That combined with the mapped flag in the XEMBED_INFO array we set just before we dock the icon allows it to work properly. I've run my small test app over 50 times straight (probably more by now--I've lost count,) and it works. I'll do some more tests to make sure everything is good, and hone my solution a little before submitting. The problem with this is that we probably want mapping if we don't have a tray to send our icon to, so I'll be playing with getting that to work cleanly.
James
Notes: [1]: http://standards.freedesktop.org/xembed-spec/latest/ar01s04.html