Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

windows: Add back `hide_title_bar` checks (#32427)

张小白4c3ada57538a
diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs
index 158b7b72696..2f6d8a8aadd 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 _)
}