From 4e1c46fe9e79cc42b70a7087acc36addac6d27e1 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 1 Feb 2023 08:03:58 -0300 Subject: [PATCH] Windows: Fix Alt key press entering menu loop (#2665) --- src/platform_impl/windows/event_loop.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index dbce31e8..9f4e8f16 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -50,10 +50,10 @@ use windows_sys::Win32::{ }, WindowsAndMessaging::{ CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetCursorPos, - GetMessageW, LoadCursorW, MsgWaitForMultipleObjectsEx, PeekMessageW, PostMessageW, - PostThreadMessageW, RegisterClassExW, RegisterWindowMessageA, SetCursor, SetWindowPos, - TranslateMessage, CREATESTRUCTW, GIDC_ARRIVAL, GIDC_REMOVAL, GWL_STYLE, GWL_USERDATA, - HTCAPTION, HTCLIENT, MINMAXINFO, MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE, + GetMenu, GetMessageW, LoadCursorW, MsgWaitForMultipleObjectsEx, PeekMessageW, + PostMessageW, PostThreadMessageW, RegisterClassExW, RegisterWindowMessageA, SetCursor, + SetWindowPos, TranslateMessage, CREATESTRUCTW, GIDC_ARRIVAL, GIDC_REMOVAL, GWL_STYLE, + GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO, MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE, NCCALCSIZE_PARAMS, PM_NOREMOVE, PM_QS_PAINT, PM_REMOVE, PT_PEN, PT_TOUCH, QS_ALLEVENTS, RI_KEY_E0, RI_KEY_E1, RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS, @@ -1550,7 +1550,9 @@ unsafe fn public_window_callback_inner( }, }); } - if msg == WM_SYSKEYUP { + if msg == WM_SYSKEYUP && GetMenu(window) != 0 { + // let Windows handle event if the window has a native menu, a modal event loop + // is started here on Alt key up. DefWindowProcW(window, msg, wparam, lparam) } else { 0