diff options
author | crupest <crupest@outlook.com> | 2020-10-17 15:57:53 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-17 15:57:53 +0800 |
commit | 46ff47d2f47a66372ca0a8a09dd08c4fb04004f3 (patch) | |
tree | 0a1168ea234cb545f76b6d9a8031c36c0f224f5c /src/win/native/GodWindow.cpp | |
parent | 937b16dff40b6eba68d6bc13162f838c8432f43b (diff) | |
download | cru-46ff47d2f47a66372ca0a8a09dd08c4fb04004f3.tar.gz cru-46ff47d2f47a66372ca0a8a09dd08c4fb04004f3.tar.bz2 cru-46ff47d2f47a66372ca0a8a09dd08c4fb04004f3.zip |
Refactor timer.
Diffstat (limited to 'src/win/native/GodWindow.cpp')
-rw-r--r-- | src/win/native/GodWindow.cpp | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/src/win/native/GodWindow.cpp b/src/win/native/GodWindow.cpp index b1e7275e..203542f7 100644 --- a/src/win/native/GodWindow.cpp +++ b/src/win/native/GodWindow.cpp @@ -1,7 +1,5 @@ #include "cru/win/native/GodWindow.hpp" -#include "GodWindowMessage.hpp" -#include "Timer.hpp" #include "cru/common/Logger.hpp" #include "cru/win/native/Exception.hpp" #include "cru/win/native/UiApplication.hpp" @@ -51,32 +49,15 @@ GodWindow::~GodWindow() { bool GodWindow::HandleGodWindowMessage(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param, LRESULT* result) { - CRU_UNUSED(hwnd) - CRU_UNUSED(l_param) + WindowNativeMessageEventArgs args( + WindowNativeMessage{hwnd, msg, w_param, l_param}); + message_event_.Raise(args); - switch (msg) { - case invoke_later_message_id: { - const auto p_action = reinterpret_cast<std::function<void()>*>(w_param); - (*p_action)(); - delete p_action; - *result = 0; - return true; - } - case WM_TIMER: { - const auto id = static_cast<UINT_PTR>(w_param); - const auto action = application_->GetTimerManager()->GetAction(id); - if (action.has_value()) { - (action.value().second)(); - if (!action.value().first) - application_->GetTimerManager()->KillTimer(id); - result = 0; - return true; - } - break; - } - default: - return false; + if (args.IsHandled()) { + *result = args.GetResult(); + return true; } + return false; } } // namespace cru::platform::native::win |