diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index c3ddfdbfbd..3923242409 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -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) -> Option { + 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 { let modifiers = current_modifiers(); if !modifiers.alt { diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 01a71f70e0..7857f71766 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -40,6 +40,7 @@ pub struct WindowsWindowState { pub callbacks: Callbacks, pub input_handler: Option, + 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,