x11: Fix mode switching when running under XWayland

XWayland emulates the XRandR interface, so it still needs the actual mode switch call to trigger the mode switching emulation.

There is also no need to wait when using XWayland mode switching emulation, as it is handled via viewport scaling and thus instantaneous.
main
Frank Praznik 2024-04-17 10:51:33 -04:00
parent bed6c5b81f
commit a2eb2697a3
2 changed files with 12 additions and 6 deletions

View File

@ -1248,8 +1248,11 @@ const SDL_DisplayMode *SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mode) int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{ {
/* Mode switching is being emulated per-window; nothing to do and cannot fail. */ /* Mode switching is being emulated per-window; nothing to do and cannot fail,
if (SDL_ModeSwitchingEmulated(_this)) { * except for XWayland, which still needs the actual mode setting call since
* it's emulated via the XRandR interface.
*/
if (SDL_ModeSwitchingEmulated(_this) && SDL_strcmp(_this->name, "x11") != 0) {
return 0; return 0;
} }

View File

@ -921,11 +921,14 @@ int X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SD
viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2); viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2);
/* XWayland mode switches are emulated with viewports and thus instantaneous. */
if (!viddata->is_xwayland) {
if (sdl_display->current_mode != mode) { if (sdl_display->current_mode != mode) {
data->mode_switch_deadline_ns = SDL_GetTicksNS() + MODE_SWITCH_TIMEOUT_NS; data->mode_switch_deadline_ns = SDL_GetTicksNS() + MODE_SWITCH_TIMEOUT_NS;
} else { } else {
data->mode_switch_deadline_ns = 0; data->mode_switch_deadline_ns = 0;
} }
}
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR #ifdef SDL_VIDEO_DRIVER_X11_XRANDR
if (data->use_xrandr) { if (data->use_xrandr) {