@@ -425,6 +425,11 @@ static bool X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
425
425
Display * display = data -> display ;
426
426
SDL_WindowData * windowdata = NULL ;
427
427
const SDL_MessageBoxData * messageboxdata = data -> messageboxdata ;
428
+ #ifdef XRANDR_DISABLED_BY_DEFAULT
429
+ const bool use_xrandr_by_default = false;
430
+ #else
431
+ const bool use_xrandr_by_default = true;
432
+ #endif
428
433
429
434
if (messageboxdata -> window ) {
430
435
SDL_DisplayData * displaydata = SDL_GetDisplayDriverDataForWindow (messageboxdata -> window );
@@ -497,7 +502,13 @@ static bool X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
497
502
const SDL_DisplayData * dpydata = dpy -> internal ;
498
503
x = dpydata -> x + ((dpy -> current_mode -> w - data -> dialog_width ) / 2 );
499
504
y = dpydata -> y + ((dpy -> current_mode -> h - data -> dialog_height ) / 3 );
500
- } else { // oh well. This will misposition on a multi-head setup. Init first next time.
505
+ } else if (SDL_GetHintBoolean (SDL_HINT_VIDEO_X11_XRANDR , use_xrandr_by_default )) {
506
+ XRRScreenResources * screen = X11_XRRGetScreenResourcesCurrent (display , DefaultRootWindow (display ));
507
+ XRRCrtcInfo * crtc_info = X11_XRRGetCrtcInfo (display , screen , screen -> crtcs [0 ]);
508
+ x = (crtc_info -> width - data -> dialog_width ) / 2 ;
509
+ y = (crtc_info -> height - data -> dialog_height ) / 3 ;
510
+ } else {
511
+ // oh well. This will misposition on a multi-head setup. Init first next time.
501
512
x = (DisplayWidth (display , data -> screen ) - data -> dialog_width ) / 2 ;
502
513
y = (DisplayHeight (display , data -> screen ) - data -> dialog_height ) / 3 ;
503
514
}
0 commit comments