mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-29 14:38:29 +00:00
Use zenity messageboxes by default on X11
This makes messageboxes consistent between X11 and Wayland.
This commit is contained in:
@@ -3384,6 +3384,10 @@ if (SDL_DIALOG)
|
|||||||
set(HAVE_SDL_DIALOG TRUE)
|
set(HAVE_SDL_DIALOG TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
||||||
|
sdl_sources(${SDL3_SOURCE_DIR}/src/dialog/unix/SDL_zenitymessagebox.h)
|
||||||
|
sdl_sources(${SDL3_SOURCE_DIR}/src/dialog/unix/SDL_zenitymessagebox.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
sdl_sources("${SDL3_SOURCE_DIR}/src/process/SDL_process.c")
|
sdl_sources("${SDL3_SOURCE_DIR}/src/process/SDL_process.c")
|
||||||
if(WINDOWS)
|
if(WINDOWS)
|
||||||
|
@@ -21,9 +21,7 @@
|
|||||||
|
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
#include "SDL_zenitymessagebox.h"
|
||||||
|
|
||||||
#include "SDL_waylandmessagebox.h"
|
|
||||||
|
|
||||||
#define ZENITY_VERSION_LEN 32 // Number of bytes to read from zenity --version (including NUL)
|
#define ZENITY_VERSION_LEN 32 // Number of bytes to read from zenity --version (including NUL)
|
||||||
|
|
||||||
@@ -75,7 +73,7 @@ static bool get_zenity_version(int *major, int *minor)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
bool SDL_Zenity_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||||
{
|
{
|
||||||
int zenity_major = 0, zenity_minor = 0, output_len = 0;
|
int zenity_major = 0, zenity_minor = 0, output_len = 0;
|
||||||
int argc = 5, i;
|
int argc = 5, i;
|
||||||
@@ -84,14 +82,6 @@ bool Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *butto
|
|||||||
};
|
};
|
||||||
SDL_Process *process;
|
SDL_Process *process;
|
||||||
|
|
||||||
// Are we trying to connect to or are currently in a Wayland session?
|
|
||||||
if (!SDL_getenv("WAYLAND_DISPLAY")) {
|
|
||||||
const char *session = SDL_getenv("XDG_SESSION_TYPE");
|
|
||||||
if (session && SDL_strcasecmp(session, "wayland") != 0) {
|
|
||||||
return SDL_SetError("Not on a wayland display");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messageboxdata->numbuttons > MAX_BUTTONS) {
|
if (messageboxdata->numbuttons > MAX_BUTTONS) {
|
||||||
return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS);
|
return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS);
|
||||||
}
|
}
|
||||||
@@ -193,4 +183,3 @@ bool Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *butto
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SDL_VIDEO_DRIVER_WAYLAND
|
|
@@ -19,13 +19,9 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SDL_waylandmessagebox_h_
|
#ifndef SDL_zenitymessagebox_h_
|
||||||
#define SDL_waylandmessagebox_h_
|
#define SDL_zenitymessagebox_h_
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
extern bool SDL_Zenity_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
|
||||||
|
|
||||||
extern bool Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
|
|
||||||
|
|
||||||
#endif // SDL_VIDEO_DRIVER_WAYLAND
|
|
||||||
|
|
||||||
#endif // SDL_waylandmessagebox_h_
|
#endif // SDL_waylandmessagebox_h_
|
@@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
#include "../../core/linux/SDL_system_theme.h"
|
#include "../../core/linux/SDL_system_theme.h"
|
||||||
#include "../../core/linux/SDL_progressbar.h"
|
#include "../../core/linux/SDL_progressbar.h"
|
||||||
|
#include "../../dialog/unix/SDL_zenitymessagebox.h"
|
||||||
#include "../../events/SDL_events_c.h"
|
#include "../../events/SDL_events_c.h"
|
||||||
|
|
||||||
#include "SDL_waylandclipboard.h"
|
#include "SDL_waylandclipboard.h"
|
||||||
#include "SDL_waylandcolor.h"
|
#include "SDL_waylandcolor.h"
|
||||||
#include "SDL_waylandevents_c.h"
|
#include "SDL_waylandevents_c.h"
|
||||||
#include "SDL_waylandkeyboard.h"
|
#include "SDL_waylandkeyboard.h"
|
||||||
#include "SDL_waylandmessagebox.h"
|
|
||||||
#include "SDL_waylandmouse.h"
|
#include "SDL_waylandmouse.h"
|
||||||
#include "SDL_waylandopengles.h"
|
#include "SDL_waylandopengles.h"
|
||||||
#include "SDL_waylandvideo.h"
|
#include "SDL_waylandvideo.h"
|
||||||
@@ -708,14 +708,14 @@ static SDL_VideoDevice *Wayland_Fallback_CreateDevice(void)
|
|||||||
VideoBootStrap Wayland_preferred_bootstrap = {
|
VideoBootStrap Wayland_preferred_bootstrap = {
|
||||||
WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
|
WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
|
||||||
Wayland_Preferred_CreateDevice,
|
Wayland_Preferred_CreateDevice,
|
||||||
Wayland_ShowMessageBox,
|
SDL_Zenity_ShowMessageBox,
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
VideoBootStrap Wayland_bootstrap = {
|
VideoBootStrap Wayland_bootstrap = {
|
||||||
WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
|
WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
|
||||||
Wayland_Fallback_CreateDevice,
|
Wayland_Fallback_CreateDevice,
|
||||||
Wayland_ShowMessageBox,
|
SDL_Zenity_ShowMessageBox,
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11
|
#ifdef SDL_VIDEO_DRIVER_X11
|
||||||
|
|
||||||
|
#include "../../dialog/unix/SDL_zenitymessagebox.h"
|
||||||
#include "SDL_x11messagebox.h"
|
#include "SDL_x11messagebox.h"
|
||||||
#include "SDL_x11toolkit.h"
|
#include "SDL_x11toolkit.h"
|
||||||
|
|
||||||
@@ -234,6 +235,10 @@ static bool X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int
|
|||||||
// Display an x11 message box.
|
// Display an x11 message box.
|
||||||
bool X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
bool X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||||
{
|
{
|
||||||
|
if (SDL_Zenity_ShowMessageBox(messageboxdata, buttonID)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#if SDL_FORK_MESSAGEBOX
|
#if SDL_FORK_MESSAGEBOX
|
||||||
// Use a child process to protect against setlocale(). Annoying.
|
// Use a child process to protect against setlocale(). Annoying.
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
Reference in New Issue
Block a user