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



commit d8406624d38d1cd74c4d33d75c840fe578933333
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 |   26 ++++++--------------------
 1 files changed, 6 insertions(+), 20 deletions(-)
---
diff --git a/src/windowMode.js b/src/windowMode.js
index c9e2b8f..76b3e9b 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,25 +73,20 @@ const ModeController = new Lang.Class({
         return this._mode;
     },
 
-    _setCanFullscreen: function(canFullscreen) {
-        this._canFullscreen = canFullscreen;
-
-        if (!this._canFullscreen && this._fullscreen)
+    _updateFullscreen: function() {
+        if (!this.getCanFullscreen() && this._fullscreen)
             this._setFullscreen(false);
 
         this.emit('can-fullscreen-changed');
     },
 
     _setFullscreen: function(fullscreen) {
-        if (!this._canFullscreenPolicy(this._mode))
+        if (!this.getCanFullscreen() && fullscreen)
             return;
 
         if (this._fullscreen == fullscreen)
             return;
 
-        if (fullscreen && !this._canFullscreen)
-            return;
-
         this._fullscreen = fullscreen;
         this.emit('fullscreen-changed', this._fullscreen);
     },
@@ -114,7 +100,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]