<AWT Dev> [10] Review Request: 8187639 TrayIcon is not properly supported on macOS in multi-screen environment

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Mon Oct 16 21:29:32 UTC 2017


On 16/10/2017 12:30, Phil Race wrote:
> - Why do we scale the icon by 0.75 ? I could be missing something but
>     it appears that this will be based off the same image whether it is 
> retina or not
>     and I wonder if we really should be scaling it down on retina ?


0.75: This code makes the application icon smaller on the notification, 
things related to style/design.

The same image is used from the LookAndFeel whether the screen is retina 
or not.
To use HiDPI image it is necessary:
  - Read all representation from the native NSImage and store them in 
MultiResolutionImage.
  - Store this image in the L&F property.
  - In CTrayIcon read the MRI from the l&f and convert it back to the 
NSImage.
  - Pass the nsimage to the native notification, the OS will select 
correct representation.
I can start to work on this after the current fix.

> - Are we losing anything by no longer knowing when the user has 
> dismissed the notification ?

We can generate an action when the user clicks on the notification, but 
I preserved the old behavior, the click on the notification just close 
it as before.

> - I suppose a test case for this is hard ?

TrayIcon.displayMessage() is a platform dependent method, there are 
nothing to test except that we could show message/notification somewhere 
near tray area. We already have some tests which use displayMessage().

> 
> - Can perhaps attach an "after the fix" screen shot to the bug report ?

done.

> On 09/27/2017 10:07 AM, Sergey Bylokhov wrote:
>>
>> Hello,
>> Please review the fix for jdk10.
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187639
>> Webrev can be found at: 
>> http://cr.openjdk.java.net/~serb/8187639/webrev.01
>>
>> Since macOS 10.9(or even early) the main menubar is shown on all 
>> screens(not only on the main screen), which means that on both screens 
>> the trayIcons are visible.
>> Our code is not ready for this situation, because we create a custom 
>> notification window and tries to place it near the trayicon on the 
>> main screen.
>>
>> Instead of updating the logic of showing the window, I migrated the 
>> code to the standard notification mechanism which is used in macOS.
>>
>> Examples:
>> The old message: http://cr.openjdk.java.net/~serb/8187639/images/Old.png
>> The new(java -jar): 
>> http://cr.openjdk.java.net/~serb/8187639/images/Command%20line.png
>> The new(bundles application): 
>> http://cr.openjdk.java.net/~serb/8187639/images/Bundled%20applicateion.png 
>>
>>
>>
> 


-- 
Best regards, Sergey.


More information about the awt-dev mailing list