PATCH: SetParent optimization

Marcus Meissner meissner at
Sun Jul 21 16:19:05 CDT 2002


this Patch is not yet applied. Any issues?

Ciao, marcus
----- Forwarded message from Marcus Meissner <meissner at> -----

Date: Fri, 12 Jul 2002 13:51:57 +0200
From: Marcus Meissner <meissner at>
To: wine-patches at
Subject: PATCH: SetParent optimization
User-Agent: Mutt/


Lotus Notes R5 5.0.10 has a Details Popup Window which stays over the
normal Lotus window usually.

If it is started and the focus leaves this window, Lotus reparents
to the toplevel window, using "SetWindowLong(hwnd, GWL_HWNDPARENT,
toplevelhwnd);" and later does "BringWindowToTop(toplevelhwnd);".

Somehow, the reparenting confuses the popup window and it hides and
moves away behind the toplevel window leading to severe redraw confusion.

Debugging further the SetParent() call generated above was setting
the same parent the window already had, so I just optimized this into
returning the parent window.

With this patch, the details popup stays on top.

I am not really sure whether this is valid behaviour. The MSDN does not
say anything regarding this and I do not have a Windows installation.

Ciao, Marcus

License: LGPL
	Do not do SetParent() if the new parent is already the old parent.

Index: windows/win.c
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.186
diff -u -r1.186 win.c
--- windows/win.c	2 Jun 2002 21:29:23 -0000	1.186
+++ windows/win.c	12 Jul 2002 11:32:56 -0000
@@ -2512,6 +2514,17 @@
     if (!parent) parent = GetDesktopWindow();
     else parent = WIN_GetFullHandle( parent );
+    /* The MSDN is unclear on whether a SetParent() which sets the 
+     * same parent window as before is a complete no-op, or does 
+     * all the steps we do below again.
+     * However, the Details popup in Lotus Notes seems to like it,
+     * so we do optimize.
+     */
+    if (GetParent( hwnd ) == parent) {
+        WARN("Optimizing, new parent is same as old one.\n");
+        return parent;
+    }
     if (!IsWindow( parent ))

----- End forwarded message -----

More information about the wine-patches mailing list