mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-02 10:04:33 +00:00
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.
This commit is contained in:
@@ -1248,8 +1248,11 @@ const SDL_DisplayMode *SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
|
||||
|
||||
int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mode)
|
||||
{
|
||||
/* Mode switching is being emulated per-window; nothing to do and cannot fail. */
|
||||
if (SDL_ModeSwitchingEmulated(_this)) {
|
||||
/* Mode switching is being emulated per-window; nothing to do and cannot fail,
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -921,10 +921,13 @@ int X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SD
|
||||
|
||||
viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2);
|
||||
|
||||
if (sdl_display->current_mode != mode) {
|
||||
data->mode_switch_deadline_ns = SDL_GetTicksNS() + MODE_SWITCH_TIMEOUT_NS;
|
||||
} else {
|
||||
data->mode_switch_deadline_ns = 0;
|
||||
/* XWayland mode switches are emulated with viewports and thus instantaneous. */
|
||||
if (!viddata->is_xwayland) {
|
||||
if (sdl_display->current_mode != mode) {
|
||||
data->mode_switch_deadline_ns = SDL_GetTicksNS() + MODE_SWITCH_TIMEOUT_NS;
|
||||
} else {
|
||||
data->mode_switch_deadline_ns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
|
||||
Reference in New Issue
Block a user