Open schmitch opened 9 years ago
The problem is in Chrome's desktop entry, which executes a wrapper. I think GNOME Shell looks at the WM_CLASS window property and creates another icon if it doesn't match with the launcher. Probably not a Dash-To-Dock issue.
You can quickly fix it like this:
sudo sed -i.bak '/\[Desktop Entry\]/a StartupWMClass=Google-chrome-stable' /usr/share/applications/google-chrome.desktop
Hi,
thanks for the bug support and investigation. There are few problem with chrome (see for instance #128) which I think are probably not strictly related to the extension. Does the problem appear with the extension disabled?
FYI: I had the same problem with the PhpStorm icon after updating to Gnome-shell 3.18. I verified that the StartupWMClass value was already set correctly. Turning off dash-to-dock and turning it back on again seems to have solved the problem.
Thanks for the additional information. Is PhpStorm based on chrome?
No, it's not. PhpStorm stands on its own. It's written in java and spawns multiple java processes. If I understand correctly, that is why it's necessary to explicitly define the StartupWMClass in the .desktop file.
This bug happens to me on Fedora 23 running Gnome 3.18 & Dash to dock as well. For example, it happens on all Jetbrains IDE for me: Phpstorm, PyCharm.. It is very annoying. I am not sure, whether it is the fault of dash to dock though. I did not do a fresh install of my system, but after removing dash to dock it still didn't work. This worked perfectly gnome < 3.18. (Yes, StartupWMClass is set correctly! xprop WM_CLASS also shows the correct WM_CLASS)
I have collected some more information about this: There has been a question about the same issue on unix.stackexchange.com: http://unix.stackexchange.com/questions/242824/java-application-appears-twice-in-dash-dock
Someone gave a very useful answer there:
I see this also when using Java based apps.
I have tracked this issue down to Java not null terminating the WM_CLASS string. Mutter seems to return this invalid string as a result and gnome-shell uses this invalid string for matching the application name which obviously fails.
It is a bug in Java as the WM_CLASS string is supposed to be null terminated. I'm not sure what changed in mutter to expose this issue as it worked previously.
Indeed, this is correct. Quoting from the ICCCM specification (http://www.x.org/docs/ICCCM/icccm.pdf):
4.1.2.5. WM_CLASS Property The WM_CLASS property (of type STRING without control characters) contains two consecutive null-terminated strings. [..] Note that WM_CLASS strings are null-terminated and, thus, differ from the general conventions that STRING properties are null-separated. This inconsistency is necessary for backwards compatibility.
Here are the relevant methods for setting the WM_CLASS in the Jetbrains IDEs: https://github.com/JetBrains/intellij-community/blob/5d350e1e5bd93beed2885671b77de4f0b79f6dc5/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java#L109 https://github.com/JetBrains/intellij-community/blob/5d350e1e5bd93beed2885671b77de4f0b79f6dc5/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java#L120
Thanks @Yannik for looking into this. So, if I understand correctly, it is a bug in IntelliJ/PhpStorm that WM_CLASS strings are not formatted correctly? In that case, can you file a bug report upstream? (I would do it myself if I'd know more about java, but "null terminating strings" means nothing to me :-))
Jetbrains IDEs must null-terminate the string to get this working. Here is a commit that shows how it could be done (only appending a null byte is necessary): https://github.com/Yannik/intellij-community/commit/56e487fed4e897adbe93cb76f06ce1581ac335f4 You can easily compile this yourself and then just replace AppUIUtil.class in your lib/phpstorm.jar. I have tested it and it works perfectly. No more duplicate icons. Needs to be re-done on updates to the IDE though. Edit: While working on this stuff, I noticed that (of course) IDEA shows the same broken behaviour.
Original jetbrains-issue implementing correct WM_CLASS: https://youtrack.jetbrains.com/issue/IDEA-70806 Original commit: https://github.com/Yannik/intellij-community/commit/8e380b95e9de261db6663d66ab66ac21caf82a21 Refactor that introduces getFrameClass(): https://github.com/Yannik/intellij-community/commit/8abcc8791a844b6ccd3b2c567a2dd496e512ccb4
I don't have the time to go through creating a complete writeup of these notes in a jetbrains bug just now, if someone else can go ahead and do so, please do it.
https://youtrack.jetbrains.com/issue/WI-31103 I created a new issue on youtrack
@tflori Thanks for the additional information.
Somehow this worked in the past but I think due to changes in Chrome dash-to-dock can't add Chrome to Favorites with right Click inside the Dash and also if I add the Favorite inside the Applications it will create a new Icon while clicking on the Dash Icon. This worked in the past.