Add SDL_HINT_VIDEO_X11_NET_WM_PING to allow disabling _NET_WM_PING protocol handling in CreateWindow if desired.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index fd14051..c28cbad 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -186,6 +186,20 @@ extern "C" {
#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR"
/**
+ * \brief A variable controlling whether the X11 _NET_WM_PING protocol should be supported.
+ *
+ * This variable can be set to the following values:
+ * "0" - Disable _NET_WM_PING
+ * "1" - Enable _NET_WM_PING
+ *
+ * By default SDL will use _NET_WM_PING, but for applications that know they
+ * will not always be able to respond to ping requests in a timely manner they can
+ * turn it off to avoid the window manager thinking the app is hung.
+ * The hint is checked in CreateWindow.
+ */
+#define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING"
+
+/**
* \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
*
* This variable can be set to the following values:
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 2a77997..b950561 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -542,11 +542,23 @@ X11_CreateWindow(_THIS, SDL_Window * window)
(unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1);
{
- Atom protocols[] = {
- data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */
- data->_NET_WM_PING, /* Respond so WM knows we're alive */
- };
- X11_XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
+ Atom protocols[2];
+ int proto_count = 0;
+ const char *ping_hint;
+
+ protocols[proto_count] = data->WM_DELETE_WINDOW; /* Allow window to be deleted by the WM */
+ proto_count++;
+
+ ping_hint = SDL_GetHint(SDL_HINT_VIDEO_X11_NET_WM_PING);
+ /* Default to using ping if there is no hint */
+ if (!ping_hint || SDL_atoi(ping_hint)) {
+ protocols[proto_count] = data->_NET_WM_PING; /* Respond so WM knows we're alive */
+ proto_count++;
+ }
+
+ SDL_assert(proto_count <= sizeof(protocols) / sizeof(protocols[0]));
+
+ X11_XSetWMProtocols(display, w, protocols, proto_count);
}
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {