aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/floating.rs16
-rw-r--r--src/layout/mod.rs20
2 files changed, 20 insertions, 16 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs
index 5c0eb121..8c1840d4 100644
--- a/src/layout/floating.rs
+++ b/src/layout/floating.rs
@@ -376,7 +376,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
} else {
// If the window wasn't fullscreen without a floating size (e.g. it was tiled before),
// ask for the current size.
- floating_size.unwrap_or_else(|| win.size_to_request())
+ floating_size.unwrap_or_else(|| win.expected_size())
};
// Make sure fixed-size through window rules keeps working.
let min_size = win.min_size();
@@ -597,11 +597,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
win_width = ensure_min_max_size(win_width, min_size.w, max_size.w);
win_width = max(1, win_width);
- let mut win_height = win.size_to_request().h;
- // If we requested height = 0, then switch to the current height.
- if win_height == 0 {
- win_height = win.size().h;
- }
+ let win_height = win.expected_size().h;
let win_height = ensure_min_max_size(win_height, min_size.h, max_size.h);
let win_size = Size::from((win_width, win_height));
@@ -630,11 +626,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
win_height = ensure_min_max_size(win_height, min_size.h, max_size.h);
win_height = max(1, win_height);
- let mut win_width = win.size_to_request().w;
- // If we requested width = 0, then switch to the current width.
- if win_width == 0 {
- win_width = win.size().w;
- }
+ let win_width = win.expected_size().w;
let win_width = ensure_min_max_size(win_width, min_size.w, max_size.w);
let win_size = Size::from((win_width, win_height));
@@ -771,7 +763,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
data.update(tile);
// Update the stored floating window size.
- let floating_size = tile.window().size_to_request();
+ let floating_size = tile.window().expected_size();
tile.set_floating_window_size(floating_size);
// When resizing by top/left edge, update the position accordingly.
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 8e86c0ca..bc2716af 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -197,15 +197,27 @@ pub trait LayoutElement {
/// Size previously requested through [`LayoutElement::request_size()`].
fn requested_size(&self) -> Option<Size<i32, Logical>>;
- /// Size that we will request of this window.
+ /// Size that we expect this window has or will shortly have.
///
/// This can be different from [`requested_size()`](LayoutElement::requested_size()). For
/// example, for floating windows this will generally return the current window size, rather
/// than the last size that we requested, since we want floating windows to be able to change
/// size freely. But not always: if we just requested a floating window to resize and it hasn't
/// responded to it yet, this will return the newly requested size.
- fn size_to_request(&self) -> Size<i32, Logical> {
- self.requested_size().unwrap_or_else(|| self.size())
+ ///
+ /// This function should never return a 0 size component.
+ ///
+ /// The default impl is for testing only, it will not preserve the window's own size changes.
+ fn expected_size(&self) -> Size<i32, Logical> {
+ let mut requested = self.requested_size().unwrap_or_default();
+ let current = self.size();
+ if requested.w == 0 {
+ requested.w = current.w;
+ }
+ if requested.h == 0 {
+ requested.h = current.h;
+ }
+ requested
}
fn is_child_of(&self, parent: &Self) -> bool;
@@ -1155,7 +1167,7 @@ impl<W: LayoutElement> Layout<W> {
// Update the floating size in case the window resizes itself during an interactive
// move.
- let floating_size = move_.tile.window().size_to_request();
+ let floating_size = move_.tile.window().expected_size();
move_.tile.set_floating_window_size(floating_size);
return;