Implement is-window-cast-target window rule matcher

This commit is contained in:
Ivan Molodetskikh
2025-02-11 09:52:05 +03:00
parent 216753678a
commit 29b7a41692
5 changed files with 94 additions and 3 deletions
+22 -3
View File
@@ -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) {
@@ -3256,6 +3261,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;