micheleg / dash-to-dock

A dock for the Gnome Shell. This extension moves the dash out of the overview transforming it in a dock for an easier launching of applications and a faster switching between windows and desktops.
https://micheleg.github.io/dash-to-dock/
GNU General Public License v2.0
3.84k stars 461 forks source link

Latest Chrome / Dash-To-Dock will have two Icons #215

Open schmitch opened 9 years ago

schmitch commented 9 years ago

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.

nevesnunes commented 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
micheleg commented 9 years ago

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?

marcvangend commented 8 years ago

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.

micheleg commented 8 years ago

Thanks for the additional information. Is PhpStorm based on chrome?

marcvangend commented 8 years ago

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.

Yannik commented 8 years ago

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)

Yannik commented 8 years ago

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.

Yannik commented 8 years ago

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

marcvangend commented 8 years ago

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 :-))

Yannik commented 8 years ago

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.

Yannik commented 8 years ago

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.

tflori commented 8 years ago

https://youtrack.jetbrains.com/issue/WI-31103 I created a new issue on youtrack

micheleg commented 8 years ago

@tflori Thanks for the additional information.