aboutsummaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-17 10:03:27 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commitc359672bd266cab37adc3f91750ef59a6a05d515 (patch)
treededc9b034bf73680d18568a30454505ec5470d21 /src/layout/mod.rs
parent38350935e6f92c2db90faaf059b851f8158e32c2 (diff)
downloadniri-c359672bd266cab37adc3f91750ef59a6a05d515.tar.gz
niri-c359672bd266cab37adc3f91750ef59a6a05d515.tar.bz2
niri-c359672bd266cab37adc3f91750ef59a6a05d515.zip
floating: Request size only once
Let floating windows resize themselves and keep that size.
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs26
1 files changed, 25 insertions, 1 deletions
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 {