Commit 6c56e275115fdb5a2fb93d4f6f7459ccb8460151

Sam Lantinga 2021-11-08T07:05:17

Set both _NET_WM_NAME and WM_NAME so SDL windows can be shared in the browser. Fixes https://github.com/libsdl-org/SDL/issues/4924

diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index a67bce8..476daea 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -405,6 +405,7 @@ X11_VideoInit(_THIS)
     GET_ATOM(WM_PROTOCOLS);
     GET_ATOM(WM_DELETE_WINDOW);
     GET_ATOM(WM_TAKE_FOCUS);
+    GET_ATOM(WM_NAME);
     GET_ATOM(_NET_WM_STATE);
     GET_ATOM(_NET_WM_STATE_HIDDEN);
     GET_ATOM(_NET_WM_STATE_FOCUSED);
diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h
index 7281e11..18d5f4a 100644
--- a/src/video/x11/SDL_x11video.h
+++ b/src/video/x11/SDL_x11video.h
@@ -93,6 +93,7 @@ typedef struct SDL_VideoData
     Atom WM_PROTOCOLS;
     Atom WM_DELETE_WINDOW;
     Atom WM_TAKE_FOCUS;
+    Atom WM_NAME;
     Atom _NET_WM_STATE;
     Atom _NET_WM_STATE_HIDDEN;
     Atom _NET_WM_STATE_FOCUSED;
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 8d81cb0..bdadbc7 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -734,6 +734,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 = data->videodata->WM_NAME;
+
+    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));