Skip to content

Commit

Permalink
win32u: Implement EVENT_OBJECT_DESTROY.
Browse files Browse the repository at this point in the history
  • Loading branch information
Esme Povirk authored and julliard committed Jul 16, 2024
1 parent 2251f1c commit a5c22b5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
26 changes: 13 additions & 13 deletions dlls/user32/tests/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,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|msg_todo, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
{ WM_DESTROY, sent },
{ WM_NCDESTROY, sent },
{ 0 }
Expand Down Expand Up @@ -1644,7 +1644,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|msg_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 */
Expand All @@ -1664,7 +1664,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|msg_todo, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
{ WM_DESTROY, sent },
{ WM_NCDESTROY, sent },
{ 0 }
Expand Down Expand Up @@ -3017,7 +3017,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|msg_todo, OBJID_CARET, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|msg_todo, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
{ WM_DESTROY, sent },
{ WM_NCDESTROY, sent },
{ 0 }
Expand Down Expand Up @@ -3066,7 +3066,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|msg_todo, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
{ WM_DESTROY, sent },
{ WM_NCDESTROY, sent },
{ 0 }
Expand Down Expand Up @@ -3268,7 +3268,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|msg_todo, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
{ WM_DESTROY, sent },
{ WM_NCDESTROY, sent },
{ 0 }
Expand Down Expand Up @@ -12806,7 +12806,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|msg_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 */
Expand Down Expand Up @@ -14493,7 +14493,7 @@ static const struct message WmQuitDialogSeq[] = {
{ EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam|msg_todo, 0, 0 },
{ HCBT_DESTROYWND, hook },
{ 0x0090, sent|optional }, /* Vista */
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|msg_todo, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
{ WM_DESTROY, sent },
{ WM_NCDESTROY, sent },
{ 0 }
Expand Down Expand Up @@ -17245,7 +17245,7 @@ static const struct message wm_popup_menu_1[] =
{ EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|msg_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|msg_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 },
Expand Down Expand Up @@ -17295,12 +17295,12 @@ static const struct message wm_popup_menu_2[] =
{ EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|msg_todo, OBJID_CLIENT, 0 },
{ HCBT_DESTROYWND, hook },
{ EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|msg_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|msg_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|msg_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 },
Expand Down Expand Up @@ -17350,12 +17350,12 @@ static const struct message wm_popup_menu_3[] =
{ EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam|msg_todo, OBJID_CLIENT, 0 },
{ HCBT_DESTROYWND, hook },
{ EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
{ EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam|msg_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|msg_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|msg_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 },
Expand Down
18 changes: 13 additions & 5 deletions dlls/win32u/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -4759,7 +4759,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;

Expand All @@ -4772,6 +4772,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);

/*
Expand All @@ -4787,7 +4790,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 );
}
Expand Down Expand Up @@ -4897,7 +4900,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;

Expand Down Expand Up @@ -4957,7 +4960,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;
}
Expand All @@ -4968,13 +4971,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
*
Expand Down

0 comments on commit a5c22b5

Please sign in to comment.