RFR: JDK-8305645: System Tray icons get corrupted when Windows primary monitor changes

Sergey Bylokhov serb at openjdk.org
Thu Jun 8 21:32:40 UTC 2023


On Wed, 7 Jun 2023 19:05:56 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

> There are two scenarios related to tray icon distortion.
> 
> 1. Single Screen - when DPI / Scale is changed on the fly - this was resolved as part of [PR#8441](https://github.com/openjdk/jdk/pull/8441)
> 
> 2. Multi Screen - when screens are set to different scales and the primary display is toggled. This is a variation of scenario one. 
> 
> Earlier Windows msg - [WM_DPICHANGED](https://learn.microsoft.com/en-us/windows/win32/hidpi/wm-dpichanged) was being used to update the tray icons. This message is sent when window DPI changes. WM_DPICHANGED msg is not received when taskbar switches to primary display under multiple screen scenario, hence the tray icon was still seen distorted in case 2.
>  
> As [WM_DISPLAYCHANGE](https://learn.microsoft.com/en-us/windows/win32/gdi/wm-displaychange) is received in both cases, it is used as the new message to trigger tray icon update. This message also works when the main display monitor gets disconnected accidently making the other display the primary display.
> 
> TrayIconScalingTest's  instructions have been updated to include both the cases described above.

The old fix did not add any scale checks since the updateNativeImage was called on dpi change only. If we will start to call updateNativeImage on each monitor change event then probably we should recreate images only if the scale was changed?

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

PR Comment: https://git.openjdk.org/jdk/pull/14368#issuecomment-1583371398



More information about the client-libs-dev mailing list