forked from pool/python-pyglet
35 lines
1.3 KiB
Diff
35 lines
1.3 KiB
Diff
![]() |
Index: pyglet/window/xlib/__init__.py
|
||
|
===================================================================
|
||
|
--- pyglet/window/xlib/__init__.py.orig
|
||
|
+++ pyglet/window/xlib/__init__.py
|
||
|
@@ -352,6 +352,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))
|
||
|
@@ -513,6 +516,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
|
||
|
|