From f75825eb28dc1a4d22716f9fd0f9a7f755ac1190 Mon Sep 17 00:00:00 2001 From: josh Date: Sun, 13 Jul 2025 18:11:07 -0500 Subject: [PATCH] Make WindowProc a static member, so we can hide processEvent...() methods. --- include/ReWindow/types/Window.h | 8 +++++++- src/platform/windows/Window.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/ReWindow/types/Window.h b/include/ReWindow/types/Window.h index 46ed444..0e8f3f7 100644 --- a/include/ReWindow/types/Window.h +++ b/include/ReWindow/types/Window.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace ReWindow { @@ -45,6 +46,7 @@ public: /// RWindow is a class implementation of a platform-independent window abstraction. /// This library also provides abstractions for user-input devices, and their interaction with the window. class ReWindow::RWindow { + protected: class Platform; Platform* platform; @@ -332,7 +334,11 @@ public: /// Updates internals to account for the latest calculated frame time. void UpdateFrameTiming(float frame_time); -public: + +#ifdef WIN32 + static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +#endif +protected: /// These unfortunately *have* to be public because of the poor design of the windows event loop. void processKeyRelease(Key key); void processKeyPress(Key key); diff --git a/src/platform/windows/Window.cpp b/src/platform/windows/Window.cpp index 602d926..eed0e0a 100644 --- a/src/platform/windows/Window.cpp +++ b/src/platform/windows/Window.cpp @@ -95,7 +95,7 @@ void RWindow::PollEvents() { focused = local_focused; } -LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { +LRESULT CALLBACK RWindow::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { auto* window = reinterpret_cast( GetWindowLongPtr(hwnd, GWLP_USERDATA) ); switch (uMsg) { case WM_CLOSE: { @@ -415,7 +415,7 @@ bool OpenGLWindow::Open() { platform->hInstance = GetModuleHandle(nullptr); WNDCLASS wc = { }; - wc.lpfnWndProc = WindowProc; + wc.lpfnWndProc = RWindow::WindowProc; wc.hInstance = platform->hInstance; wc.lpszClassName = "RWindowClass"; RegisterClass(&wc);