From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/user32/tests/win.c | 1 - dlls/win32u/ntuser_private.h | 1 + dlls/win32u/window.c | 17 ++++++++++++++++- dlls/winex11.drv/event.c | 17 ++++++++++++++++- server/protocol.def | 1 + server/window.c | 5 +++++ 6 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 173c029a7b5..cc0b53e9822 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -13117,7 +13117,6 @@ static void test_activate(void) foreground_window = GetForegroundWindow(); todo_wine_if(foreground_window != hwnd1) ok(GetForegroundWindow() == hwnd1, "Got unexpected foreground window.\n"); - todo_wine ok(!hwnd3_got_wm_activate, "Expected WM_ACTIVATE not sent to hwnd3.\n");
DestroyWindow(hwnd3); diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 3b6cab5bdc9..48bd0dbffb7 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -259,5 +259,6 @@ static inline UINT win_get_flags( HWND hwnd ) WND *get_win_ptr( HWND hwnd ); BOOL is_child( HWND parent, HWND child ); BOOL is_window( HWND hwnd ); +BOOL is_window_ever_activated( HWND hwnd );
#endif /* __WINE_NTUSER_PRIVATE_H */ diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 69dd8caba5d..c3f368c6de5 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -311,6 +311,20 @@ BOOL is_window( HWND hwnd ) return ret; }
+BOOL is_window_ever_activated( HWND hwnd ) +{ + BOOL ret = FALSE; + + SERVER_START_REQ( get_window_info ) + { + req->handle = wine_server_user_handle( hwnd ); + if (!wine_server_call_err( req )) + ret = reply->is_ever_activated; + } + SERVER_END_REQ; + return ret; +} + /* see GetWindowThreadProcessId */ DWORD get_window_thread( HWND hwnd, DWORD *process ) { @@ -3765,7 +3779,8 @@ static BOOL can_activate_window( HWND hwnd ) style = get_window_long( hwnd, GWL_STYLE ); if (!(style & WS_VISIBLE)) return FALSE; if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; - return !(style & WS_DISABLED); + if (style & WS_DISABLED) return FALSE; + return is_window_ever_activated( hwnd ); }
/******************************************************************* diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 8b02361aaff..ed7ab78702c 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -521,6 +521,20 @@ DWORD EVENT_x11_time_to_win32_time(Time time)
}
+static BOOL is_window_ever_activated( HWND hwnd ) +{ + BOOL ret = FALSE; + + SERVER_START_REQ( get_window_info ) + { + req->handle = wine_server_user_handle( hwnd ); + if (!wine_server_call_err( req )) + ret = reply->is_ever_activated; + } + SERVER_END_REQ; + return ret; +} + /******************************************************************* * can_activate_window * @@ -537,7 +551,8 @@ static inline BOOL can_activate_window( HWND hwnd ) if (NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_NOACTIVATE) return FALSE; if (hwnd == NtUserGetDesktopWindow()) return FALSE; if (NtUserGetWindowRect( hwnd, &rect ) && IsRectEmpty( &rect )) return FALSE; - return !(style & WS_DISABLED); + if (style & WS_DISABLED) return FALSE; + return is_window_ever_activated( hwnd ); }
diff --git a/server/protocol.def b/server/protocol.def index 8b51618ebe0..a50b1190ad3 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2411,6 +2411,7 @@ enum message_type thread_id_t tid; /* thread owning the window */ atom_t atom; /* class atom */ int is_unicode; /* ANSI or unicode */ + int is_ever_activated; /* Ever activated */ int dpi; /* window DPI */ int awareness; /* DPI awareness */ @END diff --git a/server/window.c b/server/window.c index 242e93f303a..a6f65cdcd66 100644 --- a/server/window.c +++ b/server/window.c @@ -80,6 +80,7 @@ struct window unsigned int is_linked : 1; /* is it linked into the parent z-order list? */ unsigned int is_layered : 1; /* has layered info been set? */ unsigned int is_orphan : 1; /* is window orphaned */ + unsigned int is_ever_activated : 1; /* is window ever activated */ unsigned int color_key; /* color key for a layered window */ unsigned int alpha; /* alpha value for a layered window */ unsigned int layered_flags; /* flags for a layered window */ @@ -573,6 +574,7 @@ static struct window *create_window( struct window *parent, struct window *owner win->is_linked = 0; win->is_layered = 0; win->is_orphan = 0; + win->is_ever_activated = 0; win->dpi_awareness = DPI_AWARENESS_PER_MONITOR_AWARE; win->dpi = 0; win->user_data = 0; @@ -2220,6 +2222,7 @@ DECL_HANDLER(get_window_info) reply->full_handle = win->handle; reply->last_active = win->handle; reply->is_unicode = win->is_unicode; + reply->is_ever_activated = win->is_ever_activated; reply->awareness = win->dpi_awareness; reply->dpi = win->dpi ? win->dpi : get_monitor_dpi( win ); if (get_user_object( win->last_active, USER_WINDOW )) reply->last_active = win->last_active; @@ -2477,6 +2480,8 @@ DECL_HANDLER(set_window_pos) mirror_rect( &win->parent->client_rect, &valid_rect ); }
+ if (!win->is_ever_activated && !(flags & SWP_NOACTIVATE)) win->is_ever_activated = 1; + win->paint_flags = (win->paint_flags & ~PAINT_CLIENT_FLAGS) | (req->paint_flags & PAINT_CLIENT_FLAGS); if (win->paint_flags & PAINT_HAS_PIXEL_FORMAT) update_pixel_format_flags( win );