SDL_ShowMessageBox: Remove #ifdef
s and respect SDL_VIDEO_DRIVER hint.
Fixes #8892.
This commit is contained in:
parent
5f65fd360d
commit
c88c12148d
24 changed files with 89 additions and 86 deletions
|
@ -447,6 +447,7 @@ typedef struct VideoBootStrap
|
|||
const char *name;
|
||||
const char *desc;
|
||||
SDL_VideoDevice *(*create)(void);
|
||||
int (*ShowMessageBox)(const SDL_MessageBoxData *messageboxdata, int *buttonid); /* can be done without initializing backend! */
|
||||
} VideoBootStrap;
|
||||
|
||||
/* Not all of these are available in a given build. Use #ifdefs, etc. */
|
||||
|
|
|
@ -4893,69 +4893,37 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
|
||||
if (_this && _this->ShowMessageBox) {
|
||||
retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
|
||||
} else {
|
||||
/* It's completely fine to call this function before video is initialized */
|
||||
const char *driver_name = SDL_GetHint(SDL_HINT_VIDEO_DRIVER);
|
||||
if (driver_name && *driver_name != 0) {
|
||||
const char *driver_attempt = driver_name;
|
||||
while (driver_attempt && (*driver_attempt != 0) && (retval == -1)) {
|
||||
const char *driver_attempt_end = SDL_strchr(driver_attempt, ',');
|
||||
size_t driver_attempt_len = (driver_attempt_end) ? (driver_attempt_end - driver_attempt)
|
||||
: SDL_strlen(driver_attempt);
|
||||
for (int i = 0; bootstrap[i]; ++i) {
|
||||
if (bootstrap[i]->ShowMessageBox && (driver_attempt_len == SDL_strlen(bootstrap[i]->name)) &&
|
||||
(SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0)) {
|
||||
if (bootstrap[i]->ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* It's completely fine to call this function before video is initialized */
|
||||
#ifdef SDL_VIDEO_DRIVER_ANDROID
|
||||
if (retval == -1 &&
|
||||
Android_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL;
|
||||
}
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
if (retval == -1 &&
|
||||
WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
} else {
|
||||
for (int i = 0; bootstrap[i]; ++i) {
|
||||
if (bootstrap[i]->ShowMessageBox && bootstrap[i]->ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_WINRT
|
||||
if (retval == -1 &&
|
||||
WINRT_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_COCOA
|
||||
if (retval == -1 &&
|
||||
Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||
if (retval == -1 &&
|
||||
UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
||||
if (retval == -1 &&
|
||||
Wayland_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_X11
|
||||
if (retval == -1 &&
|
||||
X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_HAIKU
|
||||
if (retval == -1 &&
|
||||
HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
if (retval == -1 &&
|
||||
RISCOS_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_VITA
|
||||
if (retval == -1 &&
|
||||
VITA_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (retval == -1) {
|
||||
const char *error = SDL_GetError();
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "SDL_androidtouch.h"
|
||||
#include "SDL_androidwindow.h"
|
||||
#include "SDL_androidvulkan.h"
|
||||
#include "SDL_androidmessagebox.h"
|
||||
|
||||
#define ANDROID_VID_DRIVER_NAME "Android"
|
||||
|
||||
|
@ -162,7 +163,8 @@ static SDL_VideoDevice *Android_CreateDevice(void)
|
|||
|
||||
VideoBootStrap Android_bootstrap = {
|
||||
ANDROID_VID_DRIVER_NAME, "SDL Android video driver",
|
||||
Android_CreateDevice
|
||||
Android_CreateDevice,
|
||||
Android_ShowMessageBox
|
||||
};
|
||||
|
||||
int Android_VideoInit(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "SDL_cocoavulkan.h"
|
||||
#include "SDL_cocoametalview.h"
|
||||
#include "SDL_cocoaopengles.h"
|
||||
#include "SDL_cocoamessagebox.h"
|
||||
|
||||
@implementation SDL_CocoaVideoData
|
||||
|
||||
|
@ -180,7 +181,8 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
|
|||
|
||||
VideoBootStrap COCOA_bootstrap = {
|
||||
"cocoa", "SDL Cocoa video driver",
|
||||
Cocoa_CreateDevice
|
||||
Cocoa_CreateDevice,
|
||||
Cocoa_ShowMessageBox
|
||||
};
|
||||
|
||||
int Cocoa_VideoInit(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -120,7 +120,8 @@ static SDL_VideoDevice *DUMMY_CreateDevice(void)
|
|||
|
||||
VideoBootStrap DUMMY_bootstrap = {
|
||||
DUMMYVID_DRIVER_NAME, "SDL dummy video driver",
|
||||
DUMMY_CreateDevice
|
||||
DUMMY_CreateDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
|
@ -142,7 +143,8 @@ static SDL_VideoDevice *DUMMY_EVDEV_CreateDevice(void)
|
|||
|
||||
VideoBootStrap DUMMY_evdev_bootstrap = {
|
||||
DUMMYVID_DRIVER_EVDEV_NAME, "SDL dummy video driver with evdev",
|
||||
DUMMY_EVDEV_CreateDevice
|
||||
DUMMY_EVDEV_CreateDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
#endif /* SDL_INPUT_LINUXEV */
|
||||
|
|
|
@ -116,7 +116,8 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void)
|
|||
|
||||
VideoBootStrap Emscripten_bootstrap = {
|
||||
EMSCRIPTENVID_DRIVER_NAME, "SDL emscripten video driver",
|
||||
Emscripten_CreateDevice
|
||||
Emscripten_CreateDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
int Emscripten_VideoInit(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -39,6 +39,7 @@ extern "C" {
|
|||
#include "SDL_bmodes.h"
|
||||
#include "SDL_bframebuffer.h"
|
||||
#include "SDL_bevents.h"
|
||||
#include "SDL_bmessagebox.h"
|
||||
|
||||
static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
|
||||
return (SDL_BWin *)(window->driverdata);
|
||||
|
@ -121,7 +122,8 @@ static SDL_VideoDevice * HAIKU_CreateDevice(void)
|
|||
|
||||
VideoBootStrap HAIKU_bootstrap = {
|
||||
"haiku", "Haiku graphics",
|
||||
HAIKU_CreateDevice
|
||||
HAIKU_CreateDevice,
|
||||
HAIKU_ShowMessageBox
|
||||
};
|
||||
|
||||
void HAIKU_DeleteDevice(SDL_VideoDevice * device)
|
||||
|
|
|
@ -328,7 +328,8 @@ cleanup:
|
|||
VideoBootStrap KMSDRM_bootstrap = {
|
||||
"KMSDRM",
|
||||
"KMS/DRM Video Driver",
|
||||
KMSDRM_CreateDevice
|
||||
KMSDRM_CreateDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data)
|
||||
|
|
|
@ -82,7 +82,7 @@ static SDL_VideoDevice *N3DS_CreateDevice(void)
|
|||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap N3DS_bootstrap = { N3DSVID_DRIVER_NAME, "N3DS Video Driver", N3DS_CreateDevice };
|
||||
VideoBootStrap N3DS_bootstrap = { N3DSVID_DRIVER_NAME, "N3DS Video Driver", N3DS_CreateDevice, NULL /* no ShowMessageBox implementation */ };
|
||||
|
||||
static int N3DS_VideoInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
|
|
|
@ -136,7 +136,8 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void)
|
|||
|
||||
VideoBootStrap NGAGE_bootstrap = {
|
||||
NGAGEVID_DRIVER_NAME, "SDL ngage video driver",
|
||||
NGAGE_CreateDevice
|
||||
NGAGE_CreateDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
int NGAGE_VideoInit(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -93,7 +93,8 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void)
|
|||
|
||||
VideoBootStrap OFFSCREEN_bootstrap = {
|
||||
OFFSCREENVID_DRIVER_NAME, "SDL offscreen video driver",
|
||||
OFFSCREEN_CreateDevice
|
||||
OFFSCREEN_CreateDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
int OFFSCREEN_VideoInit(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -113,7 +113,8 @@ static SDL_VideoDevice *PS2_CreateDevice(void)
|
|||
VideoBootStrap PS2_bootstrap = {
|
||||
"PS2",
|
||||
"PS2 Video Driver",
|
||||
PS2_CreateDevice
|
||||
PS2_CreateDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_PS2 */
|
||||
|
|
|
@ -118,7 +118,8 @@ static SDL_VideoDevice *PSP_Create()
|
|||
VideoBootStrap PSP_bootstrap = {
|
||||
"PSP",
|
||||
"PSP Video Driver",
|
||||
PSP_Create
|
||||
PSP_Create,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -340,5 +340,6 @@ static SDL_VideoDevice *createDevice()
|
|||
|
||||
VideoBootStrap QNX_bootstrap = {
|
||||
"qnx", "QNX Screen",
|
||||
createDevice
|
||||
createDevice,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
|
|
@ -128,7 +128,8 @@ static SDL_VideoDevice *RPI_Create()
|
|||
VideoBootStrap RPI_bootstrap = {
|
||||
"RPI",
|
||||
"RPI Video Driver",
|
||||
RPI_Create
|
||||
RPI_Create,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "SDL_riscosmouse.h"
|
||||
#include "SDL_riscosmodes.h"
|
||||
#include "SDL_riscoswindow.h"
|
||||
#include "SDL_riscosmessagebox.h"
|
||||
|
||||
#define RISCOSVID_DRIVER_NAME "riscos"
|
||||
|
||||
|
@ -89,7 +90,8 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void)
|
|||
|
||||
VideoBootStrap RISCOS_bootstrap = {
|
||||
RISCOSVID_DRIVER_NAME, "SDL RISC OS video driver",
|
||||
RISCOS_CreateDevice
|
||||
RISCOS_CreateDevice,
|
||||
RISCOS_ShowMessageBox
|
||||
};
|
||||
|
||||
static int RISCOS_VideoInit(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "SDL_uikitclipboard.h"
|
||||
#include "SDL_uikitvulkan.h"
|
||||
#include "SDL_uikitmetalview.h"
|
||||
#include "SDL_uikitmessagebox.h"
|
||||
|
||||
#define UIKITVID_DRIVER_NAME "uikit"
|
||||
|
||||
|
@ -141,7 +142,8 @@ static SDL_VideoDevice *UIKit_CreateDevice(void)
|
|||
|
||||
VideoBootStrap UIKIT_bootstrap = {
|
||||
UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
|
||||
UIKit_CreateDevice
|
||||
UIKit_CreateDevice,
|
||||
UIKit_ShowMessageBox
|
||||
};
|
||||
|
||||
int UIKit_VideoInit(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "SDL_vitakeyboard.h"
|
||||
#include "SDL_vitamouse_c.h"
|
||||
#include "SDL_vitaframebuffer.h"
|
||||
#include "SDL_vitamessagebox.h"
|
||||
|
||||
#ifdef SDL_VIDEO_VITA_PIB
|
||||
#include "SDL_vitagles_c.h"
|
||||
|
@ -158,7 +159,8 @@ static SDL_VideoDevice *VITA_Create()
|
|||
VideoBootStrap VITA_bootstrap = {
|
||||
"VITA",
|
||||
"VITA Video Driver",
|
||||
VITA_Create
|
||||
VITA_Create,
|
||||
VITA_ShowMessageBox
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -105,7 +105,8 @@ static SDL_VideoDevice *VIVANTE_Create()
|
|||
VideoBootStrap VIVANTE_bootstrap = {
|
||||
"vivante",
|
||||
"Vivante EGL Video Driver",
|
||||
VIVANTE_Create
|
||||
VIVANTE_Create,
|
||||
NULL /* no ShowMessageBox implementation */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "SDL_waylandkeyboard.h"
|
||||
#include "SDL_waylandclipboard.h"
|
||||
#include "SDL_waylandvulkan.h"
|
||||
#include "SDL_waylandmessagebox.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
@ -318,7 +319,8 @@ static SDL_VideoDevice *Wayland_CreateDevice(void)
|
|||
|
||||
VideoBootStrap Wayland_bootstrap = {
|
||||
WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
|
||||
Wayland_CreateDevice
|
||||
Wayland_CreateDevice,
|
||||
Wayland_ShowMessageBox
|
||||
};
|
||||
|
||||
static void xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowsframebuffer.h"
|
||||
#include "SDL_windowsvulkan.h"
|
||||
#include "SDL_windowsmessagebox.h"
|
||||
|
||||
#ifdef SDL_GDK_TEXTINPUT
|
||||
#include "../gdk/SDL_gdktextinput.h"
|
||||
|
@ -284,7 +285,12 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
|
|||
}
|
||||
|
||||
VideoBootStrap WINDOWS_bootstrap = {
|
||||
"windows", "SDL Windows video driver", WIN_CreateDevice
|
||||
"windows", "SDL Windows video driver", WIN_CreateDevice,
|
||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
WIN_ShowMessageBox
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
static BOOL WIN_DeclareDPIAwareUnaware(SDL_VideoDevice *_this)
|
||||
|
|
|
@ -58,6 +58,7 @@ extern "C" {
|
|||
#include "../SDL_pixels_c.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_winrtopengles.h"
|
||||
#include "SDL_winrtmessagebox.h"
|
||||
}
|
||||
|
||||
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
|
||||
|
@ -155,10 +156,10 @@ static SDL_VideoDevice *WINRT_CreateDevice(void)
|
|||
return device;
|
||||
}
|
||||
|
||||
#define WINRTVID_DRIVER_NAME "winrt"
|
||||
VideoBootStrap WINRT_bootstrap = {
|
||||
WINRTVID_DRIVER_NAME, "SDL WinRT video driver",
|
||||
WINRT_CreateDevice
|
||||
"winrt", "SDL WinRT video driver",
|
||||
WINRT_CreateDevice,
|
||||
WINRT_ShowMessageBox
|
||||
};
|
||||
|
||||
static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "SDL_x11video.h"
|
||||
#include "SDL_x11xfixes.h"
|
||||
#include "SDL_x11xinput2.h"
|
||||
#include "SDL_x11messagebox.h"
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
#include "SDL_x11opengles.h"
|
||||
|
@ -283,7 +284,8 @@ static SDL_VideoDevice *X11_CreateDevice(void)
|
|||
|
||||
VideoBootStrap X11_bootstrap = {
|
||||
"x11", "SDL X11 video driver",
|
||||
X11_CreateDevice
|
||||
X11_CreateDevice,
|
||||
X11_ShowMessageBox
|
||||
};
|
||||
|
||||
static int (*handler)(Display *, XErrorEvent *) = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue