Add limit to minimum window size (#13126)
Release Notes: - Add a limit to the minimum window size on macOS. Here's the minimum window before change: <img width="121" alt="image" src="https://github.com/zed-industries/zed/assets/38318044/9e907194-42e5-457e-91ea-96613426b479"> After change: <img width="410" alt="image" src="https://github.com/zed-industries/zed/assets/38318044/6e9c3057-9860-4f4b-9a73-c158ebac5ba9">
This commit is contained in:
parent
328d98dddc
commit
93a5d0ca29
7 changed files with 30 additions and 0 deletions
|
@ -124,5 +124,6 @@ fn notification_window_options(
|
||||||
display_id: Some(screen.id()),
|
display_id: Some(screen.id()),
|
||||||
window_background: WindowBackgroundAppearance::default(),
|
window_background: WindowBackgroundAppearance::default(),
|
||||||
app_id: Some(app_id.to_owned()),
|
app_id: Some(app_id.to_owned()),
|
||||||
|
window_min_size: Size::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ fn main() {
|
||||||
kind: WindowKind::PopUp,
|
kind: WindowKind::PopUp,
|
||||||
is_movable: false,
|
is_movable: false,
|
||||||
app_id: None,
|
app_id: None,
|
||||||
|
window_min_size: Size::default(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2287,6 +2287,15 @@ impl Pixels {
|
||||||
pub fn abs(&self) -> Self {
|
pub fn abs(&self) -> Self {
|
||||||
Self(self.0.abs())
|
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 {
|
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.
|
/// Application identifier of the window. Can by used by desktop environments to group applications together.
|
||||||
pub app_id: Option<String>,
|
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
|
/// 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 display_id: Option<DisplayId>,
|
||||||
|
|
||||||
pub window_background: WindowBackgroundAppearance,
|
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.
|
/// Represents the status of how a window should be opened.
|
||||||
|
@ -642,6 +648,7 @@ impl Default for WindowOptions {
|
||||||
display_id: None,
|
display_id: None,
|
||||||
window_background: WindowBackgroundAppearance::default(),
|
window_background: WindowBackgroundAppearance::default(),
|
||||||
app_id: None,
|
app_id: None,
|
||||||
|
window_min_size: Size::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,6 +505,7 @@ impl MacWindow {
|
||||||
focus,
|
focus,
|
||||||
show,
|
show,
|
||||||
display_id,
|
display_id,
|
||||||
|
window_min_size,
|
||||||
}: WindowParams,
|
}: WindowParams,
|
||||||
executor: ForegroundExecutor,
|
executor: ForegroundExecutor,
|
||||||
renderer_context: renderer::Context,
|
renderer_context: renderer::Context,
|
||||||
|
@ -646,6 +647,11 @@ impl MacWindow {
|
||||||
|
|
||||||
native_window.setMovable_(is_movable as BOOL);
|
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) {
|
if titlebar.map_or(true, |titlebar| titlebar.appears_transparent) {
|
||||||
native_window.setTitlebarAppearsTransparent_(YES);
|
native_window.setTitlebarAppearsTransparent_(YES);
|
||||||
native_window.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden);
|
native_window.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden);
|
||||||
|
|
|
@ -631,6 +631,7 @@ impl Window {
|
||||||
display_id,
|
display_id,
|
||||||
window_background,
|
window_background,
|
||||||
app_id,
|
app_id,
|
||||||
|
window_min_size,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
let bounds = window_bounds
|
let bounds = window_bounds
|
||||||
|
@ -647,6 +648,7 @@ impl Window {
|
||||||
show,
|
show,
|
||||||
display_id,
|
display_id,
|
||||||
window_background,
|
window_background,
|
||||||
|
window_min_size,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
let display_id = platform_window.display().map(|display| display.id());
|
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()),
|
display_id: display.map(|display| display.id()),
|
||||||
window_background: cx.theme().window_background_appearance(),
|
window_background: cx.theme().window_background_appearance(),
|
||||||
app_id: Some(app_id.to_owned()),
|
app_id: Some(app_id.to_owned()),
|
||||||
|
window_min_size: gpui::Size {
|
||||||
|
width: px(360.0),
|
||||||
|
height: px(240.0),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue