mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-07 02:16:26 +00:00
X11TK: Fix a bug where closing the messagebox would kill the application
This commit is contained in:
@@ -196,7 +196,11 @@ static bool X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create window */
|
/* Create window */
|
||||||
controls.window = X11Toolkit_CreateWindowStruct(messageboxdata->window, NULL, SDL_TOOLKIT_WINDOW_MODE_X11_DIALOG, colorhints);
|
#if SDL_FORK_MESSAGEBOX
|
||||||
|
controls.window = X11Toolkit_CreateWindowStruct(messageboxdata->window, NULL, SDL_TOOLKIT_WINDOW_MODE_X11_DIALOG, colorhints, true);
|
||||||
|
#else
|
||||||
|
controls.window = X11Toolkit_CreateWindowStruct(messageboxdata->window, NULL, SDL_TOOLKIT_WINDOW_MODE_X11_DIALOG, colorhints, false);
|
||||||
|
#endif
|
||||||
controls.window->cb_data = &controls;
|
controls.window->cb_data = &controls;
|
||||||
controls.window->cb_on_scale_change = X11_OnMessageBoxScaleChange;
|
controls.window->cb_on_scale_change = X11_OnMessageBoxScaleChange;
|
||||||
if (!controls.window) {
|
if (!controls.window) {
|
||||||
|
@@ -420,7 +420,7 @@ static void X11Toolkit_GetTextWidthHeight(SDL_ToolkitWindowX11 *data, const char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_ToolkitWindowX11 *tkparent, SDL_ToolkitWindowModeX11 mode, const SDL_MessageBoxColor *colorhints)
|
SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_ToolkitWindowX11 *tkparent, SDL_ToolkitWindowModeX11 mode, const SDL_MessageBoxColor *colorhints, bool create_new_display)
|
||||||
{
|
{
|
||||||
SDL_ToolkitWindowX11 *window;
|
SDL_ToolkitWindowX11 *window;
|
||||||
int i;
|
int i;
|
||||||
@@ -456,20 +456,29 @@ SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_Tool
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (parent) {
|
window->parent_device = NULL;
|
||||||
SDL_VideoData *videodata = SDL_GetVideoDevice()->internal;
|
if (create_new_display) {
|
||||||
window->display = videodata->display;
|
window->display = X11_XOpenDisplay(NULL);
|
||||||
window->display_close = false;
|
window->display_close = true;
|
||||||
} else if (tkparent) {
|
if (!window->display) {
|
||||||
window->display = tkparent->display;
|
ErrorFreeRetNull("Couldn't open X11 display", window);
|
||||||
window->display_close = false;
|
}
|
||||||
} else {
|
} else {
|
||||||
window->display = X11_XOpenDisplay(NULL);
|
if (parent) {
|
||||||
window->display_close = true;
|
window->parent_device = SDL_GetVideoDevice();
|
||||||
if (!window->display) {
|
window->display = window->parent_device->internal->display;
|
||||||
ErrorFreeRetNull("Couldn't open X11 display", window);
|
window->display_close = false;
|
||||||
}
|
} else if (tkparent) {
|
||||||
}
|
window->display = tkparent->display;
|
||||||
|
window->display_close = false;
|
||||||
|
} else {
|
||||||
|
window->display = X11_XOpenDisplay(NULL);
|
||||||
|
window->display_close = true;
|
||||||
|
if (!window->display) {
|
||||||
|
ErrorFreeRetNull("Couldn't open X11 display", window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
|
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
|
||||||
int xrandr_event_base, xrandr_error_base;
|
int xrandr_event_base, xrandr_error_base;
|
||||||
|
@@ -61,6 +61,7 @@ typedef struct SDL_ToolkitWindowX11
|
|||||||
bool display_close;
|
bool display_close;
|
||||||
|
|
||||||
/* Parent */
|
/* Parent */
|
||||||
|
SDL_VideoDevice *parent_device;
|
||||||
SDL_Window *parent;
|
SDL_Window *parent;
|
||||||
struct SDL_ToolkitWindowX11 *tk_parent;
|
struct SDL_ToolkitWindowX11 *tk_parent;
|
||||||
|
|
||||||
@@ -198,7 +199,7 @@ typedef struct SDL_ToolkitMenuItemX11
|
|||||||
} SDL_ToolkitMenuItemX11;
|
} SDL_ToolkitMenuItemX11;
|
||||||
|
|
||||||
/* WINDOW FUNCTIONS */
|
/* WINDOW FUNCTIONS */
|
||||||
extern SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_ToolkitWindowX11 *tkparent, SDL_ToolkitWindowModeX11 mode, const SDL_MessageBoxColor *colorhints);
|
extern SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_ToolkitWindowX11 *tkparent, SDL_ToolkitWindowModeX11 mode, const SDL_MessageBoxColor *colorhints, bool create_new_display);
|
||||||
extern bool X11Toolkit_CreateWindowRes(SDL_ToolkitWindowX11 *data, int w, int h, int cx, int cy, char *title);
|
extern bool X11Toolkit_CreateWindowRes(SDL_ToolkitWindowX11 *data, int w, int h, int cx, int cy, char *title);
|
||||||
extern void X11Toolkit_DoWindowEventLoop(SDL_ToolkitWindowX11 *data);
|
extern void X11Toolkit_DoWindowEventLoop(SDL_ToolkitWindowX11 *data);
|
||||||
extern void X11Toolkit_ResizeWindow(SDL_ToolkitWindowX11 *data, int w, int h);
|
extern void X11Toolkit_ResizeWindow(SDL_ToolkitWindowX11 *data, int w, int h);
|
||||||
|
Reference in New Issue
Block a user