Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toast notification always posting the click event on MSW #24341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lanurmi
Copy link
Contributor

@lanurmi lanurmi commented Feb 19, 2024

No idea why this is needed, but would seem to fix #24320.

No idea why this is needed, but would seem to fix wxWidgets#24320.
Copy link
Contributor

@vadz vadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the correct thing to do would be to use 3 different handlers, implementing DesktopToastActivatedEventHandler, DesktopToastDismissedEventHandler and DesktopToastFailedEventHandler respectively instead of a single one.

This should be straightforward to do, AFAICS and we actually only need 2 of them as the third one would do nothing anyhow.

Could you please try to do it like this? TIA!

IToastDismissedEventArgs *dea = nullptr;
IToastFailedEventArgs *fea = nullptr;

if ( SUCCEEDED(args->QueryInterface(__uuidof(IToastDismissedEventArgs), (void**)&dea)) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to call Release() on dea in case of success to avoid memory leaks (and the same for fea below, of course).

@lanurmi
Copy link
Contributor Author

lanurmi commented Feb 26, 2024

I think the correct thing to do would be to use 3 different handlers, implementing DesktopToastActivatedEventHandler, DesktopToastDismissedEventHandler and DesktopToastFailedEventHandler respectively instead of a single one.

Do you mean doing it the way it is already done in master? The thing is that it fails to work correctly, at least not for me. The overload of Invoke taking IInspectable* always gets called.

Regardless, some unanswered questions are:

  • Does the current master do the wrong thing for others besides me?
  • Did the current implementation work correctly at the time it was made?
  • Is this compiler-specific?

@vadz
Copy link
Contributor

vadz commented Feb 29, 2024

I think the correct thing to do would be to use 3 different handlers, implementing DesktopToastActivatedEventHandler, DesktopToastDismissedEventHandler and DesktopToastFailedEventHandler respectively instead of a single one.

Do you mean doing it the way it is already done in master?

No, this code uses a single wxToastEventHandler inheriting from
Microsoft::WRL::Implements<DesktopToastActivatedEventHandler, DesktopToastDismissedEventHandler, DesktopToastFailedEventHandler>, while I think we should use 3 (or 2) different wx classes, i.e. wxToastActivatedEventHandler and wxToastDismissedEventHandler, inheriting/implementing just the single corresponding base class.

Regardless, some unanswered questions are:

* Does the current master do the wrong thing for others besides me?

I didn't test it, but I think it always fails.

* Did the current implementation work correctly at the time it was made?

* Is this compiler-specific?

I don't think so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wxNotificationMessage always sends click event on MSW with toasts
2 participants