Bug 683768 - Add a workaround for Java applications using tray icon for Gnome Shell
Summary: Add a workaround for Java applications using tray icon for Gnome Shell
Alias: None
Product: Fedora
Classification: Fedora
Component: java-1.6.0-openjdk
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Danesh Dadachanji
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2011-03-10 10:59 UTC by Hedayat Vatankhah
Modified: 2012-02-13 17:05 UTC (History)
16 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2012-02-13 17:05:09 UTC
Type: ---

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
GNOME Bugzilla 648773 0 None None None Never

Description Hedayat Vatankhah 2011-03-10 10:59:05 UTC
Description of problem:
Java provides classes for application who'd like to use tray icon functionality available in many desktop environments. Gnome Shell doesn't have traditional system tray facility and so it doesn't support tray icons directly. However, it does have some alternative mechanisms (Looks like that there is something as notification persistence which can be used to implement almost the same functionality [1]). It would be great if tray icon facility is emulated using these mechanisms for better Java application compatibility. In the worst case, gnome shell should be probably marked as an environment without support for tray icons, so at least the application will know that it cannot use its tray icon. 


[1] http://live.gnome.org/GnomeShell/Design/Guidelines/MessageTray/Compatibility
Version-Release number of selected component (if applicable):

Comment 1 Hedayat Vatankhah 2011-03-10 10:59:56 UTC
Notice: AFAIK even gnome 3's fallback mode needs such support.

Comment 2 Omair Majid 2011-03-10 18:08:29 UTC
Thanks for filing the bug. I will take a look at this.

(In reply to comment #0)
> In the worst case,
> gnome shell should be probably marked as an environment without support for
> tray icons, so at least the application will know that it cannot use its tray
> icon. 

Isn't this bit already working? Java (at least a recent enough version of java-1.6.0-openjdk) implements the System Tray Protocol Specification [1] to find a system tray. If Gnome shell does not provide a system tray, openjdk should figure this out automatically.

[1] http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html

Comment 3 Hedayat Vatankhah 2011-03-10 19:09:42 UTC
Thanks for considering this issue :)

First, I was wrong, the tray icon works in fallback mode.
About the other: well, looks like that Gnome Shell provides some kind of support for system tray protocol; however it seems that it is implemented in a special way. While some applications can correctly use it, the tray icon of Java applications doesn't work correctly in Gnome Shell and you'll see that a very small window is available among application windows. But that small window is completely useless. 
If it works fine, the tray icon should be added to the bottom bar of gnome shell (which is visible when mouse pointer is on the bottom of screen).

Comment 4 Omair Majid 2011-03-10 20:26:04 UTC
Ugh. From reading the gnome-shell documentation, I gather that they have dropped support for the system tray (in general). The do have a new-ish (but rather incompatible) API for what they call Notifications and Messaging Tray [1], but it doesnt look like it will support Java's entire SystemTray API [2] (especially popup menus).

[1] http://live.gnome.org/GnomeShell/Design/#Notifications_and_messaging_tray
[2] http://download.oracle.com/javase/6/docs/api/java/awt/TrayIcon.html

Comment 5 Hedayat Vatankhah 2011-03-10 21:26:28 UTC
Well, I'm not very informative in this regard. However, I can observe that some applications do have popup menus in Gnome Shell too. For example, IBUS does have an icon in the bottom pane which (the icon itself, not the text beside it) has both right click and left click popup menus. Pidgin is another example which works fine there.

Comment 6 Andrew John Hughes 2011-03-10 23:47:59 UTC
If there's something that can be fixed at the actual native system tray level, then I guess something can be done when distros actually start using this thing.  But that API is a standard 1.6 Java API so it can't change.  As Gnome 3 is the one changing things here, I think the onus is on it and not every individual application to work with the existing system tray standard.

Comment 7 Hedayat Vatankhah 2011-03-11 10:07:09 UTC
Since there are programs which works correctly even without doing any special changes for Gnome Shell, it seems that it can be fixed in the Java implementation. And certainly I'm not asking for changing Java API. It looks more like bug fixing the implementation rather than undergoing a subtle change. BTW, consulting with Gnome Shell guys might be needed for clarification.

Comment 8 Warwick 2011-04-27 06:29:52 UTC
Java SE 6 Update 25 has not solve the problem...

Comment 9 Peter Weber 2011-05-26 11:47:12 UTC
I'm currently developing a small Java application, which use the SystemTray (Notification-Area). That works quite well with Gnome2, like written above that is a problem with Gnome3.

I'm doing this during creation of the TrayIcon:

		// create systray
		if (!SystemTray.isSupported()) {
			System.err.println("Systray unuseable.");
			System.exit(11); // return 11 means no Systray

Java thinks everything is all right and doesn't close the application. But I doesn't get a entry for my application in the message-tray at the bottom of the screen. Other older application (not written in Java) seem to work out-of-the-box "somewhat" with message-tray.
I know that the NotificationArea(SystemTray) is - deprecated:

If there is a way to use the MessageTray in a correct and nice manner, I would appreciate it :-)

Comment 10 Hedayat Vatankhah 2011-05-31 14:04:03 UTC
Gnome-shell developers believe that the tray icon implementation on Java is probably broken in some way, but they need more info about the implementation.
See https://bugzilla.gnome.org/show_bug.cgi?id=648773

Comment 11 Dan Winship 2011-05-31 14:13:05 UTC
More specifically, not only does gnome-shell implement the systray protocol, it actually uses the same code as gnome-panel does in fallback mode. (The na-tray-manager.c and na-tray-child.c code from gnome-panel is cut+pasted into the gnome-shell source tree.) So it seems like the problem must be that the java tray client code is making some additional incorrect check and then deciding to not use the systray even though it's there.

Comment 12 Dan Winship 2011-06-03 13:40:35 UTC
Update from the GNOME bug; the problem is that gnome-shell expects trayicons to set _NET_WM_PID on their window, and it messes things up if they don't. This will eventually be fixed in gnome-shell, but it's probably an easy fix on the java side to just set that property.

Comment 13 Andrew John Hughes 2011-06-30 00:32:16 UTC
Looking into this; both _NET_WM_PID and WM_CLIENT_MACHINE need to be set:


Comment 14 Hedayat Vatankhah 2011-10-08 07:06:27 UTC
Any updates on the Java side?! It seems that the bug is very easy to fix, so....?!

Comment 15 Danesh Dadachanji 2011-10-20 20:27:18 UTC
(In reply to comment #14)
> Any updates on the Java side?! It seems that the bug is very easy to fix,
> so....?!

I just sent a review request to openjdk:


Stay tuned..

Comment 16 Hedayat Vatankhah 2011-10-20 21:05:56 UTC

Comment 17 Danesh Dadachanji 2011-11-15 20:21:45 UTC
This was pushed to upstream openjdk8[1] some days ago. I've also just pushed it into icedtea6 HEAD[2].

I'll ask for it to be backported to openjdk6 and 7 and will be backporting this to icedtea7 shortly.

[1] http://hg.openjdk.java.net/jdk8/awt/jdk/rev/f614bcada2a9
[2] http://icedtea.classpath.org/hg/icedtea6/rev/15d88aeb3dc4

Comment 18 Hedayat Vatankhah 2011-11-16 07:57:49 UTC
Thanks. Hope to see it in the repos soon.

Comment 19 Peter Weber 2012-01-26 08:36:57 UTC

Comment 20 Danesh Dadachanji 2012-01-26 21:38:44 UTC
(In reply to comment #19)
> Progress?

This was pushed to jdk7u-dev back in November[1] and I have just made a review request for icedtea7-forest and icedtea7-forest-2.0[2]. I'll close this report once it's pushed to the release forest (since rawhide will be using it then).

[1] http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/f1d09dc7f9a7
[2] http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-January/016991.html

Comment 21 Andrew John Hughes 2012-02-02 15:17:34 UTC
This is fixed in 1.11 which should be making its way to the Fedora's which still carry 1.6 (F14 and F15) soon, if it hasn't already.

The 7 update should appear with the next security update in a couple of weeks.

Comment 23 Hedayat Vatankhah 2012-02-11 21:31:09 UTC
Finally, the updated landed in Fedora 16 for openjdk 6, and it works almost fine. The icon appears in the message tray actually, so this bug can be considered closed for OpenJDK 6 (OpenJDK 7's update is not arrived yet for Fedora 16 AFAIK). 

However, there is still a very small window shown in Gnome's Alt+Tab list (sometimes in overview mode too, sometimes not!). It would be great if that small window is also omitted. 

Thanks :)

Comment 24 Danesh Dadachanji 2012-02-13 17:05:09 UTC
> However, there is still a very small window shown in Gnome's Alt+Tab list
> (sometimes in overview mode too, sometimes not!). It would be great if that
> small window is also omitted. 

We discussed this somewhat in the email thread I posted earlier[1] and decided this was a separate issue. I believe it has to do with the order of the tuple WM_CLASS not being set correctly. I'll tackle it when I get the chance.
> Thanks :)
You're welcome, thanks for reporting! =)

This is now in rawhide[2] and icedtea7-forest[3], closing this bug.

[1] http://mail.openjdk.java.net/pipermail/awt-dev/2011-November/001999.html
[2] http://icedtea.classpath.org/hg/release/icedtea7-forest-2.0/jdk/rev/c705a1cdc132
[3] http://icedtea.classpath.org/hg/icedtea7-forest/jdk/rev/afdcedc27c23

Note You need to log in before you can comment on or make changes to this bug.