Re: mouse regression caused by x11ddraw.c revision 1.98 changes

Ove Kaaven <[email protected]>
Newsgroups gmane.comp.emulators.winex.devel
Organization TransGaming Technologies Inc
Message-ID <1082510339.7411.24.camel@renegade>
ons, 21.04.2004 kl. 01.26 skrev Tim Beckmann:
> Ove Kaaven wrote:
> > How many times did you click the mouse button when you made this trace?
> > At which times?
> 
> I don't recall exactly.  But I think it was:
> 
> - once when the splash screen was up to move past the splash screen.  It 
> works there.   After which, the screen flashes a few times to apparently 
> unmap the splash screen and make a new window to bring up the main menu.
> - In the main menu, pressed the mouse button over the "load game" 
> option.  Pressed once, or maybe twice.  Didn't work.
> - Once more over the "exit" option.  Didn't work.

Thanks. I think I see the problem in here. It is absolutely imperative
that the XSelectInput calls I added in 1.98 not get accidentally called
from any other thread than the one that runs X11DRV_DD_ThreadProc, as
they could otherwise completely disable input events, like mouse button
events, for the window. The trace shows that, unfortunately, if a
fullscreen window is created and then immediately destroyed before the
window manager gets around to processing the events from the creation, a
code path leading to a XSelectInput from the wrong thread may be taken.
Can you try the following patch that tries to safeguard this from
happening? I'm not 100% decided whether the if in front of the
XDeleteProperty should check for -1 or not. Perhaps code to properly
track windows awaiting reparenting should be written someday.

Index: x11ddraw.c
===================================================================
RCS file: /home/cvs/cvsroot/winex/dlls/x11drv/x11ddraw.c,v
retrieving revision 1.104
diff -u -r1.104 x11ddraw.c
--- x11ddraw.c	16 Apr 2004 18:21:47 -0000	1.104
+++ x11ddraw.c	21 Apr 2004 00:49:34 -0000
@@ -815,14 +815,14 @@
       unsigned long items, remain;
       unsigned char *props;
 
-      if (lParam && lParam != win) {
+      if (lParam != (LPARAM)0 && lParam != (LPARAM)-1 && lParam != win) {
         TRACE("skipping %08lx (wants %08lx)\n", win, lParam);
         WIN_ReleasePtr(wnd);
         return TRUE;
       }
 
       wine_tsx11_lock();
-      if (!lParam &&
+      if (lParam == (LPARAM)0 &&
           XGetWindowProperty(display, win, wmState, 0, sizeof(long), False, wmState,
                              &type, &fmt, &items, &remain, &props) == Success &&
           type != None) {
@@ -848,7 +848,7 @@
         wine_tsx11_unlock();
         X11DRV_DD_Reparent(hwnd, 0);
         wine_tsx11_lock();
-        if (lParam) {
+        if (lParam != (LPARAM)0 && lParam != (LPARAM)-1) {
           /* So we got here while entering fullscreen by unmapping the window and waiting
            * for WM_STATE to go away. However, metacity sets the property to WithdrawnState
            * instead of deleting it, so let's make sure the property is really gone
@@ -867,7 +867,7 @@
     }
     else {
       /* window is not mapped, reparent window immediately. */
-      if (!lParam) {
+      if (lParam == (LPARAM)0 || lParam == (LPARAM)-1) {
         X11DRV_DD_Reparent(hwnd, 0);
       }
     }
@@ -896,7 +896,7 @@
 
     /* Reparent all top level windows to our new root window */
     TSXSync(gdi_display, False);
-    EnumWindows(X11DRV_DD_StartReparent, 0);
+    EnumWindows(X11DRV_DD_StartReparent, (LPARAM)0);
     TSXSync(thread_display(), False);
   }
 }
@@ -914,7 +914,7 @@
 
     /* Reparent all top level windows to our new root window */
     TSXSync(gdi_display, False);
-    EnumWindows(X11DRV_DD_StartReparent, 0);
+    EnumWindows(X11DRV_DD_StartReparent, (LPARAM)-1);
     TSXSync(thread_display(), False);
   }
   if (root_window != DefaultRootWindow(gdi_display)) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.