[gnome-shell] status/keyboard: When per-window, choose the first IS for new windows



commit 4e52ed9df7140e586ad5bffae6ed498e0a3852e1
Author: Rui Matos <tiagomatos gmail com>
Date:   Wed Mar 11 15:48:03 2015 +0100

    status/keyboard: When per-window, choose the first IS for new windows
    
    This was libgnomekbd's behavior and seems to be prefered by users.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746037

 js/ui/status/keyboard.js |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 3179554..b5f53fd 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -475,13 +475,20 @@ const InputSourceManager = new Lang.Class({
     },
 
     _getNewInputSource: function(current) {
-        for (let i in this._inputSources) {
-            let is = this._inputSources[i];
-            if (is.type == current.type &&
-                is.id == current.id)
-                return is;
+        let sourceIndexes = Object.keys(this._inputSources);
+        if (sourceIndexes.length == 0)
+            return null;
+
+        if (current) {
+            for (let i in this._inputSources) {
+                let is = this._inputSources[i];
+                if (is.type == current.type &&
+                    is.id == current.id)
+                    return is;
+            }
         }
-        return this._currentSource;
+
+        return this._inputSources[sourceIndexes[0]];
     },
 
     _getCurrentWindow: function() {
@@ -496,16 +503,13 @@ const InputSourceManager = new Lang.Class({
         if (!window)
             return;
 
-        if (!window._inputSources) {
-            window._inputSources = this._inputSources;
-            window._currentSource = this._currentSource;
-        } else if (window._inputSources == this._inputSources) {
-            window._currentSource.activate();
-        } else {
+        if (window._inputSources != this._inputSources) {
             window._inputSources = this._inputSources;
             window._currentSource = this._getNewInputSource(window._currentSource);
-            window._currentSource.activate();
         }
+
+        if (window._currentSource)
+            window._currentSource.activate();
     },
 
     _sourcesPerWindowChanged: function() {


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