On Tue, 10 May 2022 23:17:36 GMT, Harshitha Onkar <d...@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 incrementally with one > additional commit since the last revision: > > test case exit issue fix I think the icon distortion observed on Win10 and 11 might be due to race condition between update triggered by WM_WINDOWPOSCHANGING and the re-addition of tray icons when taskbar is reloaded (occurs when DPI changes) Whenever DPI changes, the taskbar is reloaded and all the existing tray icons are re-added by `WmTaskbarCreated()` in `awt_TrayIcon.cpp`. Here is the link to the relevant doc: [Taskbar creation and reload](https://docs.microsoft.com/en-us/windows/win32/shell/taskbar#taskbar-creation-notification) **The reason for distortion:** When update to tray icons (creating new scaled icon and deleting the old one) is called on `WM_WINDOWPOSCHANGING`, it might create race condition - updating the tray icon and deleting the previous ones while the WmTaskbarCreated is trying to re-add the icons at the same time. To overcome the race condition, I have removed the call to **UpdateTrayIconHandler()** on WM_WINDOWPOSCHANGING and added it when taskbar gets reloaded and before `WmTaskbarCreated` is called. When tested on Win10, it works as well. @aivanov-jdk Can you please test on Win10 & 11 with the new fix and let me know if it works? ------------- PR: https://git.openjdk.java.net/jdk/pull/8441