aboutsummaryrefslogtreecommitdiff
path: root/src/window
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-27 11:20:03 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commita24a6e4e3c441389fd7731320f47e61e567e237f (patch)
tree0f93350f38a83af27ccb5549191323dc56cf9b4e /src/window
parent6fba4c371e7868f8d581cf3d49d611cdbb590ad4 (diff)
downloadniri-a24a6e4e3c441389fd7731320f47e61e567e237f.tar.gz
niri-a24a6e4e3c441389fd7731320f47e61e567e237f.tar.bz2
niri-a24a6e4e3c441389fd7731320f47e61e567e237f.zip
Implement is-floating window rule matcher
Diffstat (limited to 'src/window')
-rw-r--r--src/window/mapped.rs14
-rw-r--r--src/window/mod.rs21
2 files changed, 35 insertions, 0 deletions
diff --git a/src/window/mapped.rs b/src/window/mapped.rs
index 022a57a0..75551ef1 100644
--- a/src/window/mapped.rs
+++ b/src/window/mapped.rs
@@ -66,6 +66,9 @@ pub struct Mapped {
/// Whether this window is the active window in its column.
is_active_in_column: bool,
+ /// Whether this window is floating.
+ is_floating: bool,
+
/// Buffer to draw instead of the window when it should be blocked out.
block_out_buffer: RefCell<SolidColorBuffer>,
@@ -163,6 +166,7 @@ impl Mapped {
need_to_recompute_rules: false,
is_focused: false,
is_active_in_column: false,
+ is_floating: false,
block_out_buffer: RefCell::new(SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.])),
animate_next_configure: false,
animate_serials: Vec::new(),
@@ -220,6 +224,10 @@ impl Mapped {
self.is_active_in_column
}
+ pub fn is_floating(&self) -> bool {
+ self.is_floating
+ }
+
pub fn set_is_focused(&mut self, is_focused: bool) {
if self.is_focused == is_focused {
return;
@@ -690,6 +698,12 @@ impl LayoutElement for Mapped {
self.need_to_recompute_rules |= changed;
}
+ fn set_floating(&mut self, floating: bool) {
+ let changed = self.is_floating != floating;
+ self.is_floating = floating;
+ self.need_to_recompute_rules |= changed;
+ }
+
fn set_bounds(&self, bounds: Size<i32, Logical>) {
self.toplevel().with_pending_state(|state| {
state.bounds = Some(bounds);
diff --git a/src/window/mod.rs b/src/window/mod.rs
index 44d5359e..1cf576df 100644
--- a/src/window/mod.rs
+++ b/src/window/mod.rs
@@ -115,6 +115,21 @@ impl<'a> WindowRef<'a> {
WindowRef::Mapped(mapped) => mapped.is_active_in_column(),
}
}
+
+ pub fn is_floating(self) -> bool {
+ match self {
+ // FIXME: This means you cannot set initial configure rules based on is-floating. I'm
+ // not sure there's a good way to support it, since this matcher makes a cycle with the
+ // open-floating rule.
+ //
+ // That said, I don't think there are a lot of useful initial configure properties you
+ // may want to set through an is-floating matcher? Like, if you're configuring a
+ // specific window to open as floating, you can also set those properties in that same
+ // window rule, rather than relying on a different is-floating rule.
+ WindowRef::Unmapped(_) => false,
+ WindowRef::Mapped(mapped) => mapped.is_floating(),
+ }
+ }
}
impl ResolvedWindowRules {
@@ -381,5 +396,11 @@ fn window_matches(window: WindowRef, role: &XdgToplevelSurfaceRoleAttributes, m:
}
}
+ if let Some(is_floating) = m.is_floating {
+ if window.is_floating() != is_floating {
+ return false;
+ }
+ }
+
true
}