x11: Disable the X Synchronization Extension by default

Under the right conditions, this extension can result is smoother resizing when rendering with OpenGL, however, it is known to cause problems in certain cases, such as when handling presentation externally.

Gate it behind a hint, and disable it by default. Developers can selectively enable it when they verify that they meet the criteria for using it, and that it behaves correctly in their apps/games.
This commit is contained in:
Frank Praznik
2026-05-05 12:51:45 -04:00
parent f6f4664ed1
commit b8545fce54
2 changed files with 27 additions and 1 deletions

View File

@@ -4128,6 +4128,31 @@ extern "C" {
*/
#define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER"
/**
* A variable controlling whether the X Synchronization Extension is enabled.
*
* If set, this can result in smoother window resizing when rendering using
* OpenGL, however, there are some conditions:
*
* - It is only activated on windows created with the `SDL_WINDOW_OPENGL` flag
* (windows using an SDL OpenGL renderer have this automatically set).
* - When activated, presentation must be done with `SDL_GL_SwapWindow()`
* (`SDL_RenderPresent()` calls this internally for OpenGL renderers as well).
*
* Enabling this and presenting via an external mechanism will result in sync
* requests not being acked, and hangs and other odd window behavior may result.
*
* The variable can be set to the following values:
*
* - "0": The X Synchronization Extension is disabled. (default)
* - "1": The X Synchronization Extension is enabled.
*
* This hint should be set before creating a window.
*
* \since This hint is available since SDL 3.4.10.
*/
#define SDL_HINT_VIDEO_X11_ENABLE_XSYNC_EXT "SDL_VIDEO_X11_ENABLE_XSYNC_EXT"
/**
* A variable controlling whether SDL should call XSelectInput() to enable
* input events on X11 windows wrapped by SDL windows.

View File

@@ -585,7 +585,8 @@ bool X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties
}
const bool force_override_redirect = SDL_GetHintBoolean(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, false);
const bool use_resize_sync = !!(window->flags & SDL_WINDOW_OPENGL); // Doesn't work well with Vulkan
const bool use_resize_sync = SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_ENABLE_XSYNC_EXT, false) &&
(window->flags & SDL_WINDOW_OPENGL) != 0; // Doesn't work well with Vulkan
SDL_WindowData *windowdata;
Display *display = data->display;
int screen = displaydata->screen;