From 28f56ad7ae3c493d887918eb8fccc3f333fe3c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Mon, 23 Jun 2025 13:59:10 +0800 Subject: [PATCH] windows: Avoid setting the mouse cursor while the window is disabled (#33230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t set the mouse cursor when the window is disabled, it causes issues with modal dialogs. Release Notes: - N/A --- crates/gpui/src/platform/windows/events.rs | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 027c6c4dac256193b7d53481c0720aa152bef9ce..a390762ddda1e9bf9babad744bed67b89bbf7428 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -92,7 +92,7 @@ pub(crate) fn handle_msg( WM_DEADCHAR => handle_dead_char_msg(wparam, state_ptr), WM_IME_STARTCOMPOSITION => handle_ime_position(handle, state_ptr), WM_IME_COMPOSITION => handle_ime_composition(handle, lparam, state_ptr), - WM_SETCURSOR => handle_set_cursor(lparam, state_ptr), + WM_SETCURSOR => handle_set_cursor(handle, lparam, state_ptr), WM_SETTINGCHANGE => handle_system_settings_changed(handle, lparam, state_ptr), WM_INPUTLANGCHANGE => handle_input_language_changed(lparam, state_ptr), WM_GPUI_CURSOR_STYLE_CHANGED => handle_cursor_changed(lparam, state_ptr), @@ -1108,11 +1108,24 @@ fn handle_cursor_changed(lparam: LPARAM, state_ptr: Rc) - Some(0) } -fn handle_set_cursor(lparam: LPARAM, state_ptr: Rc) -> Option { - if matches!( - lparam.loword() as u32, - HTLEFT | HTRIGHT | HTTOP | HTTOPLEFT | HTTOPRIGHT | HTBOTTOM | HTBOTTOMLEFT | HTBOTTOMRIGHT - ) { +fn handle_set_cursor( + handle: HWND, + lparam: LPARAM, + state_ptr: Rc, +) -> Option { + if unsafe { !IsWindowEnabled(handle).as_bool() } + || matches!( + lparam.loword() as u32, + HTLEFT + | HTRIGHT + | HTTOP + | HTTOPLEFT + | HTTOPRIGHT + | HTBOTTOM + | HTBOTTOMLEFT + | HTBOTTOMRIGHT + ) + { return None; } unsafe {