Make WindowProc a static member, so we can hide processEvent...() methods.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m41s

This commit is contained in:
2025-07-13 18:11:07 -05:00
parent 99a5978448
commit f75825eb28
2 changed files with 9 additions and 3 deletions

View File

@@ -9,6 +9,7 @@
#include <ReWindow/types/MouseButton.h>
#include <ReWindow/types/WindowEvents.h>
#include <queue>
#include <Windows.h>
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);

View File

@@ -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<RWindow*>( 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);