From 9a125361d63b03ff39206aecc28627e1ce8e2e21 Mon Sep 17 00:00:00 2001 From: Reuben Dunnington Date: Mon, 14 Aug 2023 15:30:25 -0700 Subject: [PATCH] forward sys keys to default window proc to get alt+f4 handling --- src/app/win32_app.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/app/win32_app.c b/src/app/win32_app.c index dd4d962..8677a0f 100644 --- a/src/app/win32_app.c +++ b/src/app/win32_app.c @@ -287,6 +287,8 @@ LRESULT oc_win32_win_proc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM oc_window_data* mpWindow = GetPropW(windowHandle, L"MilePost"); //TODO: put messages in queue + bool handled = true; + switch(message) { case WM_CLOSE: @@ -471,6 +473,13 @@ LRESULT oc_win32_win_proc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM case WM_KEYDOWN: case WM_SYSKEYDOWN: { + // Need to pass these through to the normal event handler to handle system shortcuts like Alt+F4. + // Same for WM_SYSKEYUP + if (message == WM_SYSKEYDOWN) + { + handled = false; + } + oc_event event = {0}; event.window = oc_window_handle_from_ptr(mpWindow); event.type = OC_EVENT_KEYBOARD_KEY; @@ -483,6 +492,11 @@ LRESULT oc_win32_win_proc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM case WM_KEYUP: case WM_SYSKEYUP: { + if (message == WM_SYSKEYUP) + { + handled = false; + } + oc_event event = {0}; event.window = oc_window_handle_from_ptr(mpWindow); event.type = OC_EVENT_KEYBOARD_KEY; @@ -531,10 +545,16 @@ LRESULT oc_win32_win_proc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM default: { - result = DefWindowProc(windowHandle, message, wParam, lParam); + handled = false; } break; } + if (handled == false) + { + result = DefWindowProc(windowHandle, message, wParam, lParam); + } + + return(result); } -- 2.25.1