mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
125 lines
4.8 KiB
Diff
125 lines
4.8 KiB
Diff
From 2f2480806c4c431aeb75308e570a317da43f3508 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= <gabrielopcode@gmail.com>
|
|
Date: Mon, 22 Jul 2019 15:29:25 +0300
|
|
Subject: [PATCH] user32/focus: Prevent a recursive loop with the activation
|
|
messages
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
When activating a window and sending activation messages to the window
|
|
procedure, Windows avoids a recursive loop by not sending more of these
|
|
messages or hooks while it's still activating the window. Some applications
|
|
actually depend on this behavior, so it is needed.
|
|
|
|
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46274
|
|
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
|
|
---
|
|
dlls/win32u/input.c | 42 +++++++++++++++++++++++++-----------
|
|
dlls/win32u/ntuser_private.h | 1 +
|
|
2 files changed, 30 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c
|
|
index a4834b740d8..123a0ff9a94 100644
|
|
--- a/dlls/win32u/input.c
|
|
+++ b/dlls/win32u/input.c
|
|
@@ -1966,7 +1966,7 @@ BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus, DWORD new
|
|
{
|
|
HWND previous = get_active_window();
|
|
BOOL ret;
|
|
- DWORD old_thread, new_thread;
|
|
+ DWORD winflags, old_thread, new_thread;
|
|
CBTACTIVATESTRUCT cbt;
|
|
|
|
if (previous == hwnd)
|
|
@@ -1975,16 +1975,24 @@ BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus, DWORD new
|
|
goto done;
|
|
}
|
|
|
|
- /* call CBT hook chain */
|
|
- cbt.fMouse = mouse;
|
|
- cbt.hWndActive = previous;
|
|
- if (call_hooks( WH_CBT, HCBT_ACTIVATE, (WPARAM)hwnd, (LPARAM)&cbt, sizeof(cbt) )) return FALSE;
|
|
-
|
|
- if (is_window( previous ))
|
|
+ /* Prevent a recursive activation loop with the activation messages */
|
|
+ winflags = win_set_flags(hwnd, WIN_IS_IN_ACTIVATION, 0);
|
|
+ if (!(winflags & WIN_IS_IN_ACTIVATION))
|
|
{
|
|
- send_message( previous, WM_NCACTIVATE, FALSE, (LPARAM)hwnd );
|
|
- send_message( previous, WM_ACTIVATE,
|
|
- MAKEWPARAM( WA_INACTIVE, is_iconic(previous) ), (LPARAM)hwnd );
|
|
+ ret = FALSE;
|
|
+
|
|
+ /* call CBT hook chain */
|
|
+ cbt.fMouse = mouse;
|
|
+ cbt.hWndActive = previous;
|
|
+ if (call_hooks( WH_CBT, HCBT_ACTIVATE, (WPARAM)hwnd, (LPARAM)&cbt, sizeof(cbt) ))
|
|
+ goto clear_flags;
|
|
+
|
|
+ if (is_window(previous))
|
|
+ {
|
|
+ send_message( previous, WM_NCACTIVATE, FALSE, (LPARAM)hwnd );
|
|
+ send_message( previous, WM_ACTIVATE,
|
|
+ MAKEWPARAM( WA_INACTIVE, is_iconic(previous) ), (LPARAM)hwnd );
|
|
+ }
|
|
}
|
|
|
|
SERVER_START_REQ( set_active_window )
|
|
@@ -2006,7 +2014,11 @@ BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus, DWORD new
|
|
if (send_message( hwnd, WM_QUERYNEWPALETTE, 0, 0 ))
|
|
send_message_timeout( HWND_BROADCAST, WM_PALETTEISCHANGING, (WPARAM)hwnd, 0,
|
|
SMTO_ABORTIFHUNG, 2000, FALSE );
|
|
- if (!is_window(hwnd)) return FALSE;
|
|
+ if (!is_window(hwnd))
|
|
+ {
|
|
+ ret = FALSE;
|
|
+ goto clear_flags;
|
|
+ }
|
|
}
|
|
|
|
old_thread = previous ? get_window_thread( previous, NULL ) : 0;
|
|
@@ -2039,7 +2051,7 @@ BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus, DWORD new
|
|
}
|
|
}
|
|
|
|
- if (is_window(hwnd))
|
|
+ if (!(winflags & WIN_IS_IN_ACTIVATION) && is_window(hwnd))
|
|
{
|
|
send_message( hwnd, WM_NCACTIVATE, hwnd == NtUserGetForegroundWindow(), (LPARAM)previous );
|
|
send_message( hwnd, WM_ACTIVATE,
|
|
@@ -2064,13 +2076,17 @@ BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus, DWORD new
|
|
}
|
|
}
|
|
|
|
+clear_flags:
|
|
+ win_set_flags(hwnd, 0, WIN_IS_IN_ACTIVATION);
|
|
+
|
|
done:
|
|
if (hwnd)
|
|
{
|
|
if (hwnd == NtUserGetForegroundWindow()) user_driver->pActivateWindow( hwnd, previous );
|
|
clip_fullscreen_window( hwnd, FALSE );
|
|
}
|
|
- return TRUE;
|
|
+
|
|
+ return ret;
|
|
}
|
|
|
|
/**********************************************************************
|
|
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
|
|
index 2f3bbdf91c0..74f5b07bd46 100644
|
|
--- a/dlls/win32u/ntuser_private.h
|
|
+++ b/dlls/win32u/ntuser_private.h
|
|
@@ -92,6 +92,7 @@ typedef struct tagWND
|
|
#define WIN_NEEDS_SHOW_OWNEDPOPUP 0x0020 /* WM_SHOWWINDOW:SC_SHOW must be sent in the next ShowOwnedPopup call */
|
|
#define WIN_CHILDREN_MOVED 0x0040 /* children may have moved, ignore stored positions */
|
|
#define WIN_HAS_IME_WIN 0x0080 /* the window has been registered with imm32 */
|
|
+#define WIN_IS_IN_ACTIVATION 0x0100 /* the window is in an activation process */
|
|
|
|
#define WND_OTHER_PROCESS ((WND *)1) /* returned by get_win_ptr on unknown window handles */
|
|
#define WND_DESKTOP ((WND *)2) /* returned by get_win_ptr on the desktop window */
|
|
--
|
|
2.47.2
|
|
|