Skip to content

Commit c147ddf

Browse files
Everett Aftonicculus
authored andcommitted
Do not use Xrandr if the extension is not queryable in the X11 messagebox implementation
1 parent df07c09 commit c147ddf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/video/x11/SDL_x11messagebox.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ typedef struct SDL_MessageBoxDataX11
100100
long event_mask;
101101
Atom wm_protocols;
102102
Atom wm_delete_message;
103+
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
104+
bool xrandr; // Whether Xrandr is present or not
105+
#endif
103106

104107
int dialog_width; // Dialog box width.
105108
int dialog_height; // Dialog box height.
@@ -197,7 +200,12 @@ static bool X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBox
197200
if (!data->display) {
198201
return SDL_SetError("Couldn't open X11 display");
199202
}
200-
203+
204+
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
205+
int xrandr_event_base, xrandr_error_base;
206+
data->xrandr = X11_XRRQueryExtension(data->display, &xrandr_event_base, &xrandr_error_base);
207+
#endif
208+
201209
#ifdef X_HAVE_UTF8_STRING
202210
if (SDL_X11_HAVE_UTF8) {
203211
char **missing = NULL;
@@ -514,7 +522,7 @@ static bool X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
514522
y = dpydata->y + ((dpy->current_mode->h - data->dialog_height) / 3);
515523
}
516524
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
517-
else if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, use_xrandr_by_default)) {
525+
else if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, use_xrandr_by_default) && data->xrandr) {
518526
XRRScreenResources *screen = X11_XRRGetScreenResourcesCurrent(display, DefaultRootWindow(display));
519527
XRRCrtcInfo *crtc_info = X11_XRRGetCrtcInfo(display, screen, screen->crtcs[0]);
520528
x = (crtc_info->width - data->dialog_width) / 2;

0 commit comments

Comments
 (0)