win32u: Move NtUserGetForegroundWindow 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-02-17 15:43:07 +01:00 committed by Alexandre Julliard
parent e557f48cdf
commit fa3bd8f417
12 changed files with 31 additions and 24 deletions

View File

@ -161,7 +161,7 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
if (IsWindow(hwnd))
{
SendMessageW( hwnd, WM_NCACTIVATE, (hwnd == GetForegroundWindow()), (LPARAM)previous );
SendMessageW( hwnd, WM_NCACTIVATE, hwnd == NtUserGetForegroundWindow(), (LPARAM)previous );
SendMessageW( hwnd, WM_ACTIVATE,
MAKEWPARAM( mouse ? WA_CLICKACTIVE : WA_ACTIVE, IsIconic(hwnd) ),
(LPARAM)previous );
@ -371,23 +371,6 @@ HWND WINAPI GetFocus(void)
}
/*******************************************************************
* GetForegroundWindow (USER32.@)
*/
HWND WINAPI GetForegroundWindow(void)
{
HWND ret = 0;
SERVER_START_REQ( get_thread_input )
{
req->tid = 0;
if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->foreground );
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* SetShellWindowEx (USER32.@)
* hwndShell = Progman[Program Manager]

View File

@ -1876,7 +1876,7 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR
if (is_desktop_window( hwnd )) return 0;
return WIN_SetStyle(hwnd, wparam, lparam);
case WM_WINE_SETACTIVEWINDOW:
if (!wparam && GetForegroundWindow() == hwnd) return 0;
if (!wparam && NtUserGetForegroundWindow() == hwnd) return 0;
return (LRESULT)SetActiveWindow( (HWND)wparam );
case WM_WINE_KEYBOARD_LL_HOOK:
case WM_WINE_MOUSE_LL_HOOK:

View File

@ -302,7 +302,7 @@
@ stdcall GetDpiForSystem()
@ stdcall GetDpiForWindow(long)
@ stdcall GetFocus()
@ stdcall GetForegroundWindow()
@ stdcall GetForegroundWindow() NtUserGetForegroundWindow
@ stdcall GetGestureConfig(long long long ptr ptr long)
@ stdcall GetGestureInfo(long ptr)
@ stdcall GetGUIThreadInfo(long ptr)

View File

@ -97,7 +97,7 @@ static HPALETTE WINAPI UserSelectPalette( HDC hDC, HPALETTE hPal, BOOL bForceBac
HWND hwnd = WindowFromDC( hDC );
if (hwnd)
{
HWND hForeground = GetForegroundWindow();
HWND hForeground = NtUserGetForegroundWindow();
/* set primary palette if it's related to current active */
if (hForeground == hwnd || IsChild(hForeground,hwnd))
{

View File

@ -3843,7 +3843,7 @@ BOOL WINAPI FlashWindowEx( PFLASHWINFO pfinfo )
hwnd = wndPtr->obj.handle; /* make it a full handle */
if (pfinfo->dwFlags) wparam = !(wndPtr->flags & WIN_NCACTIVATED);
else wparam = (hwnd == GetForegroundWindow());
else wparam = (hwnd == NtUserGetForegroundWindow());
WIN_ReleasePtr( wndPtr );
SendMessageW( hwnd, WM_NCACTIVATE, wparam, 0 );

View File

@ -1640,7 +1640,7 @@ void WINPOS_ActivateOtherWindow(HWND hwnd)
}
done:
fg = GetForegroundWindow();
fg = NtUserGetForegroundWindow();
TRACE("win = %p fg = %p\n", hwndTo, fg);
if (!fg || (hwnd == fg))
{

View File

@ -1004,3 +1004,19 @@ int WINAPI NtUserGetMouseMovePointsEx( UINT size, MOUSEMOVEPOINT *ptin, MOUSEMOV
return copied;
}
/*******************************************************************
* NtUserGetForegroundWindow (win32u.@)
*/
HWND WINAPI NtUserGetForegroundWindow(void)
{
HWND ret = 0;
SERVER_START_REQ( get_thread_input )
{
req->tid = 0;
if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->foreground );
}
SERVER_END_REQ;
return ret;
}

View File

@ -115,6 +115,7 @@ static void * const syscalls[] =
NtUserGetCursor,
NtUserGetDoubleClickTime,
NtUserGetDpiForMonitor,
NtUserGetForegroundWindow,
NtUserGetKeyState,
NtUserGetKeyboardLayout,
NtUserGetKeyboardLayoutName,

View File

@ -926,7 +926,7 @@
@ stub NtUserGetDpiForCurrentProcess
@ stdcall -syscall NtUserGetDpiForMonitor(long long ptr ptr)
@ stub NtUserGetExtendedPointerDeviceProperty
@ stub NtUserGetForegroundWindow
@ stdcall -syscall NtUserGetForegroundWindow()
@ stub NtUserGetGUIThreadInfo
@ stub NtUserGetGestureConfig
@ stub NtUserGetGestureExtArgs

View File

@ -102,6 +102,7 @@
SYSCALL_ENTRY( NtUserGetCursor ) \
SYSCALL_ENTRY( NtUserGetDoubleClickTime ) \
SYSCALL_ENTRY( NtUserGetDpiForMonitor ) \
SYSCALL_ENTRY( NtUserGetForegroundWindow ) \
SYSCALL_ENTRY( NtUserGetKeyState ) \
SYSCALL_ENTRY( NtUserGetKeyboardLayout ) \
SYSCALL_ENTRY( NtUserGetKeyboardLayoutName ) \

View File

@ -415,3 +415,8 @@ NTSTATUS WINAPI wow64_NtUserUnhookWindowsHookEx( UINT *args )
return NtUserUnhookWindowsHookEx( handle );
}
NTSTATUS WINAPI wow64_NtUserGetForegroundWindow( UINT *args )
{
return HandleToUlong( NtUserGetForegroundWindow() );
}

View File

@ -156,6 +156,7 @@ LONG WINAPI NtUserGetDisplayConfigBufferSizes( UINT32 flags, UINT32 *num_path
UINT32 *num_mode_info );
UINT WINAPI NtUserGetDoubleClickTime(void);
BOOL WINAPI NtUserGetDpiForMonitor( HMONITOR monitor, UINT type, UINT *x, UINT *y );
HWND WINAPI NtUserGetForegroundWindow(void);
INT WINAPI NtUserGetKeyNameText( LONG lparam, WCHAR *buffer, INT size );
SHORT WINAPI NtUserGetKeyState( INT vkey );
HKL WINAPI NtUserGetKeyboardLayout( DWORD thread_id );