[gnome-games] fullscreen-box: Check for autohide on is_fullscreen changes



commit 6c08a9389ffc53369b326383afcf4cd56221b431
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Aug 11 05:00:01 2019 +0500

    fullscreen-box: Check for autohide on is_fullscreen changes
    
    Also use a setter instead of a signal handler and skip the setter if the
    value didn't change.

 data/ui/fullscreen-box.ui  |  1 -
 src/ui/fullscreen-box.vala | 31 ++++++++++++++++++++-----------
 2 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/data/ui/fullscreen-box.ui b/data/ui/fullscreen-box.ui
index c0a7d5aa..423a41dc 100644
--- a/data/ui/fullscreen-box.ui
+++ b/data/ui/fullscreen-box.ui
@@ -17,7 +17,6 @@
             <property name="transition-type">slide-down</property>
             <property name="transition-duration">500</property>
             <property name="events">pointer-motion-mask</property>
-            <signal name="notify::is-fullscreen" handler="on_fullscreen_changed"/>
             <signal name="motion-notify-event" handler="on_motion_event"/>
           </object>
         </child>
diff --git a/src/ui/fullscreen-box.vala b/src/ui/fullscreen-box.vala
index a4bc3ff0..c8cd22a1 100644
--- a/src/ui/fullscreen-box.vala
+++ b/src/ui/fullscreen-box.vala
@@ -5,7 +5,26 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
        private const uint INACTIVITY_TIME_MILLISECONDS = 3000;
        private const int SHOW_HEADERBAR_DISTANCE = 5;
 
-       public bool is_fullscreen { get; set; }
+       private bool _is_fullscreen;
+       public bool is_fullscreen {
+               get { return _is_fullscreen; }
+               set {
+                       if (is_fullscreen == value)
+                               return;
+
+                       _is_fullscreen = value;
+
+                       if (!autohide)
+                               return;
+
+                       if (is_fullscreen) {
+                               show_ui ();
+                               on_cursor_moved ();
+                       }
+                       else
+                               on_restore ();
+               }
+       }
 
        private bool _autohide = true;
        public bool autohide {
@@ -92,16 +111,6 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
                        overlay.add (widget);
        }
 
-       [GtkCallback]
-       private void on_fullscreen_changed () {
-               if (is_fullscreen) {
-                       show_ui ();
-                       on_cursor_moved ();
-               }
-               else
-                       on_restore ();
-       }
-
        [GtkCallback]
        private bool on_motion_event (Gdk.EventMotion event) {
                if (!autohide)


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