Skip to content

Commit

Permalink
win32u: Implement EVENT_OBJECT_DESTROY.
Browse files Browse the repository at this point in the history
(cherry picked from commit a5c22b5)
  • Loading branch information
Esme Povirk committed Jul 19, 2024
1 parent 89fa01e commit 03bcca0
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 @@ -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 }
Expand Down Expand Up @@ -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 */
Expand All @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down
18 changes: 13 additions & 5 deletions dlls/win32u/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

/*
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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
*
Expand Down

0 comments on commit 03bcca0

Please sign in to comment.