@@ -100,6 +100,9 @@ typedef struct SDL_MessageBoxDataX11
100
100
long event_mask ;
101
101
Atom wm_protocols ;
102
102
Atom wm_delete_message ;
103
+ #ifdef SDL_VIDEO_DRIVER_X11_XRANDR
104
+ bool xrandr ; // Whether Xrandr is present or not
105
+ #endif
103
106
104
107
int dialog_width ; // Dialog box width.
105
108
int dialog_height ; // Dialog box height.
@@ -197,7 +200,12 @@ static bool X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBox
197
200
if (!data -> display ) {
198
201
return SDL_SetError ("Couldn't open X11 display" );
199
202
}
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
+
201
209
#ifdef X_HAVE_UTF8_STRING
202
210
if (SDL_X11_HAVE_UTF8 ) {
203
211
char * * missing = NULL ;
@@ -514,7 +522,7 @@ static bool X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
514
522
y = dpydata -> y + ((dpy -> current_mode -> h - data -> dialog_height ) / 3 );
515
523
}
516
524
#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 ) {
518
526
XRRScreenResources * screen = X11_XRRGetScreenResourcesCurrent (display , DefaultRootWindow (display ));
519
527
XRRCrtcInfo * crtc_info = X11_XRRGetCrtcInfo (display , screen , screen -> crtcs [0 ]);
520
528
x = (crtc_info -> width - data -> dialog_width ) / 2 ;
0 commit comments