feat(event): handle close event

This commit is contained in:
fallenoak 2023-01-02 15:37:41 -06:00 committed by GitHub
parent d90000d0f2
commit 09d77e1ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -46,6 +46,10 @@ void EventInitialize(int32_t threadCount, int32_t netServer) {
// OsInputSetEventPollProc(&sub_47DCA0);
}
void EventInitiateShutdown() {
IEvtSchedulerShutdown();
}
int32_t EventIsControlKeyDown() {
return EventIsKeyDown(KEY_LCONTROL) || EventIsKeyDown(KEY_RCONTROL);
}

View File

@ -39,6 +39,8 @@ void EventDoMessageLoop();
void EventInitialize(int32_t threadCount, int32_t netServer);
void EventInitiateShutdown();
int32_t EventIsControlKeyDown();
int32_t EventIsKeyDown(KEY key);

View File

@ -1,4 +1,5 @@
#include "event/Input.hpp"
#include "event/Event.hpp"
#include "event/EvtContext.hpp"
#include "event/Queue.hpp"
#include "gx/Window.hpp"
@ -65,6 +66,10 @@ void PostChar(EvtContext* context, int32_t ch, int32_t repeat) {
IEvtQueueDispatch(context, EVENT_ID_CHAR, &data);
}
void PostClose() {
EventInitiateShutdown();
}
void PostKeyDown(EvtContext* context, int32_t key, int32_t repeat, int32_t time) {
if (key <= KEY_LASTMETAKEY) {
if ((1 << key) & Input::s_metaKeyState) {
@ -202,7 +207,10 @@ void ProcessInput(const int32_t param[], OSINPUT id, int32_t* shutdown, EvtConte
break;
case OS_INPUT_CLOSE:
// TODO
// TODO ConfirmClose()
PostClose();
*shutdown = 1;
break;
case OS_INPUT_FOCUS: