From cfe842961be00550636f7c45c8d2b5209fbc9eda Mon Sep 17 00:00:00 2001 From: Lauri Nurmi Date: Mon, 19 Feb 2024 12:39:46 +0200 Subject: [PATCH] Fix toast notification always posting the click event on MSW No idea why this is needed, but would seem to fix #24320. --- src/msw/rt/notifmsgrt.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/msw/rt/notifmsgrt.cpp b/src/msw/rt/notifmsgrt.cpp index eeab0a3b7f40..0cc8ece7178b 100644 --- a/src/msw/rt/notifmsgrt.cpp +++ b/src/msw/rt/notifmsgrt.cpp @@ -418,13 +418,31 @@ wxString wxToastNotifMsgImpl::ms_appId; wxCOMPtr wxToastNotifMsgImpl::ms_toastMgr; HRESULT wxToastEventHandler::Invoke( - IToastNotification *WXUNUSED(sender), - IInspectable *WXUNUSED(args)) + IToastNotification *sender, + IInspectable *args) { if ( m_impl ) { - wxCommandEvent evt(wxEVT_NOTIFICATION_MESSAGE_CLICK); - m_impl->ProcessNotificationEvent(evt); + IToastDismissedEventArgs *dea = nullptr; + IToastFailedEventArgs *fea = nullptr; + + if ( SUCCEEDED(args->QueryInterface(__uuidof(IToastDismissedEventArgs), (void**)&dea)) ) + { + // FIXME: We have for some unknown reason ended up in this function even though + // args is really a IToastDismissedEventArgs*. Call the actual implementation + // we wanted. + return Invoke(sender, dea); + } + else if ( SUCCEEDED(args->QueryInterface(__uuidof(IToastFailedEventArgs), (void**)&fea)) ) + { + // FIXME: Same as above. + return Invoke(sender, fea); + } + else + { + wxCommandEvent evt(wxEVT_NOTIFICATION_MESSAGE_CLICK); + m_impl->ProcessNotificationEvent(evt); + } } return S_OK;