From f9af0c03766d0570e3a6e32771d09258b7c0d41e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 5 Jan 2016 02:27:26 -0500 Subject: [PATCH] x11: Put a matching window_group wmhint on every window created. This is useful to the Window Manager, so it can know to associate multiple SDL windows with a single app. --- src/video/x11/SDL_x11video.c | 3 +++ src/video/x11/SDL_x11video.h | 1 + src/video/x11/SDL_x11window.c | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 13ddeb5dbc67d..a2ea05695c9f7 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -376,6 +376,9 @@ X11_VideoInit(_THIS) /* Get the process PID to be associated to the window */ data->pid = getpid(); + /* I have no idea how random this actually is, or has to be. */ + data->window_group = (XID) (((size_t) data->pid) ^ ((size_t) _this)); + /* Open a connection to the X input manager */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 61cb5833965cc..de991ca9212c3 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -81,6 +81,7 @@ typedef struct SDL_VideoData int numwindows; SDL_WindowData **windowlist; int windowlistlength; + XID window_group; /* This is true for ICCCM2.0-compliant window managers */ SDL_bool net_wm; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 7d0914e304b90..47731cd1977b3 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -524,7 +524,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) /* Setup the input hints so we get keyboard input */ wmhints = X11_XAllocWMHints(); wmhints->input = True; - wmhints->flags = InputHint; + wmhints->window_group = data->window_group; + wmhints->flags = InputHint | WindowGroupHint; /* Setup the class hints so we can get an icon (AfterStep) */ classhints = X11_XAllocClassHint();