Merge pull request 'Make WindowProc a static member, so we can hide processEvent...() methods.' (#29) from protect-events into main
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m21s

Reviewed-on: #29
This commit is contained in:
2025-07-13 19:12:16 -04:00
2 changed files with 9 additions and 3 deletions

View File

@@ -9,6 +9,7 @@
#include <ReWindow/types/MouseButton.h> #include <ReWindow/types/MouseButton.h>
#include <ReWindow/types/WindowEvents.h> #include <ReWindow/types/WindowEvents.h>
#include <queue> #include <queue>
#include <Windows.h>
namespace ReWindow { namespace ReWindow {
@@ -45,6 +46,7 @@ public:
/// RWindow is a class implementation of a platform-independent window abstraction. /// 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. /// This library also provides abstractions for user-input devices, and their interaction with the window.
class ReWindow::RWindow { class ReWindow::RWindow {
protected: protected:
class Platform; class Platform;
Platform* platform; Platform* platform;
@@ -332,7 +334,11 @@ public:
/// Updates internals to account for the latest calculated frame time. /// Updates internals to account for the latest calculated frame time.
void UpdateFrameTiming(float 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. /// These unfortunately *have* to be public because of the poor design of the windows event loop.
void processKeyRelease(Key key); void processKeyRelease(Key key);
void processKeyPress(Key key); void processKeyPress(Key key);

View File

@@ -95,7 +95,7 @@ void RWindow::PollEvents() {
focused = local_focused; 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) ); auto* window = reinterpret_cast<RWindow*>( GetWindowLongPtr(hwnd, GWLP_USERDATA) );
switch (uMsg) { switch (uMsg) {
case WM_CLOSE: { case WM_CLOSE: {
@@ -415,7 +415,7 @@ bool OpenGLWindow::Open() {
platform->hInstance = GetModuleHandle(nullptr); platform->hInstance = GetModuleHandle(nullptr);
WNDCLASS wc = { }; WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc; wc.lpfnWndProc = RWindow::WindowProc;
wc.hInstance = platform->hInstance; wc.hInstance = platform->hInstance;
wc.lpszClassName = "RWindowClass"; wc.lpszClassName = "RWindowClass";
RegisterClass(&wc); RegisterClass(&wc);