From 262831bc63dca2d63171aa98d19e8f2566907dbc Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 15 Apr 2022 14:52:20 +0200 Subject: [PATCH] winex11: Directly use win32u in more places. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/winex11.drv/desktop.c | 24 ++++++++++++------------ dlls/winex11.drv/display.c | 5 +++-- dlls/winex11.drv/keyboard.c | 18 +++++++++--------- dlls/winex11.drv/vulkan.c | 4 ++-- dlls/winex11.drv/window.c | 4 ++-- dlls/winex11.drv/x11drv.h | 10 ++++++++++ dlls/winex11.drv/xrandr.c | 2 +- 7 files changed, 39 insertions(+), 28 deletions(-) diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index a89824772d0..30a86d3b5b9 100644 --- a/dlls/winex11.drv/desktop.c +++ b/dlls/winex11.drv/desktop.c @@ -197,8 +197,8 @@ static void query_desktop_work_area( RECT *rc_work ) RECT rect; HWND hwnd = FindWindowW( trayW, NULL ); - if (!hwnd || !IsWindowVisible( hwnd )) return; - if (!GetWindowRect( hwnd, &rect )) return; + if (!hwnd || !NtUserIsWindowVisible( hwnd )) return; + if (!NtUserGetWindowRect( hwnd, &rect )) return; if (rect.top) rc_work->bottom = rect.top; else rc_work->top = rect.bottom; TRACE( "found tray %p %s work area %s\n", hwnd, wine_dbgstr_rect( &rect ), wine_dbgstr_rect( rc_work ) ); @@ -334,8 +334,8 @@ BOOL CDECL X11DRV_create_desktop( UINT width, UINT height ) Display *display = thread_init_display(); WCHAR name[MAX_PATH]; - if (!GetUserObjectInformationW( GetThreadDesktop( GetCurrentThreadId() ), - UOI_NAME, name, sizeof(name), NULL )) + if (!NtUserGetObjectInformation( NtUserGetThreadDesktop( GetCurrentThreadId() ), + UOI_NAME, name, sizeof(name), NULL )) name[0] = 0; TRACE( "%s %ux%u\n", debugstr_w(name), width, height ); @@ -418,7 +418,7 @@ static void update_desktop_fullscreen( unsigned int width, unsigned int height) void X11DRV_resize_desktop( BOOL send_display_change ) { RECT primary_rect, virtual_rect; - HWND hwnd = GetDesktopWindow(); + HWND hwnd = NtUserGetDesktopWindow(); INT width, height; virtual_rect = NtUserGetVirtualScreenRect(); @@ -426,23 +426,23 @@ void X11DRV_resize_desktop( BOOL send_display_change ) width = primary_rect.right; height = primary_rect.bottom; - if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId()) + if (NtUserGetWindowThread( hwnd, NULL ) != GetCurrentThreadId()) { - SendMessageW( hwnd, WM_X11DRV_RESIZE_DESKTOP, 0, (LPARAM)send_display_change ); + send_message( hwnd, WM_X11DRV_RESIZE_DESKTOP, 0, (LPARAM)send_display_change ); } else { TRACE( "desktop %p change to (%dx%d)\n", hwnd, width, height ); update_desktop_fullscreen( width, height ); - SetWindowPos( hwnd, 0, virtual_rect.left, virtual_rect.top, - virtual_rect.right - virtual_rect.left, virtual_rect.bottom - virtual_rect.top, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE ); + NtUserSetWindowPos( hwnd, 0, virtual_rect.left, virtual_rect.top, + virtual_rect.right - virtual_rect.left, virtual_rect.bottom - virtual_rect.top, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE ); ungrab_clipping_window(); if (send_display_change) { - SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_bpp, MAKELPARAM( width, height ), - SMTO_ABORTIFHUNG, 2000, NULL ); + send_message_timeout( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_bpp, MAKELPARAM( width, height ), + SMTO_ABORTIFHUNG, 2000, NULL ); } } } diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 87287854044..a7229d3a256 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -218,10 +218,11 @@ void X11DRV_DisplayDevices_Update(BOOL send_display_change) EnumWindows(update_windows_on_display_change, (LPARAM)mask); /* forward clip_fullscreen_window request to the foreground window */ - if ((foreground = GetForegroundWindow()) && (tid = GetWindowThreadProcessId( foreground, &pid )) && pid == GetCurrentProcessId()) + if ((foreground = NtUserGetForegroundWindow()) && + (tid = NtUserGetWindowThread( foreground, &pid )) && pid == GetCurrentProcessId()) { if (tid == GetCurrentThreadId()) clip_fullscreen_window( foreground, TRUE ); - else SendNotifyMessageW( foreground, WM_X11DRV_CLIP_CURSOR_REQUEST, TRUE, TRUE ); + else send_notify_message( foreground, WM_X11DRV_CLIP_CURSOR_REQUEST, TRUE, TRUE ); } } diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index de849066b95..a55eaf071fe 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1885,10 +1885,10 @@ BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event ) XRefreshKeyboardMapping(&event->xmapping); X11DRV_InitKeyboard( event->xmapping.display ); - hwnd = GetFocus(); - if (!hwnd) hwnd = GetActiveWindow(); - PostMessageW(hwnd, WM_INPUTLANGCHANGEREQUEST, - 0 /*FIXME*/, (LPARAM)GetKeyboardLayout(0)); + hwnd = get_focus(); + if (!hwnd) hwnd = get_active_window(); + NtUserPostMessage( hwnd, WM_INPUTLANGCHANGEREQUEST, + 0 /*FIXME*/, (LPARAM)NtUserGetKeyboardLayout(0) ); return TRUE; } @@ -2136,7 +2136,7 @@ INT X11DRV_GetKeyNameText( LONG lParam, LPWSTR lpBuffer, INT nSize ) scanCode = lParam >> 16; scanCode &= 0x1ff; /* keep "extended-key" flag with code */ - vkey = X11DRV_MapVirtualKeyEx(scanCode, MAPVK_VSC_TO_VK_EX, GetKeyboardLayout(0)); + vkey = X11DRV_MapVirtualKeyEx( scanCode, MAPVK_VSC_TO_VK_EX, NtUserGetKeyboardLayout(0) ); /* handle "don't care" bit (0x02000000) */ if (!(lParam & 0x02000000)) { @@ -2159,7 +2159,7 @@ INT X11DRV_GetKeyNameText( LONG lParam, LPWSTR lpBuffer, INT nSize ) } } - ansi = X11DRV_MapVirtualKeyEx(vkey, MAPVK_VK_TO_CHAR, GetKeyboardLayout(0)); + ansi = X11DRV_MapVirtualKeyEx( vkey, MAPVK_VK_TO_CHAR, NtUserGetKeyboardLayout(0) ); TRACE("scan 0x%04x, vkey 0x%04X, ANSI 0x%04x\n", scanCode, vkey, ansi); /* first get the name of the "regular" keys which is the Upper case @@ -2374,9 +2374,9 @@ INT X11DRV_ToUnicodeEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState, focus = x11drv_thread_data()->last_xic_hwnd; if (!focus) { - focus = GetFocus(); - if (focus) focus = GetAncestor( focus, GA_ROOT ); - if (!focus) focus = GetActiveWindow(); + focus = get_focus(); + if (focus) focus = NtUserGetAncestor( focus, GA_ROOT ); + if (!focus) focus = get_active_window(); } e.window = X11DRV_get_whole_window( focus ); xic = X11DRV_get_ic( focus ); diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index 619b0ecec1e..453b729aa42 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -318,7 +318,7 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance, FIXME("Support for allocation callbacks not implemented yet\n"); /* TODO: support child window rendering. */ - if (create_info->hwnd && GetAncestor(create_info->hwnd, GA_PARENT) != GetDesktopWindow()) + if (create_info->hwnd && NtUserGetAncestor(create_info->hwnd, GA_PARENT) != NtUserGetDesktopWindow()) { FIXME("Application requires child window rendering, which is not implemented yet!\n"); return VK_ERROR_INCOMPATIBLE_DRIVER; @@ -333,7 +333,7 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance, if (x11_surface->hwnd) { x11_surface->window = create_client_window(create_info->hwnd, &default_visual); - x11_surface->hwnd_thread_id = GetWindowThreadProcessId(x11_surface->hwnd, NULL); + x11_surface->hwnd_thread_id = NtUserGetWindowThread(x11_surface->hwnd, NULL); } else { diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 8b191ca23ed..dd5c298c7a6 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1420,7 +1420,7 @@ static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, co * still want to avoid copying invalid window bits when possible. */ if (!(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_CLIPCHILDREN )) - ExcludeUpdateRgn( hdc_dst, hwnd ); + NtUserExcludeUpdateRgn( hdc_dst, hwnd ); code = X11DRV_START_EXPOSURES; NtGdiExtEscape( hdc_dst, NULL, 0, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL ); @@ -2188,7 +2188,7 @@ void X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, if (escape.drawable) { POINT pt = { 0, 0 }; - MapWindowPoints( 0, parent, &pt, 1 ); + NtUserMapWindowPoints( 0, parent, &pt, 1 ); escape.dc_rect = *win_rect; OffsetRect( &escape.dc_rect, pt.x, pt.y ); if (flags & DCX_CLIPCHILDREN) escape.mode = ClipByChildren; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 7da1060a29c..07c36899eb3 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -857,6 +857,16 @@ static inline LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM l return NtUserMessageCall( hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE ); } +static inline LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, + UINT flags, UINT timeout, PDWORD_PTR res_ptr ) +{ + struct send_message_timeout_params params = { .flags = flags, .timeout = timeout }; + LRESULT res = NtUserMessageCall( hwnd, msg, wparam, lparam, ¶ms, + NtUserSendMessageTimeout, FALSE ); + if (res_ptr) *res_ptr = params.result; + return res; +} + static inline BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { return NtUserMessageCall( hwnd, msg, wparam, lparam, 0, NtUserSendNotifyMessage, FALSE ); diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index fb7a4405a1e..9f58246979a 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -1182,7 +1182,7 @@ static void xrandr14_free_monitors( struct gdi_monitor *monitors, int count ) static BOOL xrandr14_device_change_handler( HWND hwnd, XEvent *event ) { xrandr14_invalidate_current_mode_cache(); - if (hwnd == GetDesktopWindow() && GetWindowThreadProcessId( hwnd, NULL ) == GetCurrentThreadId()) + if (hwnd == NtUserGetDesktopWindow() && NtUserGetWindowThread( hwnd, NULL ) == GetCurrentThreadId()) { /* Don't send a WM_DISPLAYCHANGE message here because this event may be a result from * ChangeDisplaySettings(). Otherwise, ChangeDisplaySettings() would send multiple