Use SDL_EVENT_QUIT for window close (#126)

This commit is contained in:
Wouter Wijsman 2025-05-21 19:33:53 +02:00 committed by GitHub
parent af554676e4
commit 911330e61c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -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);

View File

@ -8,6 +8,7 @@
#include "mxomni.h"
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_timer.h>
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);
}