This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 183739 - provide a non-generic WM_CLASS X property
Summary: provide a non-generic WM_CLASS X property
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 7.0
Hardware: All Linux
: P2 normal with 4 votes (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-09 00:40 UTC by mrooney
Modified: 2012-10-22 08:48 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed patch (1.35 KB, patch)
2012-05-09 01:57 UTC, Jesse Glick
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mrooney 2010-04-09 00:40:35 UTC
Hello, thanks for the wonderful IDE!

One issue however is that NetBeans does not provide a useful WM_CLASS property on Linux, which docks and other tools use to match processes to windows. You can test this by running something like "xprop | grep WM_CLASS", which will turn your cursor into a cross, waiting for a click on a window, such as NetBeans:

$ xprop | grep WM_CLASS
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"

so, it is only possible to know that the window is a Java app, but not that it matches the process "nbexec" for example.

Here are some examples of well-behaved applications:

Chromium: WM_CLASS(STRING) = "chromium-browser", "Chromium-browser"
Firefox: WM_CLASS(STRING) = "Navigator", "Firefox"
Thunderbird: WM_CLASS(STRING) = "Mail", "Thunderbird"
Pidgin: WM_CLASS(STRING) = "Pidgin", "Pidgin"

So, if NetBeans provided an accurate WM_CLASS xprop, it would be very helpful to many applications across Linux desktops!
Comment 1 psybers 2010-04-09 00:59:05 UTC
One possible approach is as follows:

Toolkit xToolkit = Toolkit.getDefaultToolkit();
java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName");
awtAppClassNameField.setAccessible(true);
awtAppClassNameField.set(xToolkit, "NetBeans");

Taken from:
http://elliotth.blogspot.com/2007/02/fixing-wmclass-for-your-java.html
Comment 2 reinouts 2011-04-18 09:32:25 UTC
Still valid for 7.0RC2 and it's becoming more visible when using Netbeans under Gnome 3.0.
See Gnome bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=647437 .
Comment 3 vakuumbarn 2011-04-18 12:07:25 UTC
This is even more of a problem running multiple applications based on NetBeans platform, like NetBeans, Sql Developer, VisualVm etc at the same time, where all are presented with the same generic name.
Comment 4 Stanislav Aubrecht 2011-05-25 08:40:50 UTC
it seems more like JDK issue to me
but if you think there's a workaround (reflection), a patch is welcome
Comment 5 vakuumbarn 2011-05-25 14:31:41 UTC
Well, I'd agree it should be fixed in the JDK (see previous link to blog post) but in the meantime it's fixable and would be much appreciated. Point me to the "startup" class or main frame or whatever in the source and I'll try to provide you with a a patch.
Comment 6 Stanislav Aubrecht 2011-07-18 14:49:31 UTC
waiting for the patch:) (or the JDK fix...)
Comment 7 ogj 2011-09-22 18:38:55 UTC
I think it is not unreasonable to ask for this tiny, little fix, which will improve the netbeans appearance on Gnome3-based Linux platforms.

I think the code in Comment#1 should be enough, at least according to other sources on this subject. However, small as it is, the problem for me would be to dive into the netbeans sources. I really have no clue where to start. I'm assuming it would be quite simple for anyone familiar with the source to stick this in at some appropriate place.

Btw, the JDK bug is http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6528430, please do vote for that as well. It is from feb 2007, though, with a very low priority. And besides, it will need changes in netbeans sources anyway. I would not hold my breath for this.

Thanks.
Comment 8 Jesse Glick 2012-05-09 01:53:34 UTC
I consider this P2 since it is so obviously wrong when you run NB under GNOME 3: "java-lang-Thread" is displayed prominently at the top of the screen when NB is fronted.

This bug also makes it impossible to create a proper *.desktop file, since you need to set the StartupWMClass property to something NB-specific.
Comment 9 Jesse Glick 2012-05-09 01:57:38 UTC
Created attachment 119183 [details]
Proposed patch

This patch against NB dev sources works for me on JDK 7u4 in Ubuntu 12.04 in the GNOME 3 shell.
Comment 10 Jesse Glick 2012-05-09 01:59:11 UTC
BTW http://youtrack.jetbrains.com/issue/IDEA-70806 is similar.
Comment 11 reinouts 2012-05-09 14:26:48 UTC
(In reply to comment #9)
> Created attachment 119183 [details]
> Proposed patch
> 
> This patch against NB dev sources works for me on JDK 7u4 in Ubuntu 12.04 in
> the GNOME 3 shell.

That's good news -- does it also work with switching between multiple open Netbeans windows (dialogs, etc.) with Alt+` ?
Comment 12 Jesse Glick 2012-05-09 19:30:42 UTC
(In reply to comment #11)
> does it also work with switching between multiple open
> Netbeans windows (dialogs, etc.) with Alt+` ?

Yes.

(Note that if you use the AlternateTab shell extension it would not matter anyway, since that operates just by title, not WM class.)
Comment 13 Stanislav Aubrecht 2012-05-10 08:40:17 UTC
core-main 5832261b8434

Thanks for the patch, Jesse!
Comment 14 Jesse Glick 2012-05-10 11:21:51 UTC
Is this 71patch3-candidate? Bug symptom does not seriously interfere with IDE unusability but it looks terrible in GNOME 3 - one of the first things you notice when starting the IDE.
Comment 15 Jesse Glick 2012-05-10 12:26:38 UTC
BTW there seems to be no particularly good way in the NB Platform to get a general-purpose "application name invariant across versions". In this patch I just use CTL_MainWindow_Title_No_Project with the build number stripped off (*); org.netbeans.modules.keyring.gnome.GnomeProvider does pretty much the same for purposes of the GTK call g_set_application_name. It is not ideal since some version information remains (**) - "NetBeans IDE Dev" or "NetBeans IDE 7.2" or whatever. For Platform apps the problem may or may not exist, depending on whether the developer tries to put variable information in the "Application Title" branding field.

(*) A minor I18N violation in principle but unlikely to ever matter, since the known values of this key either do not use the {0} param at all, or use it only as a suffix " {0}".

(**) Which is why kde.KWalletProvider.getApplicationName hardcodes the name (bug #200657), though in that case hardcoding is actually best since we would prefer to use the same wallet across all NB-based apps.
Comment 16 Quality Engineering 2012-05-11 10:11:31 UTC
Integrated into 'main-golden', will be available in build *201205110400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5832261b8434
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #183739 - provide proper app name on Linux
Comment 17 Stanislav Aubrecht 2012-05-14 15:30:08 UTC
in release71_fixes as 3bb933029016
Comment 18 Quality Engineering 2012-05-15 14:58:06 UTC
Integrated into 'releases', will be available in build *201205151102* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/3bb933029016
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #183739 - provide proper app name on Linux
Comment 19 ttokoly 2012-05-18 08:43:23 UTC
Product Version: NetBeans IDE 7.1.2 (Build 201204101705)
Java: 1.6.0_32; Java HotSpot(TM) Client VM 20.7-b02
System: Linux version 3.0.0-19-generic running on i386; UTF-8; en_US (nb)

For this version of NB xprop shows now:
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "NetBeans IDE 7.1.2"

So, works for me and verified :) .
Comment 20 Jesse Glick 2012-05-18 13:31:04 UTC
ttokoly - not sure what you are testing, since the fix is not in 7.1.2. It is in 7.2 dev builds, and scheduled for 7.1.3. For 7.1.2 you should still see the bug:

WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"
Comment 21 Marian Mirilovic 2012-05-18 17:33:01 UTC
(In reply to comment #20)
> ttokoly - not sure what you are testing, since the fix is not in 7.1.2. It is
> in 7.2 dev builds, and scheduled for 7.1.3. For 7.1.2 you should still see the
> bug:
> 
> WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"

I expect Tomas tested 7.1.2 + patch3 as we were testing it today ... 

Tomas, please confirm.
Comment 22 ttokoly 2012-05-29 09:59:13 UTC
Yes, as Marian says - 7.1.2 + patch 3!
Comment 23 reinouts 2012-06-13 15:24:35 UTC
Apparently this fix didn't make it to 7.2beta?
Comment 24 Jesse Glick 2012-06-13 17:37:00 UTC
(In reply to comment #23)
> Apparently this fix didn't make it to 7.2beta?

No, I think it was made after Beta was branched. Check dev builds.
Comment 25 Jesse Glick 2012-06-13 18:18:31 UTC
Note that the fix does not work on the splash screen - just on the IDE window after startup.
Comment 26 nedenom 2012-10-19 10:15:20 UTC
Any chance of a backport to 7.2?
Comment 27 Jesse Glick 2012-10-19 18:15:38 UTC
nedenom: this fix is already in 7.2. If you observe a problem in 7.2 (or later), file a new bug report with details to reproduce, and link to this one as appropriate.
Comment 28 nedenom 2012-10-21 19:11:48 UTC
(In reply to comment #27)
> nedenom: this fix is already in 7.2. If you observe a problem in 7.2 (or
> later), file a new bug report with details to reproduce, and link to this one
> as appropriate.

OK, sorry, I was confused by the previous comments about it being included only in 7.1.2 + patch 3. I was looking for a fix for the double launcher icon problem, and I thought this was it, but Netbeans 7.2 still has a double icon by default.

I now included the following line in my netbeans-7.2.desktop file:
StartupWMClass=NetBeans IDE 7.2

That solves the double icon problem. I think the installer should have done this automatically, but I guess that is a separate issue...

Anyway, thanks for fixing this property!
Comment 29 Stanislav Aubrecht 2012-10-22 08:48:30 UTC
(In reply to comment #28)
> 
> That solves the double icon problem. I think the installer should have done
> this automatically, but I guess that is a separate issue...

Please file a new issue if you want this fixed, thanks.