[polari] mainWindow: Try harder to keep focus on the main entry



commit 5a50f25d5a628159a4323660c4cfc156b58e5be1
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Oct 11 23:10:30 2013 +0200

    mainWindow: Try harder to keep focus on the main entry
    
    In general, we want the keyboard focus to remain on the main entry
    so users don't have to explicitly focus it to write a message. The
    only exceptions are:
    
     - focusing a different entry (nick entry, user list filter in the
       future)
     - using keynav
    
    Unfortunately many widgets will grab the keyboard focus when activated,
    and making them unfocusable would break accessibility. So resort to
    a hack which forces focus back to the entry unless we detect one of
    the exceptions above.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709950

 src/mainWindow.js |   11 +++++++++++
 src/roomList.js   |    4 +++-
 2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 5ae6792..e32ab97 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -95,6 +95,17 @@ const MainWindow = new Lang.Class({
                 this._ircParser.process(this._entry.text);
                 this._entry.text = '';
             }));
+        this._entry.connect('notify::is-focus', Lang.bind(this,
+            function() {
+                // HACK: force focus to the entry unless it was
+                //       moved by keynav or moved to another entry
+                if (this.window.get_focus() instanceof Gtk.Entry)
+                    return;
+                let device = Gtk.get_current_event_device();
+                if (!device || device.get_source() == Gdk.InputSource.KEYBOARD)
+                    return;
+                this._entry.grab_focus();
+            }));
 
         this._nickEntry.connect('activate', Lang.bind(this,
             function() {
diff --git a/src/roomList.js b/src/roomList.js
index 7d4e312..23107da 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -217,10 +217,12 @@ const RoomList = new Lang.Class({
                 return c.visible;
             });
             if (visibleChildren.length > 1) {
+                row.can_focus = false;
                 this.widget.select_row(row);
+                row.can_focus = true;
                 let count = row.get_index() == 0 ? 1 : -1;
                 this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, count);
-                newActive = this.widget.get_focus_child().room;
+                newActive = this.widget.get_selected_row().room;
             }
             this._roomManager.setActiveRoom(newActive);
             if (selected != row)


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