Jacek Caban : win32u: Move NtUserGetForegroundWindow implementation from user32.
Alexandre Julliard
julliard at winehq.org
Thu Feb 17 15:33:59 CST 2022
Module: wine
Branch: master
Commit: fa3bd8f417123848c343c45f93a152cd42b3e5ff
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fa3bd8f417123848c343c45f93a152cd42b3e5ff
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Feb 17 15:43:07 2022 +0100
win32u: Move NtUserGetForegroundWindow implementation from user32.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/focus.c | 19 +------------------
dlls/user32/message.c | 2 +-
dlls/user32/user32.spec | 2 +-
dlls/user32/user_main.c | 2 +-
dlls/user32/win.c | 2 +-
dlls/user32/winpos.c | 2 +-
dlls/win32u/input.c | 16 ++++++++++++++++
dlls/win32u/syscall.c | 1 +
dlls/win32u/win32u.spec | 2 +-
dlls/wow64win/syscall.h | 1 +
dlls/wow64win/user.c | 5 +++++
include/ntuser.h | 1 +
12 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index 4ba2bfef193..a5fc376bdc6 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -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]
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index a5fcc9068a7..b4850cc1937 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -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:
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec
index d60b424321b..3baa7594e84 100644
--- a/dlls/user32/user32.spec
+++ b/dlls/user32/user32.spec
@@ -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)
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index a91db57cdb4..8ca55b283f7 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -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))
{
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index ee16144b179..1a037297ac1 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -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 );
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index abf9c25e6c6..db3408c63ba 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -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))
{
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c
index d73b03fe7fd..9c7a7e75253 100644
--- a/dlls/win32u/input.c
+++ b/dlls/win32u/input.c
@@ -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;
+}
diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c
index d97688d7c8c..2d37d605479 100644
--- a/dlls/win32u/syscall.c
+++ b/dlls/win32u/syscall.c
@@ -115,6 +115,7 @@ static void * const syscalls[] =
NtUserGetCursor,
NtUserGetDoubleClickTime,
NtUserGetDpiForMonitor,
+ NtUserGetForegroundWindow,
NtUserGetKeyState,
NtUserGetKeyboardLayout,
NtUserGetKeyboardLayoutName,
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index 20faca70c5e..03ab1ff885c 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -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
diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h
index 47e95a98a4b..22140c33f80 100644
--- a/dlls/wow64win/syscall.h
+++ b/dlls/wow64win/syscall.h
@@ -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 ) \
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c
index cd4dc32d407..a2be5fedb36 100644
--- a/dlls/wow64win/user.c
+++ b/dlls/wow64win/user.c
@@ -415,3 +415,8 @@ NTSTATUS WINAPI wow64_NtUserUnhookWindowsHookEx( UINT *args )
return NtUserUnhookWindowsHookEx( handle );
}
+
+NTSTATUS WINAPI wow64_NtUserGetForegroundWindow( UINT *args )
+{
+ return HandleToUlong( NtUserGetForegroundWindow() );
+}
diff --git a/include/ntuser.h b/include/ntuser.h
index 6e941c29c6d..51f1c624ba6 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -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 );
More information about the wine-cvs
mailing list