From: Jacek Caban jacek@codeweavers.com
And use it instead of WINPOS_ActivateOtherWindow. --- dlls/user32/dialog.c | 2 +- dlls/user32/win.h | 2 -- dlls/user32/winpos.c | 62 -------------------------------------------- dlls/win32u/window.c | 4 +++ include/ntuser.h | 6 +++++ 5 files changed, 11 insertions(+), 65 deletions(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index fc7ddb303ff..9773f67df13 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -949,7 +949,7 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval ) if (owner) SetForegroundWindow( owner ); else - WINPOS_ActivateOtherWindow( hwnd ); + NtUserActivateOtherWindow( hwnd ); }
/* unblock dialog loop */ diff --git a/dlls/user32/win.h b/dlls/user32/win.h index 9c61d5ce0a3..ae470739cbe 100644 --- a/dlls/user32/win.h +++ b/dlls/user32/win.h @@ -35,8 +35,6 @@ extern HWND *WIN_ListChildren( HWND hwnd ) DECLSPEC_HIDDEN; extern void MDI_CalcDefaultChildPos( HWND hwndClient, INT total, LPPOINT lpPos, INT delta, UINT *id ) DECLSPEC_HIDDEN; extern HDESK open_winstation_desktop( HWINSTA hwinsta, LPCWSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access ) DECLSPEC_HIDDEN;
-extern void WINPOS_ActivateOtherWindow( HWND hwnd ) DECLSPEC_HIDDEN; - static inline void mirror_rect( const RECT *window_rect, RECT *rect ) { int width = window_rect->right - window_rect->left; diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index f7f4e8bb427..97a2228d00c 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -242,68 +242,6 @@ BOOL WINAPI AnimateWindow(HWND hwnd, DWORD dwTime, DWORD dwFlags) }
-/******************************************************************* - * can_activate_window - * - * Check if we can activate the specified window. - */ -static BOOL can_activate_window( HWND hwnd ) -{ - LONG style; - - if (!hwnd) return FALSE; - style = GetWindowLongW( hwnd, GWL_STYLE ); - if (!(style & WS_VISIBLE)) return FALSE; - if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; - return !(style & WS_DISABLED); -} - - -/******************************************************************* - * WINPOS_ActivateOtherWindow - * - * Activates window other than pWnd. - */ -void WINPOS_ActivateOtherWindow(HWND hwnd) -{ - HWND hwndTo, fg; - - if ((GetWindowLongW( hwnd, GWL_STYLE ) & WS_POPUP) && (hwndTo = GetWindow( hwnd, GW_OWNER ))) - { - hwndTo = NtUserGetAncestor( hwndTo, GA_ROOT ); - if (can_activate_window( hwndTo )) goto done; - } - - hwndTo = hwnd; - for (;;) - { - if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break; - if (can_activate_window( hwndTo )) goto done; - } - - hwndTo = GetTopWindow( 0 ); - for (;;) - { - if (hwndTo == hwnd) - { - hwndTo = 0; - break; - } - if (can_activate_window( hwndTo )) goto done; - if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break; - } - - done: - fg = NtUserGetForegroundWindow(); - TRACE("win = %p fg = %p\n", hwndTo, fg); - if (!fg || (hwnd == fg)) - { - if (SetForegroundWindow( hwndTo )) return; - } - if (!NtUserSetActiveWindow( hwndTo )) NtUserSetActiveWindow( 0 ); -} - - /*********************************************************************** * BeginDeferWindowPos (USER32.@) */ diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index d9c771e5d3d..d53dfde2fbb 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5364,6 +5364,10 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code ) { switch (code) { + case NtUserCallHwnd_ActivateOtherWindow: + activate_other_window( hwnd ); + return 0; + case NtUserCallHwnd_ArrangeIconicWindows: return arrange_iconic_windows( hwnd );
diff --git a/include/ntuser.h b/include/ntuser.h index f7fa18ee983..961d34d4db6 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1126,6 +1126,7 @@ static inline BOOL NtUserUnhookWindowsHook( INT id, HOOKPROC proc ) /* NtUserCallHwnd codes, not compatible with Windows */ enum { + NtUserCallHwnd_ActivateOtherWindow, NtUserCallHwnd_ArrangeIconicWindows, NtUserCallHwnd_DrawMenuBar, NtUserCallHwnd_GetDefaultImeWindow, @@ -1149,6 +1150,11 @@ enum NtUserIsCurrehtThreadWindow, };
+static inline void NtUserActivateOtherWindow( HWND hwnd ) +{ + NtUserCallHwnd( hwnd, NtUserCallHwnd_ActivateOtherWindow ); +} + static inline UINT NtUserArrangeIconicWindows( HWND parent ) { return NtUserCallHwnd( parent, NtUserCallHwnd_ArrangeIconicWindows );