Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix disabled Windows window controls (#60440)
迷渡7194f987a743
diff --git a/crates/gpui_windows/src/events.rs b/crates/gpui_windows/src/events.rsindex 619765a2fd6..b293763bd9e 100644--- a/crates/gpui_windows/src/events.rs+++ b/crates/gpui_windows/src/events.rs@@ -903,8 +903,12 @@ impl WindowsWindowInner {WindowControlArea::Drag if self.is_movable => Some(HTCAPTION as _),WindowControlArea::Drag => None,WindowControlArea::Close => Some(HTCLOSE as _),- WindowControlArea::Max => Some(HTMAXBUTTON as _),- WindowControlArea::Min => Some(HTMINBUTTON as _),+ WindowControlArea::Max if self.is_resizable => Some(HTMAXBUTTON as _),+ WindowControlArea::Max if self.is_movable => Some(HTCAPTION as _),+ WindowControlArea::Max => Some(HTNOWHERE as _),+ WindowControlArea::Min if self.is_minimizable => Some(HTMINBUTTON as _),+ WindowControlArea::Min if self.is_movable => Some(HTCAPTION as _),+ WindowControlArea::Min => Some(HTNOWHERE as _),})} else {None@@ -926,7 +930,11 @@ impl WindowsWindowInner {};unsafe { ScreenToClient(handle, &mut cursor_point).ok().log_err() };- if !self.state.is_maximized() && 0 <= cursor_point.y && cursor_point.y <= frame_y {+ if self.is_resizable+ && !self.state.is_maximized()+ && 0 <= cursor_point.y+ && cursor_point.y <= frame_y+ {// x-axis actually goes from -frame_x to 0return Some(if cursor_point.x <= 0 {HTTOPLEFT@@ -1052,11 +1060,12 @@ impl WindowsWindowInner {&& let Some(last_pressed) = last_pressed{let handled = match (wparam.0 as u32, last_pressed) {- (HTMINBUTTON, HTMINBUTTON) => {+ (HTMINBUTTON, HTMINBUTTON) if self.is_minimizable => {unsafe { ShowWindowAsync(handle, SW_MINIMIZE).ok().log_err() };true}- (HTMAXBUTTON, HTMAXBUTTON) => {+ (HTMINBUTTON, HTMINBUTTON) => true,+ (HTMAXBUTTON, HTMAXBUTTON) if self.is_resizable => {if self.state.is_maximized() {unsafe { ShowWindowAsync(handle, SW_NORMAL).ok().log_err() };} else {@@ -1064,6 +1073,7 @@ impl WindowsWindowInner {}true}+ (HTMAXBUTTON, HTMAXBUTTON) => true,(HTCLOSE, HTCLOSE) => {unsafe {PostMessageW(Some(handle), WM_CLOSE, WPARAM::default(), LPARAM::default())diff --git a/crates/gpui_windows/src/window.rs b/crates/gpui_windows/src/window.rsindex c9352a60035..547ee7a9dde 100644--- a/crates/gpui_windows/src/window.rs+++ b/crates/gpui_windows/src/window.rs@@ -94,6 +94,8 @@ pub(crate) struct WindowsWindowInner {pub(crate) handle: AnyWindowHandle,pub(crate) hide_title_bar: bool,pub(crate) is_movable: bool,+ pub(crate) is_resizable: bool,+ pub(crate) is_minimizable: bool,pub(crate) executor: ForegroundExecutor,pub(crate) validation_number: usize,pub(crate) main_receiver: PriorityQueueReceiver<RunnableVariant>,@@ -262,6 +264,8 @@ impl WindowsWindowInner {handle: context.handle,hide_title_bar: context.hide_title_bar,is_movable: context.is_movable,+ is_resizable: context.is_resizable,+ is_minimizable: context.is_minimizable,executor: context.executor.clone(),validation_number: context.validation_number,main_receiver: context.main_receiver.clone(),@@ -384,6 +388,8 @@ struct WindowCreateContext {hide_title_bar: bool,display: WindowsDisplay,is_movable: bool,+ is_resizable: bool,+ is_minimizable: bool,min_size: Option<Size<Pixels>>,executor: ForegroundExecutor,current_cursor: Option<HCURSOR>,@@ -487,6 +493,8 @@ impl WindowsWindow {hide_title_bar,display,is_movable: params.is_movable,+ is_resizable: params.is_resizable,+ is_minimizable: params.is_minimizable,min_size: params.window_min_size,executor,current_cursor,