Browse Source

x11: #ifdef the XRandR path in the message box code

The runtime check isn't sufficient as the functions are undefined if built without XRandR.
Frank Praznik 3 months ago
parent
commit
c91f9f6968
1 changed files with 8 additions and 2 deletions
  1. 8 2
      src/video/x11/SDL_x11messagebox.c

+ 8 - 2
src/video/x11/SDL_x11messagebox.c

@@ -425,10 +425,12 @@ static bool X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
     Display *display = data->display;
     Display *display = data->display;
     SDL_WindowData *windowdata = NULL;
     SDL_WindowData *windowdata = NULL;
     const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
     const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
+#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
 #ifdef XRANDR_DISABLED_BY_DEFAULT
 #ifdef XRANDR_DISABLED_BY_DEFAULT
     const bool use_xrandr_by_default = false;
     const bool use_xrandr_by_default = false;
 #else
 #else
     const bool use_xrandr_by_default = true;
     const bool use_xrandr_by_default = true;
+#endif
 #endif
 #endif
 
 
     if (messageboxdata->window) {
     if (messageboxdata->window) {
@@ -502,12 +504,16 @@ static bool X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
             const SDL_DisplayData *dpydata = dpy->internal;
             const SDL_DisplayData *dpydata = dpy->internal;
             x = dpydata->x + ((dpy->current_mode->w - data->dialog_width) / 2);
             x = dpydata->x + ((dpy->current_mode->w - data->dialog_width) / 2);
             y = dpydata->y + ((dpy->current_mode->h - data->dialog_height) / 3);
             y = dpydata->y + ((dpy->current_mode->h - data->dialog_height) / 3);
-        } else if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, use_xrandr_by_default)) {
+        }
+#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
+        else if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, use_xrandr_by_default)) {
             XRRScreenResources *screen = X11_XRRGetScreenResourcesCurrent(display, DefaultRootWindow(display));
             XRRScreenResources *screen = X11_XRRGetScreenResourcesCurrent(display, DefaultRootWindow(display));
             XRRCrtcInfo *crtc_info = X11_XRRGetCrtcInfo(display, screen, screen->crtcs[0]);
             XRRCrtcInfo *crtc_info = X11_XRRGetCrtcInfo(display, screen, screen->crtcs[0]);
             x = (crtc_info->width - data->dialog_width) / 2;
             x = (crtc_info->width - data->dialog_width) / 2;
             y = (crtc_info->height - data->dialog_height) / 3;
             y = (crtc_info->height - data->dialog_height) / 3;
-        } else {
+        }
+#endif
+        else {
             // oh well. This will misposition on a multi-head setup. Init first next time.
             // oh well. This will misposition on a multi-head setup. Init first next time.
             x = (DisplayWidth(display, data->screen) - data->dialog_width) / 2;
             x = (DisplayWidth(display, data->screen) - data->dialog_width) / 2;
             y = (DisplayHeight(display, data->screen) - data->dialog_height) / 3;
             y = (DisplayHeight(display, data->screen) - data->dialog_height) / 3;