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

Refactor add/modify notification icon (TrayIcon)

XMLWordPrintable

    • b24
    • windows

        AwtTrayIcon::WmTaskbarCreated [1] and AwtTrayIcon::_UpdateIcon [2] have duplicate code:

            BOOL result = trayIcon->SendTrayMessage(jupdate == JNI_TRUE ? NIM_MODIFY : NIM_ADD);
            // 6270114: Instructs the taskbar to behave according to the Shell version 5.0
            if (result && jupdate == JNI_FALSE) {
                trayIcon->SendTrayMessage(NIM_SETVERSION);
            }

        The only difference is the usage of jupdate which controls whether the icon is to be added or modified.

        These could be refactored into separate methods to avoid code duplication, especially in the case of adding where another method must be called.

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

              aivanov Alexey Ivanov
              aivanov Alexey Ivanov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: