WM_CLASS name is now set for modern Linux Desktop Environments.
@@ -355,6 +355,9 @@ class XlibWindow(BaseWindow):
# Set caption
self.set_caption(self._caption)
+ # Set WM_CLASS for modern desktop environments
+ self.set_wm_class(self._caption)
+
# this is supported by some compositors (ie gnome-shell), and more to come
# see: http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idp6357888
_NET_WM_BYPASS_COMPOSITOR_HINT_ON = c_ulong(int(self._fullscreen))
@@ -519,6 +522,19 @@ class XlibWindow(BaseWindow):
self._set_text_property('_NET_WM_NAME', caption)
self._set_text_property('_NET_WM_ICON_NAME', caption)
+ def set_wm_class(self, name):
+ # WM_CLASS can only contain Ascii characters
+ try:
+ name = name.encode('ascii')
+ except UnicodeEncodeError:
+ name = "pyglet"
+
+ hints = xlib.XAllocClassHint()
+ hints.contents.res_class = asbytes(name)
+ hints.contents.res_name = asbytes(name.lower())
+ xlib.XSetClassHint(self._x_display, self._window, hints.contents)
+ xlib.XFree(hints)
+
def get_caption(self):
return self._caption
