Make sure a window is valid for a subsystem before using it in a messagebox
This commit is contained in:
parent
73cb183fdb
commit
284b7113ad
1 changed files with 40 additions and 19 deletions
|
@ -3052,6 +3052,20 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
|
||||||
#include "x11/SDL_x11messagebox.h"
|
#include "x11/SDL_x11messagebox.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
|
||||||
|
{
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_Window *window = messageboxdata->window;
|
||||||
|
|
||||||
|
if (!window) {
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
SDL_GetWindowWMInfo(window, &info);
|
||||||
|
return (info.subsystem == drivertype);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
{
|
{
|
||||||
|
@ -3071,35 +3085,42 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
if (!buttonid) {
|
if (!buttonid) {
|
||||||
buttonid = &dummybutton;
|
buttonid = &dummybutton;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_this && _this->ShowMessageBox) {
|
if (_this && _this->ShowMessageBox) {
|
||||||
retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
|
retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
|
||||||
} else {
|
}
|
||||||
/* It's completely fine to call this function before video is initialized */
|
|
||||||
if (messageboxdata->window == NULL) {
|
/* It's completely fine to call this function before video is initialized */
|
||||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||||
if ((retval == -1) && (WIN_ShowMessageBox(messageboxdata, buttonid) == 0)) {
|
if (retval == -1 &&
|
||||||
retval = 0;
|
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) &&
|
||||||
}
|
WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if SDL_VIDEO_DRIVER_COCOA
|
#if SDL_VIDEO_DRIVER_COCOA
|
||||||
if ((retval == -1) && (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0)) {
|
if (retval == -1 &&
|
||||||
retval = 0;
|
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_COCOA) &&
|
||||||
}
|
Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if SDL_VIDEO_DRIVER_UIKIT
|
#if SDL_VIDEO_DRIVER_UIKIT
|
||||||
if ((retval == -1) && (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0)) {
|
if (retval == -1 &&
|
||||||
retval = 0;
|
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_UIKIT) &&
|
||||||
}
|
UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if SDL_VIDEO_DRIVER_X11
|
#if SDL_VIDEO_DRIVER_X11
|
||||||
if ((retval == -1) && (X11_ShowMessageBox(messageboxdata, buttonid) == 0)) {
|
if (retval == -1 &&
|
||||||
retval = 0;
|
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) &&
|
||||||
}
|
X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
if (retval == -1) {
|
||||||
if (retval == -1) {
|
SDL_SetError("No message system available");
|
||||||
SDL_SetError("No message system available");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_ShowCursor(show_cursor_prev);
|
SDL_ShowCursor(show_cursor_prev);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue