mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-02-02 18:41:09 +00:00
x11: Don't change mode if we are already in the correct mode
If we are already in the desired mode, changing it is a no-op at best, and harmful at worst: on Xwayland, it sometimes happens that we disable the crtc and cannot re-enable it. Resolves: https://github.com/libsdl-org/SDL/issues/4630 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
584b89abe6
commit
25cd749adb
|
@ -1040,11 +1040,20 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode
|
||||||
return SDL_SetError("Couldn't get XRandR crtc info");
|
return SDL_SetError("Couldn't get XRandR crtc info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (crtc->mode == modedata->xrandr_mode) {
|
||||||
|
#ifdef X11MODES_DEBUG
|
||||||
|
printf("already in desired mode 0x%lx (%ux%u), nothing to do\n",
|
||||||
|
crtc->mode, crtc->width, crtc->height);
|
||||||
|
#endif
|
||||||
|
status = Success;
|
||||||
|
goto freeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
X11_XGrabServer(display);
|
X11_XGrabServer(display);
|
||||||
status = X11_XRRSetCrtcConfig(display, res, output_info->crtc, CurrentTime,
|
status = X11_XRRSetCrtcConfig(display, res, output_info->crtc, CurrentTime,
|
||||||
0, 0, None, crtc->rotation, NULL, 0);
|
0, 0, None, crtc->rotation, NULL, 0);
|
||||||
if (status != Success) {
|
if (status != Success) {
|
||||||
goto setCrtcError;
|
goto ungrabServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_width = mode->w * DisplayWidthMM(display, data->screen) / DisplayWidth(display, data->screen);
|
mm_width = mode->w * DisplayWidthMM(display, data->screen) / DisplayWidth(display, data->screen);
|
||||||
|
@ -1067,8 +1076,9 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode
|
||||||
crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation,
|
crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation,
|
||||||
&data->xrandr_output, 1);
|
&data->xrandr_output, 1);
|
||||||
|
|
||||||
setCrtcError:
|
ungrabServer:
|
||||||
X11_XUngrabServer(display);
|
X11_XUngrabServer(display);
|
||||||
|
freeInfo:
|
||||||
X11_XRRFreeCrtcInfo(crtc);
|
X11_XRRFreeCrtcInfo(crtc);
|
||||||
X11_XRRFreeOutputInfo(output_info);
|
X11_XRRFreeOutputInfo(output_info);
|
||||||
X11_XRRFreeScreenResources(res);
|
X11_XRRFreeScreenResources(res);
|
||||||
|
|
Loading…
Reference in a new issue