[fractal] Fix: only auto-play videos, if Fractal is focused
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Fix: only auto-play videos, if Fractal is focused
- Date: Tue, 11 Feb 2020 08:26:29 +0000 (UTC)
commit b0d130b6a28c42f7e9f604a260d37f3f09da79b8
Author: Sonja Heinze <sonjaleaheinze gmail com>
Date: Fri Feb 7 09:13:11 2020 +0100
Fix: only auto-play videos, if Fractal is focused
Before, when another app was focused while the user was scrolling up or
down in a room history of Fractal, videos in that room history started to
auto-play. Now, that only happens, if Fractal is the focused app.
fractal-gtk/src/widgets/room_history.rs | 37 ++++++++++++++++++---------------
1 file changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs
index ab5f170e..46b54866 100644
--- a/fractal-gtk/src/widgets/room_history.rs
+++ b/fractal-gtk/src/widgets/room_history.rs
@@ -315,20 +315,23 @@ impl RoomHistory {
.downcast::<gtk::Scrollbar>()
.unwrap();
let weak_rows = Rc::downgrade(&self.rows);
- scrollbar.connect_value_changed(move |_| {
- weak_rows.upgrade().map(|rows| {
- let weak_rows_inner = weak_rows.clone();
- let new_id = timeout_add(250, move || {
- weak_rows_inner.upgrade().map(|rows| {
- rows.borrow_mut().update_videos();
- rows.borrow_mut().video_scroll_debounce = None;
+ scrollbar.connect_value_changed(move |sb| {
+ if !sb.get_state_flags().contains(gtk::StateFlags::BACKDROP) {
+ /* Fractal is focused */
+ weak_rows.upgrade().map(|rows| {
+ let weak_rows_inner = weak_rows.clone();
+ let new_id = timeout_add(250, move || {
+ weak_rows_inner.upgrade().map(|rows| {
+ rows.borrow_mut().update_videos();
+ rows.borrow_mut().video_scroll_debounce = None;
+ });
+ Continue(false)
});
- Continue(false)
+ if let Some(old_id) = rows.borrow_mut().video_scroll_debounce.replace(new_id) {
+ let _ = Source::remove(old_id);
+ }
});
- if let Some(old_id) = rows.borrow_mut().video_scroll_debounce.replace(new_id) {
- let _ = Source::remove(old_id);
- }
- });
+ }
});
}
@@ -376,13 +379,13 @@ impl RoomHistory {
if window.get_mapped() {
/* The room history is being displayed */
weak_rows.upgrade().map(|rows| {
- let focussed = gtk::StateFlags::BACKDROP;
- if flag.contains(focussed) {
- /* Fractal has been focussed */
+ let focused = gtk::StateFlags::BACKDROP;
+ if flag.contains(focused) {
+ /* Fractal has been focused */
let len = rows.borrow().playing_videos.len();
if len != 0 {
warn!(
- "{:?} videos were playing while Fractal was focussed out.",
+ "{:?} videos were playing while Fractal was focused out.",
len
);
for (player, handler_id) in rows.borrow_mut().playing_videos.drain(..) {
@@ -397,7 +400,7 @@ impl RoomHistory {
}
rows.borrow_mut().playing_videos = videos;
} else {
- /* Fractal has been unfocussed */
+ /* Fractal has been unfocused */
if let Some(id) = rows.borrow_mut().video_scroll_debounce.take() {
let _ = Source::remove(id);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]