aboutsummaryrefslogtreecommitdiff
path: root/src/window/mapped.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-03-19 15:20:03 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-03-19 18:29:13 +0400
commitc61361de3ca4484387f39b067eadc612908560eb (patch)
tree0fc6f30df529c3ac4f7151e314e4d9548bc934bf /src/window/mapped.rs
parent3963f537a4182dbcd8e1e2f262ee105473facc56 (diff)
downloadniri-c61361de3ca4484387f39b067eadc612908560eb.tar.gz
niri-c61361de3ca4484387f39b067eadc612908560eb.tar.bz2
niri-c61361de3ca4484387f39b067eadc612908560eb.zip
Implement window rule reloading and min/max size rules
Diffstat (limited to 'src/window/mapped.rs')
-rw-r--r--src/window/mapped.rs36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/window/mapped.rs b/src/window/mapped.rs
index 4476dede..6afd995e 100644
--- a/src/window/mapped.rs
+++ b/src/window/mapped.rs
@@ -1,3 +1,5 @@
+use std::cmp::{max, min};
+
use smithay::backend::renderer::element::{AsRenderElements as _, Id};
use smithay::desktop::space::SpaceElement as _;
use smithay::desktop::Window;
@@ -82,17 +84,43 @@ impl LayoutElement for Mapped {
}
fn min_size(&self) -> Size<i32, Logical> {
- with_states(self.toplevel().wl_surface(), |state| {
+ let mut size = with_states(self.toplevel().wl_surface(), |state| {
let curr = state.cached_state.current::<SurfaceCachedState>();
curr.min_size
- })
+ });
+
+ if let Some(x) = self.rules.min_width {
+ size.w = max(size.w, i32::from(x));
+ }
+ if let Some(x) = self.rules.min_height {
+ size.h = max(size.h, i32::from(x));
+ }
+
+ size
}
fn max_size(&self) -> Size<i32, Logical> {
- with_states(self.toplevel().wl_surface(), |state| {
+ let mut size = with_states(self.toplevel().wl_surface(), |state| {
let curr = state.cached_state.current::<SurfaceCachedState>();
curr.max_size
- })
+ });
+
+ if let Some(x) = self.rules.max_width {
+ if size.w == 0 {
+ size.w = i32::from(x);
+ } else if x > 0 {
+ size.w = min(size.w, i32::from(x));
+ }
+ }
+ if let Some(x) = self.rules.max_height {
+ if size.h == 0 {
+ size.h = i32::from(x);
+ } else if x > 0 {
+ size.h = min(size.h, i32::from(x));
+ }
+ }
+
+ size
}
fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool {