Store output name in CastTarget

Will be useful in the next commit to avoid fetching it every time.
This commit is contained in:
Ivan Molodetskikh
2026-01-12 18:25:31 +03:00
parent 570ea119ba
commit 6f92b3296a
3 changed files with 31 additions and 14 deletions
+22 -3
View File
@@ -571,8 +571,27 @@ pub enum CenterCoords {
pub enum CastTarget {
// Dynamic cast before selecting anything.
Nothing,
Output(WeakOutput),
Window { id: u64 },
Output {
output: WeakOutput,
/// Cached name of the output.
name: String,
},
Window {
id: u64,
},
}
impl CastTarget {
pub fn output(output: &Output) -> Self {
Self::Output {
output: output.downgrade(),
name: output.name(),
}
}
pub fn matches_output(&self, weak: &WeakOutput) -> bool {
matches!(self, CastTarget::Output { output, .. } if output == weak)
}
}
/// Pending update to a window's focus timestamp.
@@ -2797,7 +2816,7 @@ impl Niri {
RedrawState::WaitingForEstimatedVBlankAndQueued(token) => self.event_loop.remove(token),
}
self.stop_casts_for_target(CastTarget::Output(output.downgrade()));
self.stop_casts_for_target(CastTarget::output(output));
self.remove_screencopy_output(output);