summaryrefslogtreecommitdiffstats
path: root/tools/gfx/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gfx/window.cpp')
-rw-r--r--tools/gfx/window.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/gfx/window.cpp b/tools/gfx/window.cpp
index ee9f50813..9bc63b896 100644
--- a/tools/gfx/window.cpp
+++ b/tools/gfx/window.cpp
@@ -111,22 +111,53 @@ int runWindowsApplication(
struct Window
{
HWND handle;
+ WNDPROC nativeHook;
};
+void setNativeWindowHook(Window* window, WNDPROC proc)
+{
+ window->nativeHook = proc;
+}
+
static LRESULT CALLBACK windowProc(
HWND windowHandle,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
+ Window* window = (Window*) GetWindowLongPtrW(windowHandle, GWLP_USERDATA);
+
+ // Give the installed filter a chance to intercept messages.
+ // (This is used for ImGui)
+ if( window )
+ {
+ if(auto nativeHook = window->nativeHook)
+ {
+ auto result = nativeHook(windowHandle, message, wParam, lParam);
+ if(result)
+ return result;
+ }
+ }
+
// TODO: Actually implement some reasonable logic here.
switch (message)
{
+ case WM_CREATE:
+ {
+ auto createInfo = (CREATESTRUCTW*) lParam;
+ window = (Window*) createInfo->lpCreateParams;
+ window->handle = windowHandle;
+
+ SetWindowLongPtrW(windowHandle, GWLP_USERDATA, (LONG)window);
+ }
+ break;
+
case WM_CLOSE:
PostQuitMessage(0);
return 0;
}
+
return DefWindowProcW(windowHandle, message, wParam, lParam);
}
@@ -159,6 +190,8 @@ static ATOM getWindowClassAtom()
Window* createWindow(WindowDesc const& desc)
{
Window* window = new Window();
+ window->handle = nullptr;
+ window->nativeHook = nullptr;
OSString windowTitle(desc.title);