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

Remove computing of parent and owner handles on the client side.
This commit is contained in:
Alexandre Julliard 2006-03-06 15:00:37 +01:00
parent f874d20f54
commit 4be3d4c12b
5 changed files with 30 additions and 20 deletions

View File

@ -59,6 +59,7 @@ static WND *create_window_handle( HWND parent, HWND owner, ATOM atom,
{ {
WORD index; WORD index;
WND *win; WND *win;
HWND full_parent = 0, full_owner = 0;
struct tagCLASS *class = NULL; struct tagCLASS *class = NULL;
user_handle_t handle = 0; user_handle_t handle = 0;
int extra_bytes = 0; int extra_bytes = 0;
@ -76,6 +77,8 @@ static WND *create_window_handle( HWND parent, HWND owner, ATOM atom,
if (!wine_server_call_err( req )) if (!wine_server_call_err( req ))
{ {
handle = reply->handle; handle = reply->handle;
full_parent = reply->parent;
full_owner = reply->owner;
extra_bytes = reply->extra; extra_bytes = reply->extra;
class = reply->class_ptr; class = reply->class_ptr;
} }
@ -106,6 +109,8 @@ static WND *create_window_handle( HWND parent, HWND owner, ATOM atom,
assert( index < NB_USER_HANDLES ); assert( index < NB_USER_HANDLES );
user_handles[index] = win; user_handles[index] = win;
win->hwndSelf = handle; win->hwndSelf = handle;
win->parent = full_parent;
win->owner = full_owner;
win->dwMagic = WND_MAGIC; win->dwMagic = WND_MAGIC;
win->cbWndExtra = extra_bytes; win->cbWndExtra = extra_bytes;
memset( win->wExtra, 0, extra_bytes ); memset( win->wExtra, 0, extra_bytes );
@ -915,7 +920,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
/* Find the parent window */ /* Find the parent window */
parent = GetDesktopWindow(); parent = cs->hwndParent;
owner = 0; owner = 0;
if (cs->hwndParent == HWND_MESSAGE) if (cs->hwndParent == HWND_MESSAGE)
@ -924,24 +929,24 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
* message window (style: WS_POPUP|WS_DISABLED) * message window (style: WS_POPUP|WS_DISABLED)
*/ */
FIXME("Parent is HWND_MESSAGE\n"); FIXME("Parent is HWND_MESSAGE\n");
parent = GetDesktopWindow();
} }
else if (cs->hwndParent) else if (cs->hwndParent)
{ {
/* Make sure parent is valid */ if ((cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
if (!IsWindow( cs->hwndParent ))
{ {
WARN("Bad parent %p\n", cs->hwndParent ); parent = GetDesktopWindow();
return 0; owner = cs->hwndParent;
} }
if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
parent = WIN_GetFullHandle(cs->hwndParent);
else
owner = GetAncestor( cs->hwndParent, GA_ROOT );
} }
else if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD) else
{ {
WARN("No parent for child window\n" ); if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
return 0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ {
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 */ WIN_FixCoordinates(cs, &sw); /* fix default coordinates */
@ -956,17 +961,12 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
/* Create the window structure */ /* Create the window structure */
if (!(wndPtr = create_window_handle( parent, owner, classAtom, cs->hInstance, type ))) if (!(wndPtr = create_window_handle( parent, owner, classAtom, cs->hInstance, type )))
{ return 0;
TRACE("out of memory\n" );
return 0;
}
hwnd = wndPtr->hwndSelf; hwnd = wndPtr->hwndSelf;
/* Fill the window structure */ /* Fill the window structure */
wndPtr->tid = GetCurrentThreadId(); wndPtr->tid = GetCurrentThreadId();
wndPtr->owner = owner;
wndPtr->parent = parent;
wndPtr->hInstance = cs->hInstance; wndPtr->hInstance = cs->hInstance;
wndPtr->text = NULL; wndPtr->text = NULL;
wndPtr->dwStyle = cs->style & ~WS_VISIBLE; wndPtr->dwStyle = cs->style & ~WS_VISIBLE;

View File

@ -2520,6 +2520,8 @@ struct create_window_reply
{ {
struct reply_header __header; struct reply_header __header;
user_handle_t handle; user_handle_t handle;
user_handle_t parent;
user_handle_t owner;
int extra; int extra;
void* class_ptr; void* class_ptr;
}; };
@ -4358,6 +4360,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply; struct query_symlink_reply query_symlink_reply;
}; };
#define SERVER_PROTOCOL_VERSION 229 #define SERVER_PROTOCOL_VERSION 230
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -1789,6 +1789,8 @@ enum message_type
void* instance; /* module instance */ void* instance; /* module instance */
@REPLY @REPLY
user_handle_t handle; /* created window */ 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 */ int extra; /* number of extra bytes */
void* class_ptr; /* pointer to class in client address space */ void* class_ptr; /* pointer to class in client address space */
@END @END

View File

@ -2267,6 +2267,8 @@ static void dump_create_window_request( const struct create_window_request *req
static void dump_create_window_reply( const struct create_window_reply *req ) static void dump_create_window_reply( const struct create_window_reply *req )
{ {
fprintf( stderr, " handle=%p,", req->handle ); 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, " extra=%d,", req->extra );
fprintf( stderr, " class_ptr=%p", req->class_ptr ); fprintf( stderr, " class_ptr=%p", req->class_ptr );
} }

View File

@ -1372,10 +1372,14 @@ DECL_HANDLER(create_window)
set_error( STATUS_ACCESS_DENIED ); set_error( STATUS_ACCESS_DENIED );
return; 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; if (!(win = create_window( parent, owner, req->atom, req->instance ))) return;
reply->handle = win->handle; reply->handle = win->handle;
reply->parent = win->parent ? win->parent->handle : 0;
reply->owner = win->owner;
reply->extra = win->nb_extra_bytes; reply->extra = win->nb_extra_bytes;
reply->class_ptr = get_class_client_ptr( win->class ); reply->class_ptr = get_class_client_ptr( win->class );
} }