aboutsummaryrefslogtreecommitdiff
path: root/src/win/gui/GodWindow.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-05-15 13:56:40 +0800
committercrupest <crupest@outlook.com>2022-05-15 13:56:40 +0800
commit9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752 (patch)
tree7342f6991771fa31b16fd6a5ed892ff6025f3d05 /src/win/gui/GodWindow.cpp
parent41de54bad2c0f857821fcc83f41af3334d068b6d (diff)
downloadcru-9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752.tar.gz
cru-9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752.tar.bz2
cru-9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752.zip
...
Diffstat (limited to 'src/win/gui/GodWindow.cpp')
-rw-r--r--src/win/gui/GodWindow.cpp63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/win/gui/GodWindow.cpp b/src/win/gui/GodWindow.cpp
deleted file mode 100644
index 4416870f..00000000
--- a/src/win/gui/GodWindow.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "cru/win/gui/GodWindow.h"
-
-#include "cru/common/log/Logger.h"
-#include "cru/win/gui/Exception.h"
-#include "cru/win/gui/UiApplication.h"
-#include "cru/win/gui/WindowClass.h"
-
-namespace cru::platform::gui::win {
-constexpr auto god_window_class_name = L"GodWindowClass";
-
-LRESULT CALLBACK GodWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
- LPARAM lParam) {
- const auto app = WinUiApplication::GetInstance();
-
- if (app) {
- LRESULT result;
- auto god_window = app->GetGodWindow();
- if (god_window != nullptr) {
- const auto handled = god_window->HandleGodWindowMessage(
- hWnd, uMsg, wParam, lParam, &result);
- if (handled) return result;
- }
- }
- return DefWindowProcW(hWnd, uMsg, wParam, lParam);
-}
-
-GodWindow::GodWindow(WinUiApplication* application) {
- application_ = application;
-
- const auto h_instance = application->GetInstanceHandle();
-
- god_window_class_ = std::make_unique<WindowClass>(god_window_class_name,
- GodWndProc, h_instance);
-
- hwnd_ = CreateWindowEx(0, god_window_class_name, L"", 0, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- HWND_MESSAGE, nullptr, h_instance, nullptr);
-
- if (hwnd_ == nullptr)
- throw Win32Error(::GetLastError(), u"Failed to create god window.");
-}
-
-GodWindow::~GodWindow() {
- if (!::DestroyWindow(hwnd_)) {
- // Although this could be "safely" ignore.
- CRU_LOG_WARN(u"Failed to destroy god window.");
- }
-}
-
-bool GodWindow::HandleGodWindowMessage(HWND hwnd, UINT msg, WPARAM w_param,
- LPARAM l_param, LRESULT* result) {
- WindowNativeMessageEventArgs args(
- WindowNativeMessage{hwnd, msg, w_param, l_param});
- message_event_.Raise(args);
-
- if (args.IsHandled()) {
- *result = args.GetResult();
- return true;
- }
-
- return false;
-}
-} // namespace cru::platform::gui::win