[gnome-shell] lookingGlass: make Esc work on any page



commit bee37b5bc4aa89174b6dc56289383d0f5bb4a200
Author: Dan Winship <danw gnome org>
Date:   Wed Apr 20 12:41:22 2011 -0400

    lookingGlass: make Esc work on any page
    
    The lg window was losing focus when the page with the entry got unmapped;
    fix it to refocus itself after that.
    
    Fixing this problem revealed that previously we were focusing the
    entry on open(), but not ensuring that that page was selected, meaning
    you could type into the entry without being able to see it. Fix that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=647303

 js/ui/lookingGlass.js |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 2c97cc5..6e6e22a 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -5,6 +5,7 @@ const Cogl = imports.gi.Cogl;
 const GConf = imports.gi.GConf;
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
+const Gtk = imports.gi.Gtk;
 const Pango = imports.gi.Pango;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
@@ -100,12 +101,19 @@ Notebook.prototype = {
     selectIndex: function(index) {
         if (index == this._selectedIndex)
             return;
-        this._unselect();
         if (index < 0) {
+            this._unselect();
             this.emit('selection', null);
             return;
         }
+
+        // Focus the new tab before unmapping the old one
         let tabData = this._tabs[index];
+        if (!tabData.scrollView.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false))
+            this.actor.grab_key_focus();
+
+        this._unselect();
+
         tabData.labelBox.add_style_pseudo_class('selected');
         tabData.scrollView.show();
         this._selectedIndex = index;
@@ -745,12 +753,7 @@ LookingGlass.prototype = {
         let label = new St.Label({ text: 'js>>> ' });
         entryArea.add(label);
 
-        this._entry = new St.Entry();
-        /* unmapping the edit box will un-focus it, undo that */
-        notebook.connect('selection', Lang.bind(this, function (nb, child) {
-            if (child == this._evalBox)
-                global.stage.set_key_focus(this._entry);
-        }));
+        this._entry = new St.Entry({ can_focus: true });
         entryArea.add(this._entry, { expand: true });
 
         this._windowList = new WindowList();
@@ -909,6 +912,7 @@ LookingGlass.prototype = {
         if (!Main.pushModal(this._entry))
             return;
 
+        this._notebook.selectIndex(0);
         this.actor.show();
         this.actor.lower(Main.chrome.actor);
         this._open = true;



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