[gnome-boxes/dont-grab-too-much-focus] wizard-window: Grab focus only once in "Download an OS" search



commit 62e51fb0855ee12f55a8bdc18287afca0802ba04
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon May 13 13:14:19 2019 +0200

    wizard-window: Grab focus only once in "Download an OS" search
    
    We provide some sort of "type-ahead" search in the "Download an OS"
    page, where users can just type any letter in their keyboard and that
    will perform a search in the available OSes for Download.
    
    When a new key is pressed, the key-press-event handler was constantly
    calling downloads_search.grab_focus (), which makes the GtkSearchEntry
    select its text, causing any following key presses to overwrite the
    existing ones.
    
    The solution to this issue is to only grab_focus () the search
    entry when it doesn't have focus yet. In other words:
    
    if (!downloads_search.has_focus) {
        downloads_search.grab_focus ();
    }
    
    Fixes #357

 src/wizard-window.vala | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/wizard-window.vala b/src/wizard-window.vala
index cd0f36ee..a45baab7 100644
--- a/src/wizard-window.vala
+++ b/src/wizard-window.vala
@@ -194,11 +194,13 @@ private bool on_key_pressed (Widget widget, Gdk.EventKey event) {
         }
 
         if (page == WizardWindowPage.DOWNLOADS) {
-            topbar.downloads_search.grab_focus ();
+            if (!topbar.downloads_search.has_focus)
+                topbar.downloads_search.grab_focus ();
 
             return topbar.downloads_search.key_press_event (event);
         }
 
+
         return false;
     }
 


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