changeset 2016:c12e7cd9ae66

Backport S6438179: XToolkit.isTraySupported() result has nothing to do with the system tray 2010-12-10 Omair Majid <omajid@redhat.com> Fixes RH569121, S6438179 * NEWS: Update with new backport. * Makefile.am (ICEDTEA_PATCHES): Apply new patch. * patches/openjdk/6438179-systray_check.patch: Backport of S6438179.
author Omair Majid <omajid@redhat.com>
date Fri, 10 Dec 2010 11:54:02 -0500
parents 8ee32987a172
children c7fb03394c5b
files ChangeLog Makefile.am NEWS patches/openjdk/6438179-systray_check.patch
diffstat 4 files changed, 103 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Dec 09 15:16:19 2010 -0500
+++ b/ChangeLog	Fri Dec 10 11:54:02 2010 -0500
@@ -1,3 +1,10 @@
+2010-12-10  Omair Majid  <omajid@redhat.com>
+
+	Fixes RH569121, S6438179
+	* NEWS: Update with new backport.
+	* Makefile.am (ICEDTEA_PATCHES): Apply new patch.
+	* patches/openjdk/6438179-systray_check.patch: Backport of S6438179.
+
 2010-12-09  Denis Lila <dlila@redhat.com>
 
 	* Makefile.am:
--- a/Makefile.am	Thu Dec 09 15:16:19 2010 -0500
+++ b/Makefile.am	Fri Dec 10 11:54:02 2010 -0500
@@ -376,7 +376,8 @@
 	patches/getannotation-cast.patch \
 	patches/applet_hole.patch \
 	patches/openjdk/7003777-bad-html-entity-parse.patch \
-	patches/openjdk/6967436-6976265-6967434-pisces.patch
+	patches/openjdk/6967436-6976265-6967434-pisces.patch \
+	patches/openjdk/6438179-systray_check.patch
 
 if WITH_ALT_HSBUILD
 ICEDTEA_PATCHES += patches/hotspot/$(HSBUILD)/openjdk-6886353-ignore_deoptimizealot.patch \
--- a/NEWS	Thu Dec 09 15:16:19 2010 -0500
+++ b/NEWS	Fri Dec 10 11:54:02 2010 -0500
@@ -9,6 +9,8 @@
 CVE-XXXX-YYYY: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=XXXX-YYYY
 
 New in release 1.7.7 (201X-XX-XX):
+* Backports
+  - S6438179, RH569121: XToolkit.isTraySupported() result has nothing to do with the system tray
 
 New in release 1.7.6 (2010-11-24):
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6438179-systray_check.patch	Fri Dec 10 11:54:02 2010 -0500
@@ -0,0 +1,92 @@
+# HG changeset patch
+# User omajid
+# Date 1281710168 14400
+# Node ID ac23e40d3880c30085d7a76826145afbe73dd465
+# Parent 636250081b3b27e4b9f536903aa2ddad135f24f2
+6438179: XToolkit.isTraySupported() result has nothing to do with the system tray
+Summary: Use System Tray Protocol Specification
+Reviewed-by: prr, dcherepanov
+
+--- openjdk.orig/jdk/src/share/classes/java/awt/SystemTray.java	Wed Aug 11 19:06:15 2010 +0100
++++ openjdk/jdk/src/share/classes/java/awt/SystemTray.java	Fri Aug 13 10:36:08 2010 -0400
+@@ -164,16 +164,14 @@ public class SystemTray {
+         if (GraphicsEnvironment.isHeadless()) {
+             throw new HeadlessException();
+         }
++
++        initializeSystemTrayIfNeeded();
++
+         if (!isSupported()) {
+             throw new UnsupportedOperationException(
+                 "The system tray is not supported on the current platform.");
+         }
+ 
+-        synchronized (SystemTray.class) {
+-            if (systemTray == null) {
+-                systemTray = new SystemTray();
+-            }
+-        }
+         return systemTray;
+     }
+ 
+@@ -204,7 +202,7 @@ public class SystemTray {
+      */
+     public static boolean isSupported() {
+         if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
+-
++            initializeSystemTrayIfNeeded();
+             return ((SunToolkit)Toolkit.getDefaultToolkit()).isTraySupported();
+ 
+         } else if (Toolkit.getDefaultToolkit() instanceof HeadlessToolkit) {
+@@ -472,4 +470,12 @@ public class SystemTray {
+             security.checkPermission(SecurityConstants.ACCESS_SYSTEM_TRAY_PERMISSION);
+         }
+     }
++
++    private static void initializeSystemTrayIfNeeded() {
++        synchronized (SystemTray.class) {
++            if (systemTray == null) {
++                systemTray = new SystemTray();
++            }
++        }
++    }
+ }
+--- openjdk.orig/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java	Wed Aug 11 19:06:15 2010 +0100
++++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java	Fri Aug 13 10:36:08 2010 -0400
+@@ -55,6 +55,19 @@ public class XSystemTrayPeer implements 
+         return new Dimension(XTrayIconPeer.TRAY_ICON_HEIGHT, XTrayIconPeer.TRAY_ICON_WIDTH);
+     }
+ 
++    boolean isAvailable() {
++        boolean available = false;
++        XToolkit.awtLock();
++        try {
++            long selection_owner = XlibWrapper.XGetSelectionOwner(XToolkit.getDisplay(),
++                _NET_SYSTEM_TRAY.getAtom());
++            available = (selection_owner != XConstants.None);
++        } finally {
++            XToolkit.awtUnlock();
++        }
++        return available;
++    }
++
+     // ***********************************************************************
+     // ***********************************************************************
+ 
+--- openjdk.orig/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Wed Aug 11 19:06:15 2010 +0100
++++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Aug 13 10:36:08 2010 -0400
+@@ -1073,10 +1073,9 @@ public class XToolkit extends UNIXToolki
+     }
+ 
+     public boolean isTraySupported() {
+-        int wm = XWM.getWMID();
+-        if (wm == XWM.METACITY_WM || wm == XWM.KDE2_WM)
+-        {
+-            return true;
++        XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
++        if (peer != null) {
++            return peer.isAvailable();
+         }
+         return false;
+     }
+