diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index 774bf139ef..6cf86bbc1a 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -124,5 +124,6 @@ fn notification_window_options( display_id: Some(screen.id()), window_background: WindowBackgroundAppearance::default(), app_id: Some(app_id.to_owned()), + window_min_size: Size::default(), } } diff --git a/crates/gpui/examples/window_positioning.rs b/crates/gpui/examples/window_positioning.rs index 9632ccb467..406ee40f84 100644 --- a/crates/gpui/examples/window_positioning.rs +++ b/crates/gpui/examples/window_positioning.rs @@ -51,6 +51,7 @@ fn main() { kind: WindowKind::PopUp, is_movable: false, app_id: None, + window_min_size: Size::default(), } }; diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs index feceae2e6c..e6cde4fce2 100644 --- a/crates/gpui/src/geometry.rs +++ b/crates/gpui/src/geometry.rs @@ -2287,6 +2287,15 @@ impl Pixels { pub fn abs(&self) -> Self { Self(self.0.abs()) } + + /// Returns the f64 value of `Pixels`. + /// + /// # Returns + /// + /// A f64 value of the `Pixels`. + pub fn to_f64(self) -> f64 { + self.0 as f64 + } } impl Mul for Pixels { diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index b9af658963..60a82bf1f9 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -567,6 +567,9 @@ pub struct WindowOptions { /// Application identifier of the window. Can by used by desktop environments to group applications together. pub app_id: Option, + + /// Window minimum size + pub window_min_size: Size, } /// The variables that can be configured when creating a new window @@ -594,6 +597,9 @@ pub(crate) struct WindowParams { pub display_id: Option, pub window_background: WindowBackgroundAppearance, + + #[cfg_attr(target_os = "linux", allow(dead_code))] + pub window_min_size: Size, } /// Represents the status of how a window should be opened. @@ -642,6 +648,7 @@ impl Default for WindowOptions { display_id: None, window_background: WindowBackgroundAppearance::default(), app_id: None, + window_min_size: Size::default(), } } } diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index c1b0550cda..33ea9656e0 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -505,6 +505,7 @@ impl MacWindow { focus, show, display_id, + window_min_size, }: WindowParams, executor: ForegroundExecutor, renderer_context: renderer::Context, @@ -646,6 +647,11 @@ impl MacWindow { native_window.setMovable_(is_movable as BOOL); + native_window.setContentMinSize_(NSSize { + width: window_min_size.width.to_f64(), + height: window_min_size.height.to_f64(), + }); + if titlebar.map_or(true, |titlebar| titlebar.appears_transparent) { native_window.setTitlebarAppearsTransparent_(YES); native_window.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden); diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 0c7a980669..b1031e084d 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -631,6 +631,7 @@ impl Window { display_id, window_background, app_id, + window_min_size, } = options; let bounds = window_bounds @@ -647,6 +648,7 @@ impl Window { show, display_id, window_background, + window_min_size, }, )?; let display_id = platform_window.display().map(|display| display.id()); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index bf48d30be1..d02b30f6b9 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -105,6 +105,10 @@ pub fn build_window_options(display_uuid: Option, cx: &mut AppContext) -> display_id: display.map(|display| display.id()), window_background: cx.theme().window_background_appearance(), app_id: Some(app_id.to_owned()), + window_min_size: gpui::Size { + width: px(360.0), + height: px(240.0), + }, } }