windows: Fix ctrl-click open hovered URL (#30574)

Closes #30452

Release Notes:

- N/A
This commit is contained in:
张小白 2025-05-12 22:15:50 +08:00 committed by GitHub
parent 19b6c4444e
commit 33c896c23d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View file

@ -385,10 +385,6 @@ fn handle_keydown_msg(
return Some(1);
};
let mut lock = state_ptr.state.borrow_mut();
let Some(mut func) = lock.callbacks.input.take() else {
return Some(1);
};
drop(lock);
let event = match keystroke_or_modifier {
KeystrokeOrModifier::Keystroke(keystroke) => PlatformInput::KeyDown(KeyDownEvent {
@ -396,9 +392,19 @@ fn handle_keydown_msg(
is_held: lparam.0 & (0x1 << 30) > 0,
}),
KeystrokeOrModifier::Modifier(modifiers) => {
if let Some(prev_modifiers) = lock.last_reported_modifiers {
if prev_modifiers == modifiers {
return Some(0);
}
}
lock.last_reported_modifiers = Some(modifiers);
PlatformInput::ModifiersChanged(ModifiersChangedEvent { modifiers })
}
};
let Some(mut func) = lock.callbacks.input.take() else {
return Some(1);
};
drop(lock);
let result = if func(event).default_prevented {
Some(0)

View file

@ -42,6 +42,7 @@ pub struct WindowsWindowState {
pub callbacks: Callbacks,
pub input_handler: Option<PlatformInputHandler>,
pub last_reported_modifiers: Option<Modifiers>,
pub system_key_handled: bool,
pub hovered: bool,
@ -100,6 +101,7 @@ impl WindowsWindowState {
let renderer = windows_renderer::init(gpu_context, hwnd, transparent)?;
let callbacks = Callbacks::default();
let input_handler = None;
let last_reported_modifiers = None;
let system_key_handled = false;
let hovered = false;
let click_state = ClickState::new();
@ -118,6 +120,7 @@ impl WindowsWindowState {
min_size,
callbacks,
input_handler,
last_reported_modifiers,
system_key_handled,
hovered,
renderer,