forward sys keys to default window proc to get alt+f4 handling

This commit is contained in:
Reuben Dunnington 2023-08-14 15:30:25 -07:00 committed by Martin Fouilleul
parent 78e09b3373
commit 9a125361d6
1 changed files with 21 additions and 1 deletions

View File

@ -287,6 +287,8 @@ LRESULT oc_win32_win_proc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM
oc_window_data* mpWindow = GetPropW(windowHandle, L"MilePost"); oc_window_data* mpWindow = GetPropW(windowHandle, L"MilePost");
//TODO: put messages in queue //TODO: put messages in queue
bool handled = true;
switch(message) switch(message)
{ {
case WM_CLOSE: case WM_CLOSE:
@ -471,6 +473,13 @@ LRESULT oc_win32_win_proc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_SYSKEYDOWN: 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}; oc_event event = {0};
event.window = oc_window_handle_from_ptr(mpWindow); event.window = oc_window_handle_from_ptr(mpWindow);
event.type = OC_EVENT_KEYBOARD_KEY; 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_KEYUP:
case WM_SYSKEYUP: case WM_SYSKEYUP:
{ {
if (message == WM_SYSKEYUP)
{
handled = false;
}
oc_event event = {0}; oc_event event = {0};
event.window = oc_window_handle_from_ptr(mpWindow); event.window = oc_window_handle_from_ptr(mpWindow);
event.type = OC_EVENT_KEYBOARD_KEY; event.type = OC_EVENT_KEYBOARD_KEY;
@ -531,10 +545,16 @@ LRESULT oc_win32_win_proc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM
default: default:
{ {
result = DefWindowProc(windowHandle, message, wParam, lParam); handled = false;
} break; } break;
} }
if (handled == false)
{
result = DefWindowProc(windowHandle, message, wParam, lParam);
}
return(result); return(result);
} }