SDL: X11 windows cannot be shared in browsers (Firefox, Chromium)
X11 Windows created using SDL_CreateWindow cannot be shared in browser (see also Genymobile/scrcpy#2640). The bug has been introduced in b3b4677e3295e49fc37e1400c3b076c4617f162d. Apparently, both _NET_WM_NAME and WM_NAME need to be set in order for the browser to find the window.
The following (quick and dirty) patch will fix this behaviour:
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 8d81cb055..f083d782b 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -735,6 +735,9 @@ X11_SetWindowTitle(_THIS, SDL_Window * window)
Atom UTF8_STRING = data->videodata->UTF8_STRING;
Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
+ Atom WM_NAME = X11_XInternAtom(data->videodata->display, "WM_NAME", False);
+ X11_XChangeProperty(display, data->xwindow, WM_NAME, UTF8_STRING, 8, 0, (const unsigned char *) title, strlen(title));
+
status = X11_XChangeProperty(display, data->xwindow, _NET_WM_NAME, UTF8_STRING, 8, 0, (const unsigned char *) title, strlen(title));
if (status != 1) {
Moreover, using xdotool to rename (and set both properties of) a window can be used to work around this issue:
xdotool selectwindow set_window --name "WindowName"
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (11 by maintainers)
Commits related to this issue
- Updated X11_SetWindowTitle() to set both WM_NAME (non-UTF-8) and _NET_WM_NAME (UTF-8) for window name/title. Issue #4924 & #4979 — committed to morgant/SDL by morgant 3 years ago
- Add back X11 legacy WM_NAME encodings Closes #4924. Based on patches of the past, such as this work by James Cloos in July 2010: https://github.com/exg/rxvt-unicode/commit/d7d98751b7385416ad1694b5f1... — committed to ctrlcctrlv/SDL by ctrlcctrlv 3 years ago
- Update X11_SetWindowTitle() to use locale instead of forcing ASCII for WM_NAME. Issue #4924 & #4979 — committed to morgant/SDL by morgant 3 years ago
- Add back X11 legacy WM_NAME encodings Closes #4924. Based on patches of the past, such as this work by James Cloos in July 2010: https://github.com/exg/rxvt-unicode/commit/d7d98751b7385416ad1694b5f1... — committed to libsdl-org/SDL by ctrlcctrlv 3 years ago
- video: x11: Fix an invalid SDL_LogError() call This fixes a compile warning — and possible invalid memory read — introduced in 9c03d255 ("Add back X11 legacy WM_NAME encodings"), which was part of PR... — committed to sulix/SDL by sulix 3 years ago
- video: x11: Fix an invalid SDL_LogError() call This fixes a compile warning — and possible invalid memory read — introduced in 9c03d255 ("Add back X11 legacy WM_NAME encodings"), which was part of PR... — committed to libsdl-org/SDL by sulix 3 years ago
I’d be curious what
xpropshows forWM_NAMEin the test code from #4288 (whether it’s now no longer clipped), but I’ve unfortunately run out of time to test until Tuesday. Many thanks for helping get this resolved!Fixed, thanks!