From e0751c467bf5483007486074434b6f931682b177 Mon Sep 17 00:00:00 2001 From: Junkui Zhang <364772080@qq.com> Date: Mon, 4 Aug 2025 16:51:15 +0800 Subject: [PATCH] init --- crates/gpui/src/platform/windows/events.rs | 10 ++++++++-- crates/gpui/src/platform/windows/window.rs | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 61f410a8c6..2b66388368 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -380,6 +380,7 @@ fn handle_keydown_msg( state_ptr: Rc, ) -> Option { let mut lock = state_ptr.state.borrow_mut(); + lock.keydown_time = Some(std::time::Instant::now()); let Some(input) = handle_key_event(handle, wparam, lparam, &mut lock, |keystroke| { PlatformInput::KeyDown(KeyDownEvent { keystroke, @@ -1237,10 +1238,15 @@ fn draw_window( .request_frame .take()?; request_frame(RequestFrameOptions { - require_presentation: false, + require_presentation: true, force_render, }); - state_ptr.state.borrow_mut().callbacks.request_frame = Some(request_frame); + let mut lock = state_ptr.state.borrow_mut(); + if let Some(keydown_time) = lock.keydown_time.take() { + let elapsed = keydown_time.elapsed(); + println!("Elapsed keydown time: {:.02} ms", elapsed.as_secs_f64() * 1000.0); + } + lock.callbacks.request_frame = Some(request_frame); unsafe { ValidateRect(Some(handle), None).ok().log_err() }; Some(0) } diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 68b667569b..346eeab1dd 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -49,6 +49,7 @@ pub struct WindowsWindowState { pub hovered: bool, pub renderer: DirectXRenderer, + pub keydown_time: Option, pub click_state: ClickState, pub system_settings: WindowsSystemSettings, @@ -115,6 +116,7 @@ impl WindowsWindowState { let nc_button_pressed = None; let fullscreen = None; let initial_placement = None; + let keydown_time = None; Ok(Self { origin, @@ -133,6 +135,7 @@ impl WindowsWindowState { system_key_handled, hovered, renderer, + keydown_time, click_state, system_settings, current_cursor,