[fractal] Fix fullscreen mode switch in media viewer



commit 1024dd5b72b62d6eea0d135296a93c5af1889e10
Author: sonjita <sonjaleaheinze gmail com>
Date:   Mon Jan 20 20:47:40 2020 +0100

    Fix fullscreen mode switch in media viewer
    
    Before, when changing from non-fullscreen mode to fullscreen mode or
    vice versa, the video widget size was handled according to the mode
    that was changed from. With this commit, it gets handled according to
    the mode it is changed to.

 fractal-gtk/src/widgets/media_viewer.rs | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/fractal-gtk/src/widgets/media_viewer.rs b/fractal-gtk/src/widgets/media_viewer.rs
index ee47bff1..95e17476 100644
--- a/fractal-gtk/src/widgets/media_viewer.rs
+++ b/fractal-gtk/src/widgets/media_viewer.rs
@@ -64,6 +64,7 @@ struct Data {
     loading_more_media: bool,
     loading_error: bool,
     no_more_media: bool,
+    is_fullscreen: bool,
 }
 
 impl Data {
@@ -76,6 +77,12 @@ impl Data {
         main_window: gtk::Window,
         builder: gtk::Builder,
     ) -> Data {
+        let is_fullscreen = main_window
+            .clone()
+            .get_window()
+            .unwrap()
+            .get_state()
+            .contains(gdk::WindowState::FULLSCREEN);
         Data {
             media_list,
             current_media_index,
@@ -90,6 +97,7 @@ impl Data {
             access_token,
             main_window,
             signal_id: None,
+            is_fullscreen,
         }
     }
 
@@ -112,6 +120,7 @@ impl Data {
 
     pub fn enter_full_screen(&mut self) {
         self.main_window.fullscreen();
+        self.is_fullscreen = true;
 
         let media_viewer_headerbar_box = self
             .builder
@@ -151,6 +160,7 @@ impl Data {
 
     pub fn leave_full_screen(&mut self) {
         self.main_window.unfullscreen();
+        self.is_fullscreen = false;
 
         let media_viewer_headerbar_box = self
             .builder
@@ -300,16 +310,14 @@ impl Data {
 
         bx.pack_start(&overlay, false, false, 0);
 
-        if let Some(win) = self.main_window.clone().get_window() {
-            if win.get_state().contains(gdk::WindowState::FULLSCREEN) {
-                bx.set_child_packing(&overlay, true, true, 0, gtk::PackType::Start);
-            } else {
-                bx.set_margin_start(70);
-                bx.set_margin_end(70);
-                overlay.set_valign(gtk::Align::Center);
-                overlay.set_halign(gtk::Align::Center);
-                VideoPlayerWidget::auto_adjust_widget_to_video_dimensions(&bx, &overlay, &player);
-            }
+        if self.is_fullscreen {
+            bx.set_child_packing(&overlay, true, true, 0, gtk::PackType::Start);
+        } else {
+            bx.set_margin_start(70);
+            bx.set_margin_end(70);
+            overlay.set_valign(gtk::Align::Center);
+            overlay.set_halign(gtk::Align::Center);
+            VideoPlayerWidget::auto_adjust_widget_to_video_dimensions(&bx, &overlay, &player);
         }
 
         let player_weak = Rc::downgrade(&player);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]