Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286838

SendTrayMessage(NIM_ADD) returns failure in AwtTrayIcon::WmTaskbarCreated

XMLWordPrintable

      AwtTrayIcon::WmTaskbarCreated [1] handles the situation where Windows Taskbar is recreated. When an app receives this message, it should re-add all its notification icons.

      On Windows 10, this message is also broadcast when the DPI of the main display changes. This situation is handled by JDK-8255439 which calls UpdateImage. This results in SendTrayMessage(NIM_MODIFY) being called, and it returns 1 which indicates success.

      At the same time, SendTrayMessage(NIM_ADD) is still called, and it always returns 0 which indicates failure.

      So the two cases should be handled separately: if DPI changed, call SendTrayMessage(NIM_MODIFY) only because the Taskbar still has the icon; otherwise call SendTrayMessage(NIM_ADD) to re-add the icon because the taskbar was re-created.


      [1] https://github.com/openjdk/jdk/blob/1d8e92ae0d2d0d6740e2171abef45545439e6414/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp#L477

            aivanov Alexey Ivanov
            honkar Harshitha Onkar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: