From d03e099871a676d13f645effc630e63726cac38b Mon Sep 17 00:00:00 2001 From: George Broughton Date: Sat, 19 Aug 2023 00:29:49 +0200 Subject: [PATCH] Fix x11 taskbar icon/title --- src/video/x11/SDL_x11window.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 664de3603ea14..797296dd97711 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -1934,6 +1934,18 @@ int SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title) if (conv == 0) { X11_XSetTextProperty(display, xwindow, &titleprop, XA_WM_NAME); + + /* update the x11 class name property for the window */ + XClassHint *classhints = X11_XAllocClassHint(); + if (classhints) + { + classhints->res_class = (char*)titleprop.value; + classhints->res_name = (char*)titleprop.value; + + X11_XSetWMProperties(display, xwindow, NULL, NULL, NULL, 0, NULL, NULL, classhints); + X11_XFree(classhints); + } + X11_XFree(titleprop.value); /* we know this can't be a locale error as we checked X locale validity */ } else if (conv < 0) { @@ -1947,6 +1959,18 @@ int SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title) status = X11_Xutf8TextListToTextProperty(display, &title, 1, XUTF8StringStyle, &titleprop); if (status == Success) { X11_XSetTextProperty(display, xwindow, &titleprop, _NET_WM_NAME); + + /* update the x11 class name property for the window */ + XClassHint *classhints = X11_XAllocClassHint(); + if (classhints) + { + classhints->res_class = (char*)titleprop.value; + classhints->res_name = (char*)titleprop.value; + + X11_XSetWMProperties(display, xwindow, NULL, NULL, NULL, 0, NULL, NULL, classhints); + X11_XFree(classhints); + } + X11_XFree(titleprop.value); } else { return SDL_SetError("Failed to convert title to UTF8! Bad encoding, or bad Xorg encoding? Window title: «%s»", title);