diff options
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/floating.rs | 35 | ||||
| -rw-r--r-- | src/layout/mod.rs | 26 |
2 files changed, 43 insertions, 18 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs index ee9c7013..4565e2f2 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -367,7 +367,7 @@ impl<W: LayoutElement> FloatingSpace<W> { tile.update_config(self.scale, self.options.clone()); let win = tile.window_mut(); - if win.is_pending_fullscreen() { + let size = if win.is_pending_fullscreen() { let mut size = Size::from((0, 0)); // Make sure fixed-size through window rules keeps working. @@ -380,8 +380,11 @@ impl<W: LayoutElement> FloatingSpace<W> { size.h = min_size.h; } - win.request_size(size, true, None); - } + size + } else { + win.size() + }; + win.request_size_once(size, true); if activate || self.tiles.is_empty() { self.active_window_id = Some(win.id().clone()); @@ -591,16 +594,15 @@ 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 win_height = win - .requested_size() - .map(|size| size.h) - // If we requested height = 0, then switch to the current height. - .filter(|h| *h != 0) - .unwrap_or_else(|| win.size().h); + 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 = ensure_min_max_size(win_height, min_size.h, max_size.h); let win_size = Size::from((win_width, win_height)); - win.request_size(win_size, animate, None); + win.request_size_once(win_size, animate); } pub fn set_window_height(&mut self, id: Option<&W::Id>, change: SizeChange, animate: bool) { @@ -622,16 +624,15 @@ 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 win_width = win - .requested_size() - .map(|size| size.w) - // If we requested width = 0, then switch to the current width. - .filter(|w| *w != 0) - .unwrap_or_else(|| win.size().w); + 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 = ensure_min_max_size(win_width, min_size.w, max_size.w); let win_size = Size::from((win_width, win_height)); - win.request_size(win_size, animate, None); + win.request_size_once(win_size, animate); } fn focus_directional( diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 7378aa60..acc5257f 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -151,13 +151,24 @@ pub trait LayoutElement { self.render(renderer, location, scale, alpha, target).popups } + /// Requests the element to change its size. + /// + /// The size request is stored and will be continuously sent to the element on any further + /// state changes. fn request_size( &mut self, size: Size<i32, Logical>, animate: bool, transaction: Option<Transaction>, ); + + /// Requests the element to change size once, clearing the request afterwards. + fn request_size_once(&mut self, size: Size<i32, Logical>, animate: bool) { + self.request_size(size, animate, None); + } + fn request_fullscreen(&mut self, size: Size<i32, Logical>); + fn min_size(&self) -> Size<i32, Logical>; fn max_size(&self) -> Size<i32, Logical>; fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool; @@ -186,6 +197,17 @@ 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. + /// + /// 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()) + } + fn is_child_of(&self, parent: &Self) -> bool; fn rules(&self) -> &ResolvedWindowRules; @@ -3255,10 +3277,12 @@ impl<W: LayoutElement> Layout<W> { size.h = min_size.h; } - win.request_size(size, true, None); + win.request_size_once(size, true); // If we're unfullscreening to floating, default to the floating layout. is_floating = tile.unfullscreen_to_floating(); + } else { + win.request_size_once(win.size(), true); } let mut data = InteractiveMoveData { |
