From af2279b2862f24919bd8cadddec3bd1b829eab11 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 29 Jul 2025 09:41:35 -0700
Subject: [PATCH] Revert "Use SDL_MessageBoxFlags and SDL_MessageBoxButtonFlags
appropriately"
This reverts commit 059af5265aee9cd9608d2f2c7030c9b62e4f02b3.
---
src/video/SDL_video.c | 2 +-
src/video/haiku/SDL_bmessagebox.cc | 25 ++++++++++++++++-------
src/video/riscos/SDL_riscosmessagebox.c | 4 ++--
src/video/wayland/SDL_waylandmessagebox.c | 2 +-
src/video/windows/SDL_windowsmessagebox.c | 4 ++--
5 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 9691f53582b7d..4e22f28c580e7 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -4561,7 +4561,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
return retval;
}
-int SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window)
+int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
{
#ifdef __EMSCRIPTEN__
/* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */
diff --git a/src/video/haiku/SDL_bmessagebox.cc b/src/video/haiku/SDL_bmessagebox.cc
index 0ebb6a96df830..d59c7a564ae65 100644
--- a/src/video/haiku/SDL_bmessagebox.cc
+++ b/src/video/haiku/SDL_bmessagebox.cc
@@ -154,7 +154,7 @@ class HAIKU_SDL_MessageBox : public BAlert
(aMessageBoxData->message[0]) ?
SetMessageText(aMessageBoxData->message) : SetMessageText(HAIKU_SDL_DefMessage);
- SetType(ConvertMessageBoxType(aMessageBoxData->flags));
+ SetType(ConvertMessageBoxType(static_cast<SDL_MessageBoxFlags>(aMessageBoxData->flags)));
}
void
@@ -264,12 +264,23 @@ class HAIKU_SDL_MessageBox : public BAlert
size_t countButtons = fButtons.size();
for (size_t i = 0; i < countButtons; ++i) {
- if (fButtons[i]->flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
- fCloseButton = static_cast<int>(i);
- }
- if (fButtons[i]->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
- fDefaultButton = static_cast<int>(i);
- }
+ switch (fButtons[i]->flags)
+ {
+ case SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT:
+ {
+ fCloseButton = static_cast<int>(i);
+ break;
+ }
+ case SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT:
+ {
+ fDefaultButton = static_cast<int>(i);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
AddButton(fButtons[i]->text);
}
diff --git a/src/video/riscos/SDL_riscosmessagebox.c b/src/video/riscos/SDL_riscosmessagebox.c
index a7213d50012a0..e7dd11916d2cf 100644
--- a/src/video/riscos/SDL_riscosmessagebox.c
+++ b/src/video/riscos/SDL_riscosmessagebox.c
@@ -40,9 +40,9 @@ int RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttoni
regs.r[0] = (unsigned int)&error;
regs.r[1] = (1 << 8) | (1 << 4);
- if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) {
+ if (messageboxdata->flags == SDL_MESSAGEBOX_INFORMATION) {
regs.r[1] |= (1 << 9);
- } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
+ } else if (messageboxdata->flags == SDL_MESSAGEBOX_WARNING) {
regs.r[1] |= (2 << 9);
}
diff --git a/src/video/wayland/SDL_waylandmessagebox.c b/src/video/wayland/SDL_waylandmessagebox.c
index aa64f6a22708c..1744dbda85835 100644
--- a/src/video/wayland/SDL_waylandmessagebox.c
+++ b/src/video/wayland/SDL_waylandmessagebox.c
@@ -147,7 +147,7 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button
* We need to handle it gracefully, otherwise no message box will be shown.
*/
argv[argc++] = zenity_major > 3 || (zenity_major == 3 && zenity_minor >= 90) ? "--icon" : "--icon-name";
- switch (messageboxdata->flags & (SDL_MESSAGEBOX_ERROR | SDL_MESSAGEBOX_WARNING | SDL_MESSAGEBOX_INFORMATION)) {
+ switch (messageboxdata->flags) {
case SDL_MESSAGEBOX_ERROR:
argv[argc++] = "dialog-error";
break;
diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c
index 7a2f19e5a853f..7f27022fe5172 100644
--- a/src/video/windows/SDL_windowsmessagebox.c
+++ b/src/video/windows/SDL_windowsmessagebox.c
@@ -238,7 +238,7 @@ typedef struct
WORD numbuttons;
} WIN_DialogData;
-static SDL_bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, SDL_MessageBoxButtonFlags flags, size_t *i)
+static SDL_bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, Uint32 flags, size_t *i)
{
for (*i = 0; *i < (size_t)messageboxdata->numbuttons; ++*i) {
if (messageboxdata->buttons[*i].flags & flags) {
@@ -702,7 +702,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *
return SDL_SetError("Number of butons exceeds limit of %d", MAX_BUTTONS);
}
- switch (messageboxdata->flags & (SDL_MESSAGEBOX_ERROR | SDL_MESSAGEBOX_WARNING | SDL_MESSAGEBOX_INFORMATION)) {
+ switch (messageboxdata->flags) {
case SDL_MESSAGEBOX_ERROR:
icon = (Uint16)(size_t)IDI_ERROR;
break;