X11TK: Add more checks to the Xrandr code path to avoid errors

This commit is contained in:
eafton
2025-10-05 01:10:12 +03:00
committed by Özkan Sezer
parent 2638537f92
commit 87f9a0e106

View File

@@ -999,7 +999,14 @@ bool X11Toolkit_CreateWindowRes(SDL_ToolkitWindowX11 *data, int w, int h, int cx
goto FIRSTOUTPUTXRANDR; goto FIRSTOUTPUTXRANDR;
} }
if (out_info->crtc != None) {
crtc_info = X11_XRRGetCrtcInfo(display, screen_res, out_info->crtc); crtc_info = X11_XRRGetCrtcInfo(display, screen_res, out_info->crtc);
} else if (out_info->ncrtc > 0) {
crtc_info = X11_XRRGetCrtcInfo(display, screen_res, out_info->crtcs[0]);
} else {
crtc_info = NULL;
}
if (crtc_info) { if (crtc_info) {
x = (crtc_info->width - data->window_width) / 2; x = (crtc_info->width - data->window_width) / 2;
y = (crtc_info->height - data->window_height) / 3; y = (crtc_info->height - data->window_height) / 3;
@@ -1020,7 +1027,14 @@ bool X11Toolkit_CreateWindowRes(SDL_ToolkitWindowX11 *data, int w, int h, int cx
goto FIRSTCRTCXRANDR; goto FIRSTCRTCXRANDR;
} }
if (out_info->crtc != None) {
crtc_info = X11_XRRGetCrtcInfo(display, screen_res, out_info->crtc); crtc_info = X11_XRRGetCrtcInfo(display, screen_res, out_info->crtc);
} else if (out_info->ncrtc > 0) {
crtc_info = X11_XRRGetCrtcInfo(display, screen_res, out_info->crtcs[0]);
} else {
crtc_info = NULL;
}
if (!crtc_info) { if (!crtc_info) {
X11_XRRFreeOutputInfo(out_info); X11_XRRFreeOutputInfo(out_info);
goto FIRSTCRTCXRANDR; goto FIRSTCRTCXRANDR;