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

Most upvoted comments

I’d be curious what xprop shows for WM_NAME in 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!