RFR: JDK-8255439: System Tray icons get corrupted when windows scaling changes [v8]

Kevin Rushforth kcr at openjdk.java.net
Fri May 13 19:04:04 UTC 2022


On Fri, 13 May 2022 18:01:47 GMT, Harshitha Onkar <duke at openjdk.java.net> wrote:

>> In Windows, when desktop scaling is changed the tray icons was distorted/blurred a bit each time scaling changes.
>> 
>> With the proposed fix, the tray icon scales according to on-the-fly DPI scale settings. A test case has been added which adds a MRI icon to system tray, to observe the icon scaling when DPI is changed. Since the scale cannot be programmatically changed (for dynamic on-the-fly scale changes), I have used a manual test case to test this scenario.
>> 
>> When DPI changes usually two messages are sent by windows -
>> 
>> - [WM_DPICHANGED](https://docs.microsoft.com/en-us/windows/win32/hidpi/wm-dpichanged)
>> - [WMPOSCHANGING](https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-windowposchanging)
>> 
>> I'm triggering an update on tray icons on receiving WMPOSCHANGING msg through the Tray icon's Window Procedure. Triggering an update on WM_DPICHANGED was still causing the icons to be distorted, hence WMPOSCHANGING is being used as the message to trigger the update.
>
> Harshitha Onkar has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 11 additional commits since the last revision:
> 
>  - Merge branch 'master' into WinTrayIcon
>  - reverted SystemTray changes
>  - new changes - trayicon update triggered in WmTaskbarCreated
>  - trayicon update triggered on taskbar reload
>  - test case exit issue fix
>  - formatting changes
>  - resized instruction window and formatted line lengths
>  - removed whitespaces error due to CRLF
>  - removed whitespace error
>  - added manual to test case
>  - ... and 1 more: https://git.openjdk.java.net/jdk/compare/eabce393...60391f28

The latest version of the fix looks good, and is simpler than the earlier one. I tested it on Windows 10 and it works well.

There are two files that can be reverted, `TrayIcon.java` and `WTrayIconPeer.java`, since the only remaining changes after your last update are unrelated changes in the copyright year and the import statements. The easiest way to do this is `git checkout master -- filename1 filename2 ...`, presuming that the HEAD of `master` matches what you have merged into your branch.

src/java.desktop/share/classes/java/awt/TrayIcon.java line 2:

> 1: /*
> 2:  * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.

You can revert this file, since the only remaining changes are this copyright year and import statements, which are relating to your fix.

src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java line 2:

> 1: /*
> 2:  * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.

You can revert this file, since the only remaining changes are this copyright year and import statements, which are relating to your fix.

test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java line 129:

> 127:     }
> 128: }
> 129: 

Minor: there is an extra blank line here.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8441



More information about the client-libs-dev mailing list