From 07d09128e6f70dba8146341cfb33095d27586b20 Mon Sep 17 00:00:00 2001 From: Dipshet <264011288+Dipshet@users.noreply.github.com> Date: Fri, 7 Aug 2026 23:29:53 +0200 Subject: [PATCH] Silence the Alt+key system beep (unhandled WM_SYSCHAR) While Alt is held every keypress arrives as WM_SYSKEYDOWN->WM_SYSCHAR, and an unhandled WM_SYSCHAR reaching DefWindowProc on a menu-less window triggers MessageBeep which causes camera panning on KB+M dinged constantly. Consume it (and answer WM_MENUCHAR with MNC_CLOSE) when the window has no menu. --- .../rexglue-sdk/src/native/ui/window_win.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/thirdparty/rexglue-sdk/src/native/ui/window_win.cpp b/thirdparty/rexglue-sdk/src/native/ui/window_win.cpp index 14531469..0af039f8 100644 --- a/thirdparty/rexglue-sdk/src/native/ui/window_win.cpp +++ b/thirdparty/rexglue-sdk/src/native/ui/window_win.cpp @@ -970,6 +970,22 @@ bool Win32Window::HandleKeyboard(UINT message, WPARAM wParam, LPARAM lParam, case WM_CHAR: OnKeyChar(e, destruction_receiver); break; + case WM_SYSCHAR: + // An unhandled WM_SYSCHAR reaching DefWindowProc on a window with no + // menu triggers the system "ding" (MessageBeep) for every Alt+key + // press. A menu-less window has no mnemonics to dispatch, so consume + // it. This also swallows Alt+Space's keyboard route to the system + // menu - standard for borderless games. Alt+F4 lives in + // WM_SYSKEYDOWN handling, which still reaches DefWindowProc. + if (!GetMenu(hwnd_)) { + static bool s_syschar_logged = false; + if (!s_syschar_logged) { + s_syschar_logged = true; + REXLOG_INFO("Win32Window: consuming WM_SYSCHAR (Alt+key) - system beep suppressed"); + } + e.set_handled(true); + } + break; default: break; } @@ -1230,6 +1246,15 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar return 0; } break; + case WM_MENUCHAR: { + // Belt to the WM_SYSCHAR braces above: if a system-char ever reaches + // menu processing on a menu-less window, answer "close the menu, no + // beep" instead of the default MNC_IGNORE ding. + if (!GetMenu(hwnd_)) { + return MAKELRESULT(0, MNC_CLOSE); + } + } break; + case WM_TABLET_QUERYSYSTEMGESTURESTATUS: return // disables press and hold (right-click) gesture