aboutsummaryrefslogtreecommitdiff
path: root/src/layout/floating.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-27 09:58:22 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commitdb6447ed797fc5aa113d49e0da3130abcf58d2cf (patch)
tree426cb2aa6ddbc8ac00cb62015608c45e0bb6d95e /src/layout/floating.rs
parent99c0fabee658d3b1fc0fd3faf6741afd344d8dab (diff)
downloadniri-db6447ed797fc5aa113d49e0da3130abcf58d2cf.tar.gz
niri-db6447ed797fc5aa113d49e0da3130abcf58d2cf.tar.bz2
niri-db6447ed797fc5aa113d49e0da3130abcf58d2cf.zip
floating: Support default-column-width in most cases
open-fullscreen + open-floating default width is still not supported in this commit.
Diffstat (limited to 'src/layout/floating.rs')
-rw-r--r--src/layout/floating.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs
index 3633ad18..08a74b37 100644
--- a/src/layout/floating.rs
+++ b/src/layout/floating.rs
@@ -1,3 +1,4 @@
+use std::cmp::max;
use std::iter::zip;
use std::rc::Rc;
@@ -1097,6 +1098,36 @@ impl<W: LayoutElement> FloatingSpace<W> {
}
}
+ pub fn resolve_width(&self, width: ColumnWidth) -> ResolvedSize {
+ width.resolve_no_gaps(&self.options, self.working_area.size.w)
+ }
+
+ pub fn new_window_size(
+ &self,
+ width: Option<ColumnWidth>,
+ rules: &ResolvedWindowRules,
+ ) -> Size<i32, Logical> {
+ let border = rules.border.resolve_against(self.options.border);
+
+ let width = if let Some(width) = width {
+ let width = match self.resolve_width(width) {
+ ResolvedSize::Tile(mut size) => {
+ if !border.off {
+ size -= border.width.0 * 2.;
+ }
+ size
+ }
+ ResolvedSize::Window(size) => size,
+ };
+
+ max(1, width.floor() as i32)
+ } else {
+ 0
+ };
+
+ Size::from((width, 0))
+ }
+
#[cfg(test)]
pub fn view_size(&self) -> Size<f64, Logical> {
self.view_size