From 520b542fccafad046beb71a42560e4906e763149 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 10 Oct 2020 11:30:10 +0900 Subject: [PATCH] Introduce NACT::on_syswmevent() This is in preparation for adding more handlers for platform-specific window messages (e.g. menu commands). --- src/android/nact_android.cpp | 4 ++++ src/emscripten/nact_emscripten.cpp | 4 ++++ src/linux/nact_linux.cpp | 4 ++++ src/sys/nact.h | 4 ++++ src/sys/nact_input.cpp | 12 ++++-------- src/win/mako.cpp | 1 - src/win/nact_win.cpp | 12 ++++++++++++ 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/android/nact_android.cpp b/src/android/nact_android.cpp index b58006a..1672a74 100644 --- a/src/android/nact_android.cpp +++ b/src/android/nact_android.cpp @@ -46,3 +46,7 @@ void NACT::output_console(const char *format, ...) va_end(ap); #endif } + +void NACT::on_syswmevent(SDL_SysWMmsg* msg) +{ +} diff --git a/src/emscripten/nact_emscripten.cpp b/src/emscripten/nact_emscripten.cpp index 83438a8..74c337f 100644 --- a/src/emscripten/nact_emscripten.cpp +++ b/src/emscripten/nact_emscripten.cpp @@ -41,3 +41,7 @@ void NACT::output_console(const char *format, ...) va_end(ap); #endif } + +void NACT::on_syswmevent(SDL_SysWMmsg* msg) +{ +} diff --git a/src/linux/nact_linux.cpp b/src/linux/nact_linux.cpp index a3c9904..d9db398 100644 --- a/src/linux/nact_linux.cpp +++ b/src/linux/nact_linux.cpp @@ -23,3 +23,7 @@ void NACT::output_console(const char *format, ...) va_end(ap); #endif } + +void NACT::on_syswmevent(SDL_SysWMmsg* msg) +{ +} diff --git a/src/sys/nact.h b/src/sys/nact.h index d7b47e7..0b9792f 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -262,6 +262,10 @@ public: int get_scenario_page() const { return scenario_page; } void fatal(const char* msg, ...); + +private: + bool pump_events(); + void on_syswmevent(SDL_SysWMmsg* msg); }; class NACT_Sys1 final : public NACT { diff --git a/src/sys/nact_input.cpp b/src/sys/nact_input.cpp index 8da5854..2ed9cf5 100644 --- a/src/sys/nact_input.cpp +++ b/src/sys/nact_input.cpp @@ -11,12 +11,11 @@ #include #include "nact.h" #include "ags.h" -#include "mako.h" #include "texthook.h" static int mousex, mousey, fingers; -static bool pump_events(AGS* ags, MAKO* mako) +bool NACT::pump_events() { SDL_Event e; while (SDL_PollEvent(&e)) { @@ -41,12 +40,9 @@ static bool pump_events(AGS* ags, MAKO* mako) ags->flush_screen(false); break; -#ifdef _WIN32 case SDL_SYSWMEVENT: - if (e.syswm.msg->msg.win.msg == MM_MCINOTIFY) - mako->on_mci_notify(e.syswm.msg); + on_syswmevent(e.syswm.msg); break; -#endif } } return false; @@ -58,7 +54,7 @@ uint8 NACT::get_key() texthook_keywait(); - if (pump_events(ags, mako)) + if (pump_events()) terminate = true; // キーボード&マウス @@ -103,7 +99,7 @@ uint8 NACT::get_key() void NACT::get_cursor(int* x, int* y) { - if (pump_events(ags, mako)) + if (pump_events()) terminate = true; *x = mousex; *y = mousey; diff --git a/src/win/mako.cpp b/src/win/mako.cpp index 88e6be7..7e0004a 100644 --- a/src/win/mako.cpp +++ b/src/win/mako.cpp @@ -170,7 +170,6 @@ MAKO::MAKO(NACT* parent, const char* playlist) : WARNING("SDL_GetWindowWMInfo failed: %s", SDL_GetError()); } else { Music::hwnd_notify = info.info.win.window; - SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); } } diff --git a/src/win/nact_win.cpp b/src/win/nact_win.cpp index 20762a9..553ad2c 100644 --- a/src/win/nact_win.cpp +++ b/src/win/nact_win.cpp @@ -2,6 +2,7 @@ #include #include #include "SDL_syswm.h" +#include "mako.h" #include "../res3/resource.h" extern SDL_Window* g_window; @@ -83,6 +84,8 @@ void NACT::platform_initialize() title[6] = '0' + sys_ver; SetConsoleTitle(title); #endif + + SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); } void NACT::platform_finalize() @@ -102,3 +105,12 @@ void NACT::output_console(const char *format, ...) va_end(ap); #endif } + +void NACT::on_syswmevent(SDL_SysWMmsg* msg) +{ + switch (msg->msg.win.msg) { + case MM_MCINOTIFY: + mako->on_mci_notify(msg); + break; + } +}