Fix capslock on windows (#33093)

The new feature doesn't work well on windows

Release Notes:

- N/A
This commit is contained in:
张小白 2025-06-20 18:57:00 +08:00 committed by GitHub
parent d97a58b20e
commit f8a0eb5a8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -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,

View file

@ -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,