shell: Enforce some minimum resize sizes

This commit is contained in:
Victoria Brekenfeld 2023-07-07 18:23:34 +02:00
parent 0ebcfa24a3
commit 92019b4286
3 changed files with 23 additions and 4 deletions

View file

@ -86,8 +86,8 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
let (min_size, max_size) = (self.window.min_size(), self.window.max_size());
let min_width = min_size.map(|s| s.w).unwrap_or(1);
let min_height = min_size.map(|s| s.h).unwrap_or(1);
let min_width = min_size.map(|s| s.w).unwrap_or(360);
let min_height = min_size.map(|s| s.h).unwrap_or(240);
let max_width = max_size.map(|s| s.w).unwrap_or(i32::max_value());
let max_height = max_size.map(|s| s.h).unwrap_or(i32::max_value());

View file

@ -305,6 +305,14 @@ impl FloatingLayout {
Some(other) => Some(other.merge(output_geo)),
}) else { return true };
let (min_size, max_size) = (mapped.min_size(), mapped.max_size());
let min_width = min_size.map(|s| s.w).unwrap_or(360);
let min_height = min_size.map(|s| s.h).unwrap_or(240);
let max_width = max_size.map(|s| s.w).unwrap_or(i32::max_value());
let max_height = max_size.map(|s| s.h).unwrap_or(i32::max_value());
geo.size.w = min_width.max(geo.size.w).min(max_width);
geo.size.h = min_height.max(geo.size.h).min(max_height);
geo = geo.intersection(bounding_box).unwrap();
*mapped.resize_state.lock().unwrap() = Some(ResizeState::Resizing(ResizeData {
@ -314,7 +322,13 @@ impl FloatingLayout {
}));
mapped.set_resizing(true);
mapped.set_geometry(geo);
mapped.set_geometry(Rectangle::from_loc_and_size(
match mapped.active_window() {
CosmicSurface::X11(s) => s.geometry().loc,
_ => (0, 0).into(),
},
geo.size,
));
mapped.configure();
true

View file

@ -1536,7 +1536,12 @@ impl TilingLayout {
};
let old_size = sizes[shrink_idx];
sizes[shrink_idx] = (old_size - amount).max(10);
sizes[shrink_idx] =
(old_size - amount).max(if orientation == Orientation::Vertical {
360
} else {
240
});
let diff = old_size - sizes[shrink_idx];
sizes[grow_idx] += diff;
}