Fixed multi-window test programs not quitting when windows are closed

This commit is contained in:
Sam Lantinga 2024-06-25 10:15:36 -07:00
parent 596c0af0f3
commit b37b94453c
2 changed files with 10 additions and 2 deletions

View file

@ -248,12 +248,12 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
int toplevel_count = 0;
SDL_Window *n;
for (n = SDL_GetVideoDevice()->windows; n; n = n->next) {
if (!n->parent) {
if (!n->parent && !(n->flags & SDL_WINDOW_HIDDEN)) {
++toplevel_count;
}
}
if (toplevel_count == 1) {
if (toplevel_count <= 1) {
if (SDL_GetHintBoolean(SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE, SDL_TRUE)) {
SDL_SendQuit(); /* This is the last toplevel window in the list so send the SDL_EVENT_QUIT event */
}

View file

@ -2095,6 +2095,14 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
}
}
break;
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
{
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
if (window) {
SDL_HideWindow(window);
}
break;
}
case SDL_EVENT_KEY_DOWN:
{
SDL_bool withControl = !!(event->key.mod & SDL_KMOD_CTRL);