[Pkg-mozext-commits] [tabmixplus] 32/44: Restore windows order and selected window

David Prévot taffit at moszumanska.debian.org
Fri Mar 18 20:57:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit b89047a9d6360d9544bb8c365a708dc447a9370d
Author: onemen <tabmix.onemen at gmail.com>
Date:   Fri Mar 4 22:40:28 2016 +0200

    Restore windows order and selected window
---
 chrome/content/session/session.js      | 22 +++++++++++++++++++---
 chrome/content/session/sessionStore.js | 10 +++++++++-
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 5a99e0d..b82bc12 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -415,6 +415,9 @@ TabmixSessionManager = {
       if (show) {
         this.TabmixGroupsMigrator.missingTabViewNotification(window, show.msg);
       }
+      if (TabmixSvc.sm.windowToFocus) {
+        TabmixSvc.sm.windowToFocus.focus();
+      }
       let {restoreID} = window.tabmixdata;
       let state = this._statesToRestore[restoreID];
       this.loadOneWindow(state, "windowopenedbytabmix");
@@ -699,6 +702,9 @@ TabmixSessionManager = {
       delete this._statesToRestore[restoreID];
       delete window.tabmixdata;
     }
+    if (TabmixSvc.sm.windowToFocus && TabmixSvc.sm.windowToFocus == window) {
+      delete TabmixSvc.sm.windowToFocus;
+    }
   },
 
   // XXX split this for each pref that has change
@@ -2678,6 +2684,7 @@ TabmixSessionManager = {
     }
 
     var rdfNodeThisWindow = this.RDFService.GetResource(winPath);
+    this.setLiteral(rdfNodeThisWindow, "SSi", window.__SSi);
     if (this.prefBranch.getBoolPref("save.selectedtab")) // save selected tab index
       this.setIntLiteral(rdfNodeThisWindow, "selectedIndex", this.getTabPosition());
 
@@ -3133,7 +3140,10 @@ TabmixSessionManager = {
       windowsList.push(win);
     }
 
-    state.windows.forEach(winData => {
+    if (!state.selectedWindow || state.selectedWindow > state.windows.length) {
+      state.selectedWindow = 0;
+    }
+    state.windows.forEach((winData, index) => {
       winData.tabsRemoved = tabsRemoved;
       sessionCount++;
       let win = windowsList.pop();
@@ -3146,7 +3156,11 @@ TabmixSessionManager = {
           win.TabmixSessionManager.saveOneWindow(this.gSessionPath[0], "", true);
         win.TabmixSessionManager.loadOneWindow(winData, caller);
       } else {
-        this.openNewWindow(winData, this.isPrivateWindow);
+        win = this.openNewWindow(winData, this.isPrivateWindow);
+      }
+      if (index == state.selectedWindow - 1) {
+        win.focus();
+        TabmixSvc.sm.windowToFocus = win;
       }
     });
     // cloes extra windows if we overwrite open windows and set dontLoad==true
@@ -3177,7 +3191,8 @@ TabmixSessionManager = {
         this.saveOneWindow(this.gSessionPath[0], "", true);
       this.loadOneWindow(winData, "openclosedwindow");
     } else {
-      this.openNewWindow(winData, this.isPrivateWindow);
+      let win = this.openNewWindow(winData, this.isPrivateWindow);
+      TabmixSvc.sm.windowToFocus = win;
     }
   },
 
@@ -3200,6 +3215,7 @@ TabmixSessionManager = {
     } while (ID in this._statesToRestore);
     this._statesToRestore[ID] = aState;
     newWindow.tabmixdata = {restoreID: ID};
+    return newWindow;
   },
 
   loadOneWindow: function SM_loadOneWindow(winData, caller) {
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index bedd63b..5ebd4ed 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -728,6 +728,7 @@ var TabmixConvertSession = { // jshint ignore:line
   getSessionState: function cs_getSessionState(aPath, internal) {
     var _windows = [], tabsCount = 0;
     var sessionEnum = TabmixSessionManager.initContainer(aPath).GetElements();
+    let index = 0;
     while (sessionEnum.hasMoreElements()) {
       let rdfNodeWindow = sessionEnum.getNext();
       if (rdfNodeWindow instanceof Ci.nsIRDFResource) {
@@ -736,12 +737,19 @@ var TabmixConvertSession = { // jshint ignore:line
           continue;
         let aWindowState = this.getWindowState(rdfNodeWindow, internal);
         if (aWindowState) {// don't save empty windows
+          aWindowState.index = TabmixSessionManager.getLiteralValue(rdfNodeWindow, "SSi", index++);
           _windows.push(aWindowState);
           tabsCount += aWindowState.tabs.length;
         }
       }
     }
-    return {windows: _windows, selectedWindow: 1, tabsCount: tabsCount};
+    let selected = _windows[_windows.length - 1];
+    _windows.sort((a, b) => a.index > b.index);
+    return {
+      windows: _windows,
+      selectedWindow: _windows.indexOf(selected) + 1,
+      tabsCount: tabsCount,
+    };
   },
 
   getWindowState: function cs_getWindowState(rdfNodeWindow, internal) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list