mirror of
https://github.com/sal063/AC6_recomp
synced 2026-08-21 23:00:53 -04:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user