WINEX11.DRV: workaround for unstable window state while handling MapNotify (fixes bug 12196)

Alex Villací­s Lasso a_villacis at palosanto.com
Mon Mar 31 12:14:13 CDT 2008


The root cause of the bug is that dlls/winex11.drv/event.c calls
get_window_wm_state() to get the state of the window (which could be
NormalState or IconicState for the purposes of this bug) in X11DRV_MapNotify(),
but at the moment it does, the window has not yet received the notification
that the property has changed, so it sees IconicState even when the window is
being restored.

As seen in the attached logs:

trace:event:call_event_handler MapNotify for hwnd/window 0x1002e/4c00007
trace:x11drv:X11DRV_MapNotify win 0x1002e/4c00007 ignoring since state=3
...
trace:event:call_event_handler PropertyNotify for hwnd/window 0x1002e/4c00007
trace:event:EVENT_PropertyNotify 0x1002e/4c00007: new WM_STATE 1

It seems that (at least in Metacity) there is no guarantee that the window
state will no longer change when MapNotify is received. It can be any value
(IconicState or NormalState) by the time the app gets around to process the
event. Here the state changed *after* the MapNotify was received. The handler
decided to ignore the event, and when the PropertyNotify was received, it did
nothing. 

BTW, the WM can choose to change the value *before* MapNotify, even when the
PropertyNotify is issued *after* MapNotify. In that case the app is restored
normally. The typical race condition. I don't know whether this describes
incorrect WM behavior, but a workaround is needed for it.

The attached patch seems to fix this issue for me. It issues X11DRV_MapNotify
when it detects that the window is still marked as iconic on a transition from
IconicState to NormalState. Please comment on this.

See bug #12196 for full discussion.

Changelog:
* Workaround for unstable window state when handling MapNotify at window restore after minimize. 
  Issue extra X11DRV_MapNotify call when PropertyNotify detects still-iconic window on 
  IconicState->NormalState transition.

-- 
perl -e '$x=2.4;print sprintf("%.0f + %.0f = %.0f\n",$x,$x,$x+$x);'

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-winex11.drv-workaround-PropertyNotify-after-MapNotify.patch
Type: text/x-patch
Size: 1224 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20080331/6b9457a3/attachment.bin 


More information about the wine-patches mailing list