win32u: Move GetParent implementation from user32.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-03-08 14:24:00 +01:00 committed by Alexandre Julliard
parent cde008fe71
commit 5da6282a60
4 changed files with 44 additions and 34 deletions

View File

@ -2908,39 +2908,7 @@ DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process )
*/ */
HWND WINAPI GetParent( HWND hwnd ) HWND WINAPI GetParent( HWND hwnd )
{ {
WND *wndPtr; return UlongToHandle( NtUserCallHwnd( hwnd, NtUserGetParent ));
HWND retvalue = 0;
if (!(wndPtr = WIN_GetPtr( hwnd )))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr == WND_DESKTOP) return 0;
if (wndPtr == WND_OTHER_PROCESS)
{
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
if (style & (WS_POPUP | WS_CHILD))
{
SERVER_START_REQ( get_window_tree )
{
req->handle = wine_server_user_handle( hwnd );
if (!wine_server_call_err( req ))
{
if (style & WS_POPUP) retvalue = wine_server_ptr_handle( reply->owner );
else if (style & WS_CHILD) retvalue = wine_server_ptr_handle( reply->parent );
}
}
SERVER_END_REQ;
}
}
else
{
if (wndPtr->dwStyle & WS_POPUP) retvalue = wndPtr->owner;
else if (wndPtr->dwStyle & WS_CHILD) retvalue = wndPtr->parent;
WIN_ReleasePtr( wndPtr );
}
return retvalue;
} }

View File

@ -296,6 +296,7 @@ extern void user_check_not_lock(void) DECLSPEC_HIDDEN;
struct tagWND; struct tagWND;
extern HWND is_current_thread_window( HWND hwnd ) DECLSPEC_HIDDEN; extern HWND is_current_thread_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern void flush_window_surfaces( BOOL idle ) DECLSPEC_HIDDEN; extern void flush_window_surfaces( BOOL idle ) DECLSPEC_HIDDEN;
extern DWORD get_window_long( HWND hwnd, INT offset ) DECLSPEC_HIDDEN;
extern void register_window_surface( struct window_surface *old, extern void register_window_surface( struct window_surface *old,
struct window_surface *new ) DECLSPEC_HIDDEN; struct window_surface *new ) DECLSPEC_HIDDEN;

View File

@ -361,6 +361,44 @@ static DWORD get_window_thread( HWND hwnd, DWORD *process )
return tid; return tid;
} }
/* see GetParent */
static HWND get_parent( HWND hwnd )
{
HWND retval = 0;
WND *win;
if (!(win = get_win_ptr( hwnd )))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (win == WND_DESKTOP) return 0;
if (win == WND_OTHER_PROCESS)
{
LONG style = get_window_long( hwnd, GWL_STYLE );
if (style & (WS_POPUP | WS_CHILD))
{
SERVER_START_REQ( get_window_tree )
{
req->handle = wine_server_user_handle( hwnd );
if (!wine_server_call_err( req ))
{
if (style & WS_POPUP) retval = wine_server_ptr_handle( reply->owner );
else if (style & WS_CHILD) retval = wine_server_ptr_handle( reply->parent );
}
}
SERVER_END_REQ;
}
}
else
{
if (win->dwStyle & WS_POPUP) retval = win->owner;
else if (win->dwStyle & WS_CHILD) retval = win->parent;
release_win_ptr( win );
}
return retval;
}
/* see GetWindow */ /* see GetWindow */
static HWND get_window_relative( HWND hwnd, UINT rel ) static HWND get_window_relative( HWND hwnd, UINT rel )
{ {
@ -557,7 +595,7 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans
} }
/* see GetWindowLongW */ /* see GetWindowLongW */
static DWORD get_window_long( HWND hwnd, INT offset ) DWORD get_window_long( HWND hwnd, INT offset )
{ {
return get_window_long_size( hwnd, offset, sizeof(LONG), FALSE ); return get_window_long_size( hwnd, offset, sizeof(LONG), FALSE );
} }
@ -757,6 +795,8 @@ DWORD WINAPI NtUserCallHwnd( HWND hwnd, DWORD code )
{ {
switch (code) switch (code)
{ {
case NtUserGetParent:
return HandleToUlong( get_parent( hwnd ));
case NtUserGetWindowTextLength: case NtUserGetWindowTextLength:
return get_server_window_text( hwnd, NULL, 0 ); return get_server_window_text( hwnd, NULL, 0 );
case NtUserIsWindow: case NtUserIsWindow:

View File

@ -139,6 +139,7 @@ enum
/* NtUserCallHwnd codes, not compatible with Windows */ /* NtUserCallHwnd codes, not compatible with Windows */
enum enum
{ {
NtUserGetParent,
NtUserGetWindowTextLength, NtUserGetWindowTextLength,
NtUserIsWindow, NtUserIsWindow,
}; };