[gnome-maps/wip/mlundblad/touch-search-fixes] mainWindow: Don't focus search entry by default



commit fd9836a66147fe4742a96668b4124d68e345c4fe
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Aug 8 21:45:37 2017 +0200

    mainWindow: Don't focus search entry by default
    
    Focusing the search entry by default makes the OSK come up
    on touch devices when launching when no physical keyboard is available.
    Instead focus it in the key press handler when no other entry is focused
    (and propagate the event in there).

 src/mainWindow.js |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index fd97733..7085380 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -271,21 +271,23 @@ const MainWindow = new Lang.Class({
          * hijack the key-press to the main window and make sure that
          * they reach the entry before they can be swallowed as accelerator.
          */
-        this.connect('key-press-event', function(window, event) {
+        this.connect('key-press-event', (function(window, event) {
             let focusWidget = window.get_focus();
             let keyval = event.get_keyval()[1];
             let keys = [Gdk.KEY_plus,
                         Gdk.KEY_minus,
                         Gdk.KEY_equal];
 
-            if (!(focusWidget instanceof Gtk.Entry))
-                return false;
+            if (!(focusWidget instanceof Gtk.Entry)) {
+                this._placeEntry.has_focus = true;
+                focusWidget = this._placeEntry;
+            }
 
             if (keys.indexOf(keyval) !== -1)
                 return focusWidget.event(event);
 
             return false;
-        });
+        }).bind(this));
     },
 
     _updateLocationSensitivity: function() {
@@ -299,7 +301,6 @@ const MainWindow = new Lang.Class({
     _initHeaderbar: function() {
         this._placeEntry = this._createPlaceEntry();
         this._headerBar.custom_title = this._placeEntry;
-        this._placeEntry.has_focus = true;
 
         let favoritesPopover = this._favoritesButton.popover;
         this._favoritesButton.sensitive = favoritesPopover.rows > 0;


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