<div dir="ltr">Back in mid-2021 I submitted a <a href="https://bugs.openjdk.org/browse/JDK-8266423">feature request</a> to add new APIs for toast notifications on macOS and Windows <i>without</i> using SystemTray. It's something I'd like to implement. Apple introduced its <a href="https://developer.apple.com/documentation/foundation/nsusernotification?language=objc">notification APIs</a> in macOS 10.8. Never worked with the WinRT before, though.<div><br></div><div>SWinxy</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 8, 2024 at 4:06 PM Davide Perini <<a href="mailto:perini.davide@dpsoftware.org">perini.davide@dpsoftware.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
Thanks for the explanation Aleksei <br>
but can you explain me what is the OpenJDK direction please?<br>
<br>
Suppose that you have a feature like this one, a simple
notifications.<br>
Java worked well with Windows notifications until Win10,<br>
then Microsoft changed the APIs for notifications in Win11.<br>
<br>
Isn't OpenJDK supposed to adapt to the new Windows APIs?<br>
<br>
Does OpenJDK supports Windows 11 or not?<br>
<br>
It's a little "weird" to close an issue by saying that Java uses the
same way to do the same thing since Windows 95 <br>
and that it's a Microsoft problem if they changed the way to send
notifications to the OS.<br>
<br>
Java should support Microsoft Windows, it isn't Microsoft Windows
that should support Java, <br>
isn't it?<br>
<br>
Other languages adapted their APIs for the new notifications system,
like everyone should expect from a modern language, <br>
after 2 years from the release of Win 11,<br>
Oracle says that it worked since Windows 95, so it is ok to have a
broken API in JDK because it worked before, they are the ones who
broke it (Microsoft).<br>
<br>
Does Java offers a correct way to send Notifications in Win10?
Answer: Yes<br>
Does Java offers a correct way to send Notifications in Win11?
Answer: No<br>
Does other languages offers a correct way to send Notifications in
Win11? Answer: Yes<br>
Does current JDK APIs works as expected in Win11? <br>
Answer: No because JDK uses an old API born with Win95 (30 years ago
+ or -) with a new OS born in 2021, this results in an unexcpected
behaviour that doesn't work as supposed initially by the API.<br>
<br>
In the bug report you wrote:<br>
"I can't see what Java can do to change the behaviour."<br>
<br>
The answer is:<br>
"By implementing the correct API for the correct OS".<br>
<br>
<br>
Java is currently not able to correctly send a Notification in
Windows 11.<br>
<br>
<br>
I see a bug there, if you don't see it, <br>
I'm pretty worried of the new JDK direction.<br>
<br>
Thanks<br>
Davide<br>
<br>
<br>
Il 08/01/2024 20:55, Aleksei Ivanov ha scritto:<br>
<blockquote type="cite">
On 2024-01-08 19:30, Davide Perini wrote:<br>
<blockquote type="cite">
Thanks for the Answer Aleksei,<br>
I have a lot of Windows apps that uses notifications without
problems.<br>
<br>
even a simple python program like this works correctly.<br>
<div style="background-color:rgb(30,31,34);color:rgb(188,190,196)">
<pre style="font-family:"JetBrains Mono",monospace"><span style="color:rgb(207,142,109)">from </span>win11toast <span style="color:rgb(207,142,109)">import </span>toast
toast(<span style="color:rgb(106,171,115)">'Hello'</span>, <span style="color:rgb(106,171,115)">'Click to run python script'</span>)</pre>
</div>
</blockquote>
<br>
Python could use newer WinRT APIs [6], in particular
ToastNotification class [7] which provide richer interface for the
toast notifications. The package name ‘toast’ hints it uses the
newer APIs.<br>
<br>
<blockquote type="cite">is
it possible that Microsoft changed the way how to create
Notifications in Windows 11 and Java still uses the way it
worked in Windows 7?<br>
</blockquote>
<br>
Perhaps, Microsoft changed how they handle notifications in
Windows 11. In Windows 10, the notifications created with a Java
app remain in Action / Notification centre.<br>
<br>
Java uses Shell_NotifyIcon [8] function that has been available
since Windows 95.<br>
<br>
-- <br>
Regards,<br>
Alexey<br>
<br>
[6] <a href="https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/" target="_blank">https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/</a><br>
[7]
<a href="https://learn.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotification?view=winrt-22621" target="_blank">https://learn.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotification?view=winrt-22621</a><br>
[8]
<a href="https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shell_notifyiconw" target="_blank">https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shell_notifyiconw</a><br>
<br>
<blockquote type="cite">
<br>
Thanks<br>
Davide<br>
<br>
<br>
<br>
<div>Il 08/01/2024 17:59, Aleksei Ivanov
ha scritto:<br>
</div>
<blockquote type="cite">Hi
Davide, <br>
<br>
The bug that you reported has been moved to JDK project in
JBS, you can view it as JDK-8315647 [1]. You should've
received a link to it. <br>
<br>
<blockquote type="cite">Is there a way to workaround this JDK
bug? <br>
I opened a bug report months ago but no one answered. </blockquote>
<br>
What kind of answer did you expect to receive? <br>
<br>
You already asked this question on this mailing list in August
[2]. I replied to your question [3]. Nothing has changed since
August. It is not a bug in Java because a native Win32 app
behaves the same way. <br>
<br>
I compiled and tested the sample [4], it behaves in Windows 11
as Java does: the displayed balloon notification does not go
to notification centre. However, if I open notification centre
while the balloon is displayed, it remains there. If I disable
"Show notification banners" and leave "Show notifications in
notification centre" enabled, the balloon goes directly to
notification centre without displaying a banner. <br>
<br>
You can compile and test the sample too: <br>
<br>
git clone --filter=<a>blob:none</a>
--sparse <a href="https://urldefense.com/v3/__https://github.com/microsoft/Windows-classic-samples.git__;!!ACWV5N9M2RV99hQ!NLmQsIei56bZm5IGVWA45k6g1Dduh_MFpShFK0TzjLM7OJHlH90je29IlZRa410GYcehUmNb21kyLplVv8fTzwWsci7s6yw2$" target="_blank">https://github.com/microsoft/Windows-classic-samples.git</a>
windows-samples <br>
cd windows-samples <br>
git sparse-checkout add
Samples/Win7Samples/winui/shell/appshellintegration/NotificationIcon
<br>
<br>
Navigate to the NotificationIcon folder and open
NotificationIcon.sln in Visual Studio to compile and run it. <br>
<br>
If required, I can attach the compiled version of the
application. <br>
<br>
<br>
I have closed JDK-8315647 as duplicate of JDK-8310352 [5]. <br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</div>
</blockquote></div>