Browse Source

room-history: Prevent scroll when contextual menu is shown

closes GNOME/fractal#937
merge-requests/1327/merge
Harshil Patel 3 years ago
parent
commit
103fc1927e
  1. 5
      src/session/content/room_history/item_row.rs
  2. 8
      src/session/content/room_history/mod.rs

5
src/session/content/room_history/item_row.rs

@ -99,6 +99,7 @@ mod imp {
if let Some(event) = obj.item().and_then(|item| item.downcast::<Event>().ok()) {
let room_history = obj.room_history();
let popover = room_history.item_context_menu().to_owned();
room_history.set_sticky(false);
if let Some(list_item) = obj.parent() {
list_item.add_css_class("has-open-popup");
@ -106,7 +107,9 @@ mod imp {
let cell: Rc<RefCell<Option<glib::signal::SignalHandlerId>>> =
Rc::new(RefCell::new(None));
let signal_id = popover.connect_closed(
clone!(@weak list_item, @strong cell => move |popover| {
clone!(@weak list_item, @strong cell, @weak room_history => move |popover| {
room_history.enable_sticky_mode();
list_item.remove_css_class("has-open-popup");
if let Some(signal_id) = cell.take() {

8
src/session/content/room_history/mod.rs

@ -895,6 +895,14 @@ impl RoomHistory {
.emit_by_name::<bool>("scroll-child", &[&gtk::ScrollType::End, &false]);
}
/// Set `RoomHistory` to stick to the bottom based on scrollbar position
pub fn enable_sticky_mode(&self) {
let imp = self.imp();
let adj = imp.listview.vadjustment().unwrap();
let is_at_bottom = adj.value() + adj.page_size() == adj.upper();
self.set_sticky(is_at_bottom);
}
fn try_again(&self) {
self.start_loading();
}

Loading…
Cancel
Save