diff --git a/data/resources/style.css b/data/resources/style.css index 85926f26..87a20f90 100644 --- a/data/resources/style.css +++ b/data/resources/style.css @@ -392,6 +392,11 @@ login { padding-bottom: 6px; } +.room-history row.has-open-popup { + background-color: alpha(currentColor, 0.07); + border-radius: 6px; +} + .room-history row.has-header { margin-top: 6px; } diff --git a/src/session/content/room_history/item_row.rs b/src/session/content/room_history/item_row.rs index 2711d10c..ca7d9513 100644 --- a/src/session/content/room_history/item_row.rs +++ b/src/session/content/room_history/item_row.rs @@ -16,7 +16,7 @@ use crate::{ }; mod imp { - use std::cell::RefCell; + use std::{cell::RefCell, rc::Rc}; use glib::{signal::SignalHandlerId, WeakRef}; use once_cell::unsync::OnceCell; @@ -114,6 +114,24 @@ mod imp { let room_history = obj.room_history(); let popover = room_history.item_context_menu().to_owned(); + if let Some(list_item) = obj.parent() { + list_item.add_css_class("has-open-popup"); + + let cell: Rc>> = + Rc::new(RefCell::new(None)); + let signal_id = popover.connect_closed( + clone!(@weak list_item, @strong cell => move |popover| { + list_item.remove_css_class("has-open-popup"); + + if let Some(signal_id) = cell.take() { + popover.disconnect(signal_id); + } + }), + ); + + cell.replace(Some(signal_id)); + } + if let Some(event) = event .downcast_ref::() .filter(|event| event.content().is_some())