windows: Stop beeping (#14872)

Close #14857 

Release Notes:

- N/A
This commit is contained in:
张小白 2024-07-26 01:26:36 +08:00 committed by GitHub
parent 06863144c6
commit a60b3b9389
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -76,6 +76,7 @@ pub(crate) fn handle_msg(
WM_MOUSEHWHEEL => handle_mouse_horizontal_wheel_msg(handle, wparam, lparam, state_ptr),
WM_SYSKEYDOWN => handle_syskeydown_msg(wparam, lparam, state_ptr),
WM_SYSKEYUP => handle_syskeyup_msg(wparam, state_ptr),
WM_SYSCOMMAND => handle_system_command(wparam, state_ptr),
WM_KEYDOWN => handle_keydown_msg(wparam, lparam, state_ptr),
WM_KEYUP => handle_keyup_msg(wparam, state_ptr),
WM_CHAR => handle_char_msg(wparam, lparam, state_ptr),
@ -273,7 +274,8 @@ fn handle_syskeydown_msg(
keystroke,
is_held: lparam.0 & (0x1 << 30) > 0,
};
let result = if func(PlatformInput::KeyDown(event)).default_prevented {
let result = if !func(PlatformInput::KeyDown(event)).propagate {
state_ptr.state.borrow_mut().system_key_handled = true;
Some(0)
} else {
None
@ -1067,6 +1069,17 @@ fn handle_system_settings_changed(
Some(0)
}
fn handle_system_command(wparam: WPARAM, state_ptr: Rc<WindowsWindowStatePtr>) -> Option<isize> {
if wparam.0 == SC_KEYMENU as usize {
let mut lock = state_ptr.state.borrow_mut();
if lock.system_key_handled {
lock.system_key_handled = false;
return Some(0);
}
}
None
}
fn parse_syskeydown_msg_keystroke(wparam: WPARAM) -> Option<Keystroke> {
let modifiers = current_modifiers();
if !modifiers.alt {

View file

@ -40,6 +40,7 @@ pub struct WindowsWindowState {
pub callbacks: Callbacks,
pub input_handler: Option<PlatformInputHandler>,
pub system_key_handled: bool,
pub renderer: BladeRenderer,
@ -87,6 +88,7 @@ impl WindowsWindowState {
let renderer = windows_renderer::windows_renderer(hwnd, transparent)?;
let callbacks = Callbacks::default();
let input_handler = None;
let system_key_handled = false;
let click_state = ClickState::new();
let system_settings = WindowsSystemSettings::new();
let nc_button_pressed = None;
@ -100,6 +102,7 @@ impl WindowsWindowState {
scale_factor,
callbacks,
input_handler,
system_key_handled,
renderer,
click_state,
system_settings,