Bug 683768

Summary: Add a workaround for Java applications using tray icon for Gnome Shell
Product: [Fedora] Fedora Reporter: Hedayat Vatankhah <hedayatv>
Component: java-1.6.0-openjdkAssignee: Danesh Dadachanji <ddadacha>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: ahughes, andre.ocosta, bfay, danw, dbhole, ddadacha, iyjc, jvanek, langel, lkundrak, mail, mark, mmatejov, omajid, peterle, peter.weber
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-13 12:05:09 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:

Description Hedayat Vatankhah 2011-03-10 05:59:05 EST
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. 

Thanks

[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 05:59:56 EST
Notice: AFAIK even gnome 3's fallback mode needs such support.
Comment 2 Omair Majid 2011-03-10 13:08:29 EST
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 14:09:42 EST
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 15:26:04 EST
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 16:26:28 EST
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 18:47:59 EST
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 05:07:09 EST
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 02:29:52 EDT
Java SE 6 Update 25 has not solve the problem...
Comment 9 Peter Weber 2011-05-26 07:47:12 EDT
Hello!
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:
https://live.gnome.org/GnomeShell/Design/Guidelines/MessageTray
http://ploum.net/post/219-the-aristocratic-desktop-part-3-there-s-no-tray-icon-in-gnome

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 10:04:03 EDT
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 10:13:05 EDT
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 09:40:35 EDT
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-29 20:32:16 EDT
Looking into this; both _NET_WM_PID and WM_CLIENT_MACHINE need to be set:

http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html#id2523510
Comment 14 Hedayat Vatankhah 2011-10-08 03:06:27 EDT
Any updates on the Java side?! It seems that the bug is very easy to fix, so....?!
Comment 15 Danesh Dadachanji 2011-10-20 16:27:18 EDT
(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:

http://mail.openjdk.java.net/pipermail/awt-dev/2011-October/001951.html

Stay tuned..
Comment 16 Hedayat Vatankhah 2011-10-20 17:05:56 EDT
Thanks.
Comment 17 Danesh Dadachanji 2011-11-15 15:21:45 EST
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 02:57:49 EST
Thanks. Hope to see it in the repos soon.
Comment 19 Peter Weber 2012-01-26 03:36:57 EST
Progress?
Comment 20 Danesh Dadachanji 2012-01-26 16:38:44 EST
(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 10:17:34 EST
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 16:31:09 EST
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 12:05:09 EST
> 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