[gnome-documents/wip/rishi/split-view: 6/17] windowMode: Clean up the fullscreen code



commit bfea86789ccc7ccb89f87c9ff58f322a454cf047
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Oct 15 15:10:15 2014 +0200

    windowMode: Clean up the fullscreen code
    
    Ensure that the fullscreen logic runs after this._mode has been updated
    so that there are no state changes between can-fullscreen-changed and
    window-mode-changed.
    
    This changes the current requirement that setFullscreen has to be used
    before the mode is updated, which I found to be confusing, and we
    don't need a separate this._canFullscreen variable any more.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686461

 src/windowMode.js |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/src/windowMode.js b/src/windowMode.js
index e76b368..23f76e6 100644
--- a/src/windowMode.js
+++ b/src/windowMode.js
@@ -39,27 +39,20 @@ const ModeController = new Lang.Class({
     _init: function() {
         this._mode = WindowMode.NONE;
         this._fullscreen = false;
-        this._canFullscreen = false;
         this._history = [];
     },
 
-    _canFullscreenPolicy: function(mode) {
-        return (mode == WindowMode.PREVIEW || mode == WindowMode.EDIT);
-    },
-
     goBack: function() {
         let oldMode = this._history.pop();
         if (!oldMode || oldMode == WindowMode.NONE)
             return;
 
-        let policy = this._canFullscreenPolicy(oldMode);
-        this._setCanFullscreen(policy);
-
         // Swap the old and current modes.
         let tmp = oldMode;
         oldMode = this._mode;
         this._mode = tmp;
 
+        this._updateFullscreen();
         this.emit('window-mode-changed', this._mode, oldMode);
     },
 
@@ -69,12 +62,10 @@ const ModeController = new Lang.Class({
         if (oldMode == mode)
             return;
 
-        let policy = this._canFullscreenPolicy(mode);
-        this._setCanFullscreen(policy);
-
         this._history.push(oldMode);
         this._mode = mode;
 
+        this._updateFullscreen();
         this.emit('window-mode-changed', this._mode, oldMode);
     },
 
@@ -82,11 +73,9 @@ const ModeController = new Lang.Class({
         return this._mode;
     },
 
-    _setCanFullscreen: function(canFullscreen) {
-        this._canFullscreen = canFullscreen;
-
-        if (!this._canFullscreen && this._fullscreen)
-            this.setFullscreen(false);
+    _updateFullscreen: function() {
+        if (!this.getCanFullscreen() && this._fullscreen)
+            this._setFullscreen(false);
 
         this.emit('can-fullscreen-changed');
     },
@@ -108,7 +97,7 @@ const ModeController = new Lang.Class({
     },
 
     getCanFullscreen: function() {
-        return this._canFullscreen;
+        return (this._mode == WindowMode.PREVIEW || this._mode == WindowMode.EDIT);
     }
 });
 Signals.addSignalMethods(ModeController.prototype);


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