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 */
|
||||
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_on_scale_change = X11_OnMessageBoxScaleChange;
|
||||
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;
|
||||
int i;
|
||||
@@ -456,9 +456,17 @@ SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_Tool
|
||||
}
|
||||
#endif
|
||||
|
||||
window->parent_device = NULL;
|
||||
if (create_new_display) {
|
||||
window->display = X11_XOpenDisplay(NULL);
|
||||
window->display_close = true;
|
||||
if (!window->display) {
|
||||
ErrorFreeRetNull("Couldn't open X11 display", window);
|
||||
}
|
||||
} else {
|
||||
if (parent) {
|
||||
SDL_VideoData *videodata = SDL_GetVideoDevice()->internal;
|
||||
window->display = videodata->display;
|
||||
window->parent_device = SDL_GetVideoDevice();
|
||||
window->display = window->parent_device->internal->display;
|
||||
window->display_close = false;
|
||||
} else if (tkparent) {
|
||||
window->display = tkparent->display;
|
||||
@@ -470,6 +478,7 @@ SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_Tool
|
||||
ErrorFreeRetNull("Couldn't open X11 display", window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
int xrandr_event_base, xrandr_error_base;
|
||||
|
@@ -61,6 +61,7 @@ typedef struct SDL_ToolkitWindowX11
|
||||
bool display_close;
|
||||
|
||||
/* Parent */
|
||||
SDL_VideoDevice *parent_device;
|
||||
SDL_Window *parent;
|
||||
struct SDL_ToolkitWindowX11 *tk_parent;
|
||||
|
||||
@@ -198,7 +199,7 @@ typedef struct SDL_ToolkitMenuItemX11
|
||||
} SDL_ToolkitMenuItemX11;
|
||||
|
||||
/* 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 void X11Toolkit_DoWindowEventLoop(SDL_ToolkitWindowX11 *data);
|
||||
extern void X11Toolkit_ResizeWindow(SDL_ToolkitWindowX11 *data, int w, int h);
|
||||
|
Reference in New Issue
Block a user