WM_CLASS missing GNOME 3

During our app internal testing we headed some problems with GNOME desktop env.

First one of our tester either keyboard or mouse didn’t worked.

And also task bar icon do not shown as it’s shown when other desktops are in use, could be missing WM_CLASS.

What it’s and how this can be fixed ?

Could you please provide an example where the keyboard and mouse are not working, or give us some steps to reproduce the issue?

Did anybody ever find a way to solve the WM_CLASS issue? My app gets no icon on Ubuntu 18.04

Hmmm that’s strange. Just tested the Projucer on Ubuntu 18.04 LTS and the icon seems fine.

Is there anything I need to do to get my window Icon to show up? I added an icon in the Linux exporter. I also tried getting the peer after I call addToDesktop() and setting an icon. Neither seem to have an effect.

I noticed which Projucer has an icon, it doesn’t have an application name.

Sometimes the following will get the icon to show up:
xprop -name “AppName” -f WMCLASS 8s -set WM_CLASS “AppName”

I’ve been experiencing an issue recently that may be related:

Add the Projucer icon to the dash/dock permanently via the “Add to Favorites” option, and see if the behavior changes. I believe a .desktop file must exist before the “Add to Favorites” option is available.

In my case, after adding the Projucer icon to the dash/dock, launching the application causes a second, lower-resolution Projucer icon to appear (this can be seen in the attached image – I’m using the dash-to-dock extension but this occurs with that extension disabled in the normal dash, as well). A bit of searching suggests that adding a WM_CLASS attribute to the Projucer.desktop file would fix this issue, but running xprop WM_CLASS and clicking on the Projucer returns: WM_CLASS: not found.

I’m running GNOME on Fedora, but I would guess that this behaviour isn’t any different in GNOME on Ubuntu.

Same problem here on Ubuntu 18.04 + GNOME. How to fix it:

--- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp
+++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp
@@ -2722,6 +2722,13 @@ private:
         XSetWMHints (display, windowH, wmHints);
         XFree (wmHints);
+        // Set WM_CLASS property
+        XClassHint* classHint = XAllocClassHint();
+        classHint->res_name  = const_cast<char*>(component.getName().toRawUTF8());
+        classHint->res_class = const_cast<char*>(component.getName().toRawUTF8());
+        XSetClassHint (display, windowH, classHint);
+        XFree (classHint);
         // Set the window type

I’m not 100% happy with that hacky const_cast<char*> though. That’s the only way I’ve found to take a char* from a JUCE string. Beautifications are welcome…

Thanks! This has been added to the develop branch now: