Subject: bug#79400: 30.2; Windows: w32-notification-notify/-close handle frames incorrectly

From: Raffael Stocker <[email-masked]>
Date: Sun, 07 Sep 2025 16:29:38 +0200

Eli Zaretskii <[email-masked]> writes:

>> The problem is that ‘w32-notification-notify’ and
>> ‘w32-notification-close’ use ‘SELECTED_FRAME()’ to call the Windows API.
>> This is fine for ‘-notify’, but not for ‘-close’, which should instead
>> pass the frame used in the corresponding call to ‘-notify’.
>
> What if that frame no longer exists?

In that case, Windows seems to close the notification by itself.  Last
time I checked, the icon in the task bar remained, but on mouse-over it
also vanished.

>> I would suggest changing the ID returned in ‘w32-notification-notify’ to
>> a cons cell containing ID and frame.
>
> Why not return an integer that is the handle of the frame's w32 window
> instead?

Do you mean besides the ID or instead of the ID?

Instead of the ID: if the ID ever takes on a value besides 42 or Windows
allows more than one notification per frame, we have the same problem
all over again.

Besides the ID: it could be the window handle, which would require
changes (simplifications?) to ‘add_tray_notification’ and
‘delete_tray_notification’.  These functions use the frame to obtain the
window handle, but also to do some basic sanity check using
‘FRAME_W32_P’.  I'm not sure something like this can be done if we pass
the window handle directly.

Regards,
Raffael