Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix capslock on windows (#33093)

张小白f8a0eb5a8c76
diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs
index 67859a980b4..fbc0857463b 100644
--- a/crates/gpui/src/platform/windows/events.rs
+++ b/crates/gpui/src/platform/windows/events.rs
@@ -1227,7 +1227,6 @@ where
{
let virtual_key = VIRTUAL_KEY(wparam.loword());
let mut modifiers = current_modifiers();
- let capslock = current_capslock();
match virtual_key {
VK_SHIFT | VK_CONTROL | VK_MENU | VK_LWIN | VK_RWIN => {
@@ -1238,6 +1237,20 @@ where
return None;
}
state.last_reported_modifiers = Some(modifiers);
+ Some(PlatformInput::ModifiersChanged(ModifiersChangedEvent {
+ modifiers,
+ capslock: current_capslock(),
+ }))
+ }
+ VK_CAPITAL => {
+ let capslock = current_capslock();
+ if state
+ .last_reported_capslock
+ .is_some_and(|prev_capslock| prev_capslock == capslock)
+ {
+ return None;
+ }
+ state.last_reported_capslock = Some(capslock);
Some(PlatformInput::ModifiersChanged(ModifiersChangedEvent {
modifiers,
capslock,
diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs
index b682b88e72d..b969a284b5d 100644
--- a/crates/gpui/src/platform/windows/window.rs
+++ b/crates/gpui/src/platform/windows/window.rs
@@ -43,6 +43,7 @@ pub struct WindowsWindowState {
pub callbacks: Callbacks,
pub input_handler: Option<PlatformInputHandler>,
pub last_reported_modifiers: Option<Modifiers>,
+ pub last_reported_capslock: Option<Capslock>,
pub system_key_handled: bool,
pub hovered: bool,
@@ -102,6 +103,7 @@ impl WindowsWindowState {
let callbacks = Callbacks::default();
let input_handler = None;
let last_reported_modifiers = None;
+ let last_reported_capslock = None;
let system_key_handled = false;
let hovered = false;
let click_state = ClickState::new();
@@ -121,6 +123,7 @@ impl WindowsWindowState {
callbacks,
input_handler,
last_reported_modifiers,
+ last_reported_capslock,
system_key_handled,
hovered,
renderer,