Detailed changes
@@ -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(),
}
}
@@ -51,6 +51,7 @@ fn main() {
kind: WindowKind::PopUp,
is_movable: false,
app_id: None,
+ window_min_size: Size::default(),
}
};
@@ -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<Pixels> for Pixels {
@@ -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<String>,
+
+ /// Window minimum size
+ pub window_min_size: Size<Pixels>,
}
/// The variables that can be configured when creating a new window
@@ -594,6 +597,9 @@ pub(crate) struct WindowParams {
pub display_id: Option<DisplayId>,
pub window_background: WindowBackgroundAppearance,
+
+ #[cfg_attr(target_os = "linux", allow(dead_code))]
+ pub window_min_size: Size<Pixels>,
}
/// 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(),
}
}
}
@@ -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);
@@ -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());
@@ -105,6 +105,10 @@ pub fn build_window_options(display_uuid: Option<Uuid>, 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),
+ },
}
}