From 24d3d22a71b5dd3123e717b3f2f50f7239a07e0e Mon Sep 17 00:00:00 2001 From: Esme Povirk Date: Fri, 14 Jun 2024 21:03:16 +0000 Subject: [PATCH] win32u: Implement EVENT_OBJECT_DESTROY. (cherry picked from commit a5c22b55445dbea184d9045f997705cf92b2c8ab) --- dlls/user32/tests/msg.c | 26 +++++++++++++------------- dlls/win32u/window.c | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index bb7b74558c4..cb66f921174 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -724,7 +724,7 @@ static const struct message WmDestroyOverlappedSeq[] = { { WM_KILLFOCUS, sent|optional|wparam, 0 }, { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_NCDESTROY, sent }, { 0 } @@ -1626,7 +1626,7 @@ static const struct message WmDestroyChildSeq[] = { { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 }, { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, { WM_SETFOCUS, sent|parent }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_DESTROY, sent|optional }, /* some other (IME?) window */ { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */ @@ -1646,7 +1646,7 @@ static const struct message WmDestroyInvisibleChildSeq[] = { { 0x0090, sent|optional }, { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY }, { WM_SHOWWINDOW, sent|wparam, 0 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_NCDESTROY, sent }, { 0 } @@ -2991,7 +2991,7 @@ static const struct message WmDestroyMDIframeSeq[] = { { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */ { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */ { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|winevent_hook_todo, OBJID_CARET, 0 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_NCDESTROY, sent }, { 0 } @@ -3040,7 +3040,7 @@ static const struct message WmDestroyMDIclientSeq[] = { { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_NCDESTROY, sent }, { 0 } @@ -3242,7 +3242,7 @@ static const struct message WmDestroyMDIchildInvisibleSeq[] = { */ { 0x0090, sent|optional }, { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */ - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_NCDESTROY, sent }, /* FIXME: Wine destroys an icon/title window while Windows doesn't */ @@ -12571,7 +12571,7 @@ static const struct message destroy_window_with_children[] = { { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */ { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */ { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */ - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, /* parent */ + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */ { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */ { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */ { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */ @@ -14253,7 +14253,7 @@ static const struct message WmQuitDialogSeq[] = { { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, { HCBT_DESTROYWND, hook }, { 0x0090, sent|optional }, /* Vista */ - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_NCDESTROY, sent }, { 0 } @@ -16987,7 +16987,7 @@ static const struct message wm_popup_menu_1[] = { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|winevent_hook_todo, OBJID_CLIENT, 0 }, { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't create a window */ { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 }, { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 }, @@ -17037,12 +17037,12 @@ static const struct message wm_popup_menu_2[] = { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|winevent_hook_todo, OBJID_CLIENT, 0 }, { HCBT_DESTROYWND, hook }, { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|winevent_hook_todo, OBJID_CLIENT, 0 }, { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */ { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 }, { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 }, @@ -17092,12 +17092,12 @@ static const struct message wm_popup_menu_3[] = { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|winevent_hook_todo, OBJID_CLIENT, 0 }, { HCBT_DESTROYWND, hook }, { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|winevent_hook_todo, OBJID_CLIENT, 0 }, { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */ { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, - { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|winevent_hook_todo, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 }, { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 }, diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 702981a27bb..a8fce495d61 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -4690,7 +4690,7 @@ HICON WINAPI NtUserInternalGetWindowIcon( HWND hwnd, UINT type ) /*********************************************************************** * send_destroy_message */ -static void send_destroy_message( HWND hwnd ) +static void send_destroy_message( HWND hwnd, BOOL winevent ) { GUITHREADINFO info; @@ -4703,6 +4703,9 @@ static void send_destroy_message( HWND hwnd ) if (hwnd == NtUserGetClipboardOwner()) release_clipboard_owner( hwnd ); + if (winevent) + NtUserNotifyWinEvent( EVENT_OBJECT_DESTROY, hwnd, OBJID_WINDOW, 0 ); + send_message( hwnd, WM_DESTROY, 0, 0); /* @@ -4718,7 +4721,7 @@ static void send_destroy_message( HWND hwnd ) for (i = 0; children[i]; i++) { - if (is_window( children[i] )) send_destroy_message( children[i] ); + if (is_window( children[i] )) send_destroy_message( children[i], FALSE ); } free( children ); } @@ -4825,7 +4828,7 @@ LRESULT destroy_window( HWND hwnd ) /*********************************************************************** * NtUserDestroyWindow (win32u.@) */ -BOOL WINAPI NtUserDestroyWindow( HWND hwnd ) +static BOOL user_destroy_window( HWND hwnd, BOOL winevent ) { BOOL is_child; @@ -4885,7 +4888,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd ) if (get_window_relative( children[i], GW_OWNER ) != hwnd) continue; if (is_current_thread_window( children[i] )) { - NtUserDestroyWindow( children[i] ); + user_destroy_window( children[i], FALSE ); got_one = TRUE; continue; } @@ -4896,13 +4899,18 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd ) } } - send_destroy_message( hwnd ); + send_destroy_message( hwnd, winevent ); if (!is_window( hwnd )) return TRUE; destroy_window( hwnd ); return TRUE; } +BOOL WINAPI NtUserDestroyWindow( HWND hwnd ) +{ + return user_destroy_window( hwnd, TRUE ); +} + /***************************************************************************** * destroy_thread_windows *