diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/niri.rs | 25 | ||||
| -rw-r--r-- | src/window/mapped.rs | 17 | ||||
| -rw-r--r-- | src/window/mod.rs | 13 |
3 files changed, 52 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; diff --git a/src/window/mapped.rs b/src/window/mapped.rs index b5bf8afb..055f2cc5 100644 --- a/src/window/mapped.rs +++ b/src/window/mapped.rs @@ -80,6 +80,9 @@ pub struct Mapped { /// Whether this window is floating. is_floating: bool, + /// Whether this window is a target of a window cast. + is_window_cast_target: bool, + /// Whether this window should ignore opacity set through window rules. ignore_opacity_window_rule: bool, @@ -188,6 +191,7 @@ impl Mapped { is_focused: false, is_active_in_column: true, is_floating: false, + is_window_cast_target: false, ignore_opacity_window_rule: false, block_out_buffer: RefCell::new(SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.])), animate_next_configure: false, @@ -260,6 +264,10 @@ impl Mapped { self.is_floating } + pub fn is_window_cast_target(&self) -> bool { + self.is_window_cast_target + } + pub fn toggle_ignore_opacity_window_rule(&mut self) { self.ignore_opacity_window_rule = !self.ignore_opacity_window_rule; } @@ -273,6 +281,15 @@ impl Mapped { self.need_to_recompute_rules = true; } + pub fn set_is_window_cast_target(&mut self, value: bool) { + if self.is_window_cast_target == value { + return; + } + + self.is_window_cast_target = value; + self.need_to_recompute_rules = true; + } + fn render_snapshot(&self, renderer: &mut GlesRenderer) -> LayoutElementRenderSnapshot { let _span = tracy_client::span!("Mapped::render_snapshot"); diff --git a/src/window/mod.rs b/src/window/mod.rs index 10aecbfe..41f2182b 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -146,6 +146,13 @@ impl<'a> WindowRef<'a> { WindowRef::Mapped(mapped) => mapped.is_floating(), } } + + pub fn is_window_cast_target(self) -> bool { + match self { + WindowRef::Unmapped(_) => false, + WindowRef::Mapped(mapped) => mapped.is_window_cast_target(), + } + } } impl ResolvedWindowRules { @@ -446,5 +453,11 @@ fn window_matches(window: WindowRef, role: &XdgToplevelSurfaceRoleAttributes, m: } } + if let Some(is_window_cast_target) = m.is_window_cast_target { + if window.is_window_cast_target() != is_window_cast_target { + return false; + } + } + true } |
