[PATCH v2 5/5] user32: Send WM_NCACTIVATE on SetForegroundWindow call.
Rémi Bernon
rbernon at codeweavers.com
Wed Sep 2 12:01:02 CDT 2020
When window is already active but has lost foreground, as shown by
concurrent SetForegroundWindow tests.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/user32/focus.c | 4 ++++
dlls/user32/tests/win.c | 42 ++++++++++++++++++++---------------------
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index b88a711b05e..db4fe0dfb15 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -232,6 +232,10 @@ static BOOL set_foreground_window( HWND hwnd, BOOL mouse )
else if (send_msg_new) /* old window belongs to us but new one to other thread */
ret = set_active_window( 0, NULL, mouse, TRUE, active_gen_old + 1 );
+ /* already active, set_active_window will do no nothing */
+ if (!send_msg_new && hwnd == GetActiveWindow())
+ SendMessageW( hwnd, WM_NCACTIVATE, TRUE, (LPARAM)hwnd );
+
if (send_msg_new) /* new window belongs to other thread */
SendNotifyMessageW( hwnd, WM_WINE_SETACTIVEWINDOW, (WPARAM)hwnd, (LPARAM)active_gen_new );
else /* new window belongs to us */
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 75a4cdc42d5..cff334368b9 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -3266,33 +3266,32 @@ struct test_sfw_test_desc
BOOL todo_msgcount_before_set_foreground;
int msgcount_before_set_foreground;
- BOOL todo_msgcount_after_set_foreground;
int msgcount_after_set_foreground;
int msgcount_after_peek_message;
int expected_window;
};
static struct test_sfw_test_desc test_sfw_tests[] = {
- {1, FALSE, FALSE, FALSE, FALSE, 0, FALSE, 0, 6, 0},
- {1, TRUE, FALSE, FALSE, FALSE, 0, TRUE, 1, 6, 0},
- {1, FALSE, TRUE, FALSE, FALSE, 0, FALSE, 0, 6, 0},
- {1, TRUE, TRUE, FALSE, FALSE, 0, TRUE, 1, 6, 0},
- {1, FALSE, FALSE, TRUE, FALSE, 0, FALSE, 0, 6, 0},
- {1, TRUE, FALSE, TRUE, FALSE, 0, TRUE, 1, 6, 0},
-
- {2, FALSE, FALSE, FALSE, FALSE, 0, FALSE, 6, 0, 1},
- {2, TRUE, FALSE, FALSE, FALSE, 0, FALSE, 6, 0, 1},
- {2, FALSE, TRUE, FALSE, FALSE, 6, FALSE, 0, 0, 1},
- {2, TRUE, TRUE, FALSE, FALSE, 6, TRUE, 1, 6, 0},
- {2, FALSE, FALSE, TRUE, TRUE, 8, FALSE, 0, 0, 1},
- {2, TRUE, FALSE, TRUE, TRUE, 8, TRUE, 1, 6, 0},
-
- {0, FALSE, FALSE, FALSE, FALSE, 0, FALSE, 6, 0, 1},
- {0, TRUE, FALSE, FALSE, FALSE, 0, FALSE, 6, 0, 1},
- {0, FALSE, TRUE, FALSE, FALSE, 6, FALSE, 0, 0, 1},
- {0, TRUE, TRUE, FALSE, FALSE, 6, TRUE, 1, 6, 0},
- {0, FALSE, FALSE, TRUE, TRUE, 8, FALSE, 0, 0, 1},
- {0, TRUE, FALSE, TRUE, TRUE, 8, TRUE, 1, 6, 0},
+ {1, FALSE, FALSE, FALSE, FALSE, 0, 0, 6, 0},
+ {1, TRUE, FALSE, FALSE, FALSE, 0, 1, 6, 0},
+ {1, FALSE, TRUE, FALSE, FALSE, 0, 0, 6, 0},
+ {1, TRUE, TRUE, FALSE, FALSE, 0, 1, 6, 0},
+ {1, FALSE, FALSE, TRUE, FALSE, 0, 0, 6, 0},
+ {1, TRUE, FALSE, TRUE, FALSE, 0, 1, 6, 0},
+
+ {2, FALSE, FALSE, FALSE, FALSE, 0, 6, 0, 1},
+ {2, TRUE, FALSE, FALSE, FALSE, 0, 6, 0, 1},
+ {2, FALSE, TRUE, FALSE, FALSE, 6, 0, 0, 1},
+ {2, TRUE, TRUE, FALSE, FALSE, 6, 1, 6, 0},
+ {2, FALSE, FALSE, TRUE, TRUE, 8, 0, 0, 1},
+ {2, TRUE, FALSE, TRUE, TRUE, 8, 1, 6, 0},
+
+ {0, FALSE, FALSE, FALSE, FALSE, 0, 6, 0, 1},
+ {0, TRUE, FALSE, FALSE, FALSE, 0, 6, 0, 1},
+ {0, FALSE, TRUE, FALSE, FALSE, 6, 0, 0, 1},
+ {0, TRUE, TRUE, FALSE, FALSE, 6, 1, 6, 0},
+ {0, FALSE, FALSE, TRUE, TRUE, 8, 0, 0, 1},
+ {0, TRUE, FALSE, TRUE, TRUE, 8, 1, 6, 0},
};
static DWORD WINAPI test_sfw_thread( void *param )
@@ -3357,7 +3356,6 @@ static DWORD WINAPI test_sfw_thread( void *param )
test_sfw_msg_count = 0;
SetForegroundWindow( windows[1] );
- todo_wine_if( test->todo_msgcount_after_set_foreground )
ok( test_sfw_msg_count == test->msgcount_after_set_foreground,
"%d: Unexpected number of messages received after SetForegroundWindow: %d\n", i, test_sfw_msg_count );
--
2.28.0
More information about the wine-devel
mailing list