From 4c3ada57538a3e358d19130e99db51187e61bd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Wed, 11 Jun 2025 17:46:16 +0800 Subject: [PATCH] windows: Add back `hide_title_bar` checks (#32427) These `if` condition checks were removed in #30828, and this PR adds them back. This is especially important in the handling of `WM_NCHITTEST`, where all the calculations are based on the assumption that `hide_title_bar = true`. Release Notes: - N/A --- crates/gpui/src/platform/windows/events.rs | 45 +++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 158b7b72696435350bec3d5d316669017b508fd3..2f6d8a8aadd67c582dcf7477471cd63002cfb8cb 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -888,6 +888,32 @@ fn handle_hit_test_msg( return None; } + let mut lock = state_ptr.state.borrow_mut(); + if let Some(mut callback) = lock.callbacks.hit_test_window_control.take() { + drop(lock); + let area = callback(); + state_ptr + .state + .borrow_mut() + .callbacks + .hit_test_window_control = Some(callback); + if let Some(area) = area { + return match area { + WindowControlArea::Drag => Some(HTCAPTION as _), + WindowControlArea::Close => Some(HTCLOSE as _), + WindowControlArea::Max => Some(HTMAXBUTTON as _), + WindowControlArea::Min => Some(HTMINBUTTON as _), + }; + } + } else { + drop(lock); + } + + if !state_ptr.hide_title_bar { + // If the OS draws the title bar, we don't need to handle hit test messages. + return None; + } + // default handler for resize areas let hit = unsafe { DefWindowProcW(handle, msg, wparam, lparam) }; if matches!( @@ -922,25 +948,6 @@ fn handle_hit_test_msg( return Some(HTTOP as _); } - let mut lock = state_ptr.state.borrow_mut(); - if let Some(mut callback) = lock.callbacks.hit_test_window_control.take() { - drop(lock); - let area = callback(); - state_ptr - .state - .borrow_mut() - .callbacks - .hit_test_window_control = Some(callback); - if let Some(area) = area { - return match area { - WindowControlArea::Drag => Some(HTCAPTION as _), - WindowControlArea::Close => Some(HTCLOSE as _), - WindowControlArea::Max => Some(HTMAXBUTTON as _), - WindowControlArea::Min => Some(HTMINBUTTON as _), - }; - } - } - Some(HTCLIENT as _) }