From 6f2f5a38a6ed5774b7d3afc2741bd59cd8c0cc50 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 26 Nov 2024 14:12:15 +0100 Subject: [PATCH] fix: overlap notify filter handles by client --- src/wayland/protocols/overlap_notify.rs | 54 ++++++++++++++++--------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/src/wayland/protocols/overlap_notify.rs b/src/wayland/protocols/overlap_notify.rs index 1517e613..4298b6ef 100644 --- a/src/wayland/protocols/overlap_notify.rs +++ b/src/wayland/protocols/overlap_notify.rs @@ -167,15 +167,21 @@ impl LayerOverlapNotificationDataInternal { } pub fn add_notification(&mut self, new_notification: ZcosmicOverlapNotificationV1) { - for (toplevel, overlap) in &self.last_snapshot.toplevel_overlaps { - if let Ok(toplevel) = toplevel.upgrade() { - new_notification.toplevel_enter( - &toplevel, - overlap.loc.x, - overlap.loc.y, - overlap.size.w, - overlap.size.h, - ); + if let Some(client) = new_notification.client() { + for (toplevel, overlap) in &self.last_snapshot.toplevel_overlaps { + if let Some(toplevel) = toplevel + .upgrade() + .ok() + .filter(|handle| handle.client().is_some_and(|c| c == client)) + { + new_notification.toplevel_enter( + &toplevel, + overlap.loc.x, + overlap.loc.y, + overlap.size.w, + overlap.size.h, + ); + } } } for (_, (identifier, exclusive, layer, overlap)) in &self.last_snapshot.layer_overlaps { @@ -207,8 +213,13 @@ impl LayerOverlapNotificationDataInternal { for toplevel in self.last_snapshot.toplevel_overlaps.keys() { if !new_snapshot.toplevel_overlaps.contains_key(toplevel) { if let Ok(toplevel) = toplevel.upgrade() { - for notification in ¬ifications { - notification.toplevel_leave(&toplevel); + if let Some(client) = toplevel.client() { + for notification in notifications + .iter() + .filter(|n| n.client().is_some_and(|c| c == client)) + { + notification.toplevel_leave(&toplevel); + } } } } @@ -221,14 +232,19 @@ impl LayerOverlapNotificationDataInternal { .is_some_and(|old_overlap| old_overlap == overlap) { if let Ok(toplevel) = toplevel.upgrade() { - for notification in ¬ifications { - notification.toplevel_enter( - &toplevel, - overlap.loc.x, - overlap.loc.y, - overlap.size.w, - overlap.size.h, - ); + if let Some(client) = toplevel.client() { + for notification in notifications + .iter() + .filter(|n| n.client().is_some_and(|c| c == client)) + { + notification.toplevel_enter( + &toplevel, + overlap.loc.x, + overlap.loc.y, + overlap.size.w, + overlap.size.h, + ); + } } } }