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

[macos11] java.awt.TrayIcon requires updates for template images

XMLWordPrintable

    • b05
    • x86_64
    • os_x
    • Not verified

      ADDITIONAL SYSTEM INFORMATION :
      macOS Big Sur 11.0 Beta (20A5323l)
      MacBook Pro (13-inch, 2020)

      openjdk version "11.0.7" 2020-04-14
      OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
      OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      According to Apple's human interface guidelines, developers should:

      "[...] use a template image to represent your menu bar extra. A template image discards color information and uses a mask to produce the appearance you see onscreen. Template images automatically adapt to the user’s appearance settings, so they look good on both dark and light menu bars, and when your menu bar extra is selected."

      These template images could be effectively simulated in appearance prior to MacOS 11.0 "Big Sur" by using platform-specific workarounds to predict the color of the icon, however starting with 11.0 "Big Sur", workarounds are ineffective as described here:

      https://github.com/AdoptOpenJDK/openjdk-support/issues/146

      Supporting template icons requires an API change to java.awt.TrayIcon, specifically a boolean flag to represent if the icon provided can be used as a "template" icon. This API can and should be implemented to any other platforms (e.g. Windows 10), assuming a similar API -- or simulation thereof -- can exist. See also Qt's API example "setIsMask" which offers this functionality: https://github.com/qt/qtbase/blob/471e4fcb226c4523efe93b1bdaf0db026495da94/src/gui/image/qicon.cpp#L1341-L1355

      In order for this feature to be implemented, Java will need to change the AWTTrayIconView to use a button (not a view) instead as the existing AWTTrayIconView implementation manually blits the image using AWTTrayIconView.drawRect(), preventing control over NSImage::isTemplate from being used.

      Due to the introduction of macOS 11.0 in fall of 2020 combined with the state of Java 11 being LTS until 2023, java.awt.TrayIcon should be enhanced to support template icons to be consistent with Apple's human interface guidelines so that Java developers can continue to develop and use java.awt.TrayIcon in accordance with Apple's standards.


            peterz Peter Zhelezniakov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: