Alexandre Julliard : server: Return real parent and owner in the create_window request.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 6 12:54:52 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 4be3d4c12b916d2f17c22f09bcf087f7b8ce7390
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=4be3d4c12b916d2f17c22f09bcf087f7b8ce7390

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Mar  6 15:00:37 2006 +0100

server: Return real parent and owner in the create_window request.

Remove computing of parent and owner handles on the client side.

---

 dlls/user/win.c                |   38 +++++++++++++++++++-------------------
 include/wine/server_protocol.h |    4 +++-
 server/protocol.def            |    2 ++
 server/trace.c                 |    2 ++
 server/window.c                |    4 ++++
 5 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/dlls/user/win.c b/dlls/user/win.c
index 237deeb..1fc2d7c 100644
--- a/dlls/user/win.c
+++ b/dlls/user/win.c
@@ -59,6 +59,7 @@ static WND *create_window_handle( HWND p
 {
     WORD index;
     WND *win;
+    HWND full_parent = 0, full_owner = 0;
     struct tagCLASS *class = NULL;
     user_handle_t handle = 0;
     int extra_bytes = 0;
@@ -76,6 +77,8 @@ static WND *create_window_handle( HWND p
         if (!wine_server_call_err( req ))
         {
             handle = reply->handle;
+            full_parent = reply->parent;
+            full_owner  = reply->owner;
             extra_bytes = reply->extra;
             class = reply->class_ptr;
         }
@@ -106,6 +109,8 @@ static WND *create_window_handle( HWND p
     assert( index < NB_USER_HANDLES );
     user_handles[index] = win;
     win->hwndSelf   = handle;
+    win->parent     = full_parent;
+    win->owner      = full_owner;
     win->dwMagic    = WND_MAGIC;
     win->cbWndExtra = extra_bytes;
     memset( win->wExtra, 0, extra_bytes );
@@ -915,7 +920,7 @@ static HWND WIN_CreateWindowEx( CREATEST
 
     /* Find the parent window */
 
-    parent = GetDesktopWindow();
+    parent = cs->hwndParent;
     owner = 0;
 
     if (cs->hwndParent == HWND_MESSAGE)
@@ -924,24 +929,24 @@ static HWND WIN_CreateWindowEx( CREATEST
        * message window (style: WS_POPUP|WS_DISABLED)
        */
       FIXME("Parent is HWND_MESSAGE\n");
+      parent = GetDesktopWindow();
     }
     else if (cs->hwndParent)
     {
-	/* Make sure parent is valid */
-        if (!IsWindow( cs->hwndParent ))
+        if ((cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
         {
-            WARN("Bad parent %p\n", cs->hwndParent );
-	    return 0;
-	}
-        if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
-            parent = WIN_GetFullHandle(cs->hwndParent);
-        else
-            owner = GetAncestor( cs->hwndParent, GA_ROOT );
+            parent = GetDesktopWindow();
+            owner = cs->hwndParent;
+        }
     }
-    else if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
+    else
     {
-        WARN("No parent for child window\n" );
-        return 0;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
+        if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
+        {
+            WARN("No parent for child window\n" );
+            return 0;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
+        }
+        parent = GetDesktopWindow();
     }
 
     WIN_FixCoordinates(cs, &sw); /* fix default coordinates */
@@ -956,17 +961,12 @@ static HWND WIN_CreateWindowEx( CREATEST
     /* Create the window structure */
 
     if (!(wndPtr = create_window_handle( parent, owner, classAtom, cs->hInstance, type )))
-    {
-	TRACE("out of memory\n" );
-	return 0;
-    }
+        return 0;
     hwnd = wndPtr->hwndSelf;
 
     /* Fill the window structure */
 
     wndPtr->tid            = GetCurrentThreadId();
-    wndPtr->owner          = owner;
-    wndPtr->parent         = parent;
     wndPtr->hInstance      = cs->hInstance;
     wndPtr->text           = NULL;
     wndPtr->dwStyle        = cs->style & ~WS_VISIBLE;
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index a462751..0e9ae22 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -2520,6 +2520,8 @@ struct create_window_reply
 {
     struct reply_header __header;
     user_handle_t  handle;
+    user_handle_t  parent;
+    user_handle_t  owner;
     int            extra;
     void*          class_ptr;
 };
@@ -4358,6 +4360,6 @@ union generic_reply
     struct query_symlink_reply query_symlink_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 229
+#define SERVER_PROTOCOL_VERSION 230
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/protocol.def b/server/protocol.def
index c3ea6a6..9163a36 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1789,6 +1789,8 @@ enum message_type
     void*          instance;    /* module instance */
 @REPLY
     user_handle_t  handle;      /* created window */
+    user_handle_t  parent;      /* full handle of parent */
+    user_handle_t  owner;       /* full handle of owner */
     int            extra;       /* number of extra bytes */
     void*          class_ptr;   /* pointer to class in client address space */
 @END
diff --git a/server/trace.c b/server/trace.c
index 3e5155a..0d5fac9 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -2267,6 +2267,8 @@ static void dump_create_window_request( 
 static void dump_create_window_reply( const struct create_window_reply *req )
 {
     fprintf( stderr, " handle=%p,", req->handle );
+    fprintf( stderr, " parent=%p,", req->parent );
+    fprintf( stderr, " owner=%p,", req->owner );
     fprintf( stderr, " extra=%d,", req->extra );
     fprintf( stderr, " class_ptr=%p", req->class_ptr );
 }
diff --git a/server/window.c b/server/window.c
index bc6c208..cde33be 100644
--- a/server/window.c
+++ b/server/window.c
@@ -1372,10 +1372,14 @@ DECL_HANDLER(create_window)
             set_error( STATUS_ACCESS_DENIED );
             return;
         }
+        else /* owner must be a top-level window */
+            while (!is_desktop_window(owner->parent)) owner = owner->parent;
     }
     if (!(win = create_window( parent, owner, req->atom, req->instance ))) return;
 
     reply->handle    = win->handle;
+    reply->parent    = win->parent ? win->parent->handle : 0;
+    reply->owner     = win->owner;
     reply->extra     = win->nb_extra_bytes;
     reply->class_ptr = get_class_client_ptr( win->class );
 }




More information about the wine-cvs mailing list