From 911330e61c70eb8bf35976584d744c96549ec126 Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Wed, 21 May 2025 19:33:53 +0200 Subject: [PATCH] Use SDL_EVENT_QUIT for window close (#126) --- ISLE/isleapp.cpp | 6 +++--- LEGO1/lego/legoomni/include/legomain.h | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 6d3fd428..cd5201d2 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -425,6 +425,9 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) ); } break; + case SDL_EVENT_QUIT: + return SDL_APP_SUCCESS; + break; } if (event->user.type == g_legoSdlEvents.m_windowsMessage) { @@ -432,9 +435,6 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) case WM_ISLE_SETCURSOR: g_isle->SetupCursor((Cursor) (uintptr_t) event->user.data1); break; - case WM_QUIT: - return SDL_APP_SUCCESS; - break; case WM_TIMER: if (InputManager()) { InputManager()->QueueEvent(c_notificationTimer, (MxU8) (uintptr_t) event->user.data1, 0, 0, 0); diff --git a/LEGO1/lego/legoomni/include/legomain.h b/LEGO1/lego/legoomni/include/legomain.h index 6ba6266e..adb640b2 100644 --- a/LEGO1/lego/legoomni/include/legomain.h +++ b/LEGO1/lego/legoomni/include/legomain.h @@ -8,6 +8,7 @@ #include "mxomni.h" #include +#include class Isle; class LegoAnimationManager; @@ -192,11 +193,13 @@ class LegoOmni : public MxOmni { void CloseMainWindow() { + SDL_QuitEvent quit; + quit.type = SDL_EVENT_QUIT; + quit.timestamp = SDL_GetTicksNS(); + SDL_Event event; - event.user.type = g_legoSdlEvents.m_windowsMessage; - event.user.code = WM_QUIT; - event.user.data1 = NULL; - event.user.data2 = NULL; + event.quit = quit; + SDL_PushEvent(&event); }