aboutsummaryrefslogtreecommitdiff
path: root/src/niri.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-02-11 09:52:05 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-02-11 10:31:12 +0300
commit29b7a41692b9773ac939c2b18fe9dbf6735cfef1 (patch)
treea0a1ec4a15566ed6eb8d0bcb2ef8dd4c96674a8b /src/niri.rs
parent216753678a9fc51b0d639b6ed374e965d9eda301 (diff)
downloadniri-29b7a41692b9773ac939c2b18fe9dbf6735cfef1.tar.gz
niri-29b7a41692b9773ac939c2b18fe9dbf6735cfef1.tar.bz2
niri-29b7a41692b9773ac939c2b18fe9dbf6735cfef1.zip
Implement is-window-cast-target window rule matcher
Diffstat (limited to 'src/niri.rs')
-rw-r--r--src/niri.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/niri.rs b/src/niri.rs
index 4dfaf525..b1b9a90c 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -642,13 +642,18 @@ impl State {
self.niri.refresh_idle_inhibit();
self.refresh_pointer_contents();
foreign_toplevel::refresh(self);
+
+ #[cfg(feature = "xdp-gnome-screencast")]
+ self.niri.refresh_mapped_cast_outputs();
+ // Should happen before refresh_window_rules(), but after anything that can start or stop
+ // screencasts.
+ #[cfg(feature = "xdp-gnome-screencast")]
+ self.niri.refresh_mapped_cast_window_rules();
+
self.niri.refresh_window_rules();
self.refresh_ipc_outputs();
self.ipc_refresh_layout();
self.ipc_refresh_keyboard_layout_index();
-
- #[cfg(feature = "xdp-gnome-screencast")]
- self.niri.refresh_mapped_cast_outputs();
}
fn notify_blocker_cleared(&mut self) {
@@ -3257,6 +3262,20 @@ impl Niri {
}
#[cfg(feature = "xdp-gnome-screencast")]
+ pub fn refresh_mapped_cast_window_rules(&mut self) {
+ // O(N^2) but should be fine since there aren't many casts usually.
+ self.layout.with_windows_mut(|mapped, _| {
+ let id = mapped.id().get();
+ // Find regardless of cast.is_active.
+ let value = self
+ .casts
+ .iter()
+ .any(|cast| cast.target == (CastTarget::Window { id }));
+ mapped.set_is_window_cast_target(value);
+ });
+ }
+
+ #[cfg(feature = "xdp-gnome-screencast")]
pub fn refresh_mapped_cast_outputs(&mut self) {
use std::collections::hash_map::Entry;