crates/gpui/src/platform.rs 🔗
@@ -706,7 +706,6 @@ pub(crate) struct WindowParams {
pub display_id: Option<DisplayId>,
- #[cfg_attr(target_os = "linux", allow(dead_code))]
pub window_min_size: Option<Size<Pixels>>,
}
apricotbucket28 created
https://github.com/zed-industries/zed/pull/13126 added the
`window_min_size` property for window creation, but it was only
implemented for macOS. This PR implements the property on Linux as well.
Release Notes:
- N/A
crates/gpui/src/platform.rs | 1 -
crates/gpui/src/platform/linux/wayland/window.rs | 5 ++++-
crates/gpui/src/platform/linux/x11/window.rs | 9 +++++++++
3 files changed, 13 insertions(+), 2 deletions(-)
@@ -706,7 +706,6 @@ pub(crate) struct WindowParams {
pub display_id: Option<DisplayId>,
- #[cfg_attr(target_os = "linux", allow(dead_code))]
pub window_min_size: Option<Size<Pixels>>,
}
@@ -264,7 +264,10 @@ impl WaylandWindow {
.wm_base
.get_xdg_surface(&surface, &globals.qh, surface.id());
let toplevel = xdg_surface.get_toplevel(&globals.qh, surface.id());
- toplevel.set_min_size(50, 50);
+
+ if let Some(size) = params.window_min_size {
+ toplevel.set_min_size(size.width.0 as i32, size.height.0 as i32);
+ }
if let Some(fractional_scale_manager) = globals.fractional_scale_manager.as_ref() {
fractional_scale_manager.get_fractional_scale(&surface, &globals.qh, surface.id());
@@ -14,6 +14,7 @@ use raw_window_handle as rwh;
use util::{maybe, ResultExt};
use x11rb::{
connection::Connection,
+ properties::WmSizeHints,
protocol::{
sync,
xinput::{self, ConnectionExt as _},
@@ -371,6 +372,14 @@ impl X11WindowState {
visual.depth, x_window, visual_set.root, bounds.origin.x.0 + 2, bounds.origin.y.0, bounds.size.width.0, bounds.size.height.0)
})?;
+ if let Some(size) = params.window_min_size {
+ let mut size_hints = WmSizeHints::new();
+ size_hints.min_size = Some((size.width.0 as i32, size.height.0 as i32));
+ size_hints
+ .set_normal_hints(xcb_connection, x_window)
+ .unwrap();
+ }
+
let reply = xcb_connection
.get_geometry(x_window)
.unwrap()