[gnome-flashback] input-sources: do not grab keyboard with set-content-type



commit 028122a439f227a3c107b45d6d2a2f56b5144a8a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu May 2 16:58:47 2019 +0300

    input-sources: do not grab keyboard with set-content-type
    
    When gnome-flashback receives the signal of 'set-content-type' from ibus,
    gnome-flashback calls gf_keyboard_manager_grab() and gf_keyboard_manager_ungrab()
    and the functions change the current input focus in GNOME Xorg and it could
    result in closing a popup window which has a password entry by focusing on
    the entry.
    
    The solution is to stop to call the APIs on 'set-content-type' signal.
    
    Based on gnome-shell commit:
    https://gitlab.gnome.org/GNOME/gnome-shell/commit/551e827841626cd8
    
    https://gitlab.gnome.org/GNOME/gnome-flashback/issues/15

 .../libinput-sources/gf-input-source-manager.c      | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c 
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index 0343e11..619a689 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -70,6 +70,7 @@ struct _GfInputSourceManager
   GfIBusManager         *ibus_manager;
   gboolean               ibus_ready;
   gboolean               disable_ibus;
+  gboolean               reloading;
 
   GHashTable            *input_sources;
   GHashTable            *ibus_sources;
@@ -784,6 +785,9 @@ engine_set_cb (GfIBusManager *manager,
 
   source_manager = GF_INPUT_SOURCE_MANAGER (user_data);
 
+  if (source_manager->reloading)
+    return;
+
   gf_keyboard_manager_ungrab (source_manager->keyboard_manager,
                               GDK_CURRENT_TIME);
 }
@@ -835,7 +839,18 @@ activate_cb (GfInputSource        *source,
 
   xkb_id = gf_input_source_get_xkb_id (source);
 
-  gf_keyboard_manager_grab (manager->keyboard_manager, GDK_CURRENT_TIME);
+  /*
+   * The focus changes during grab/ungrab may trick the client into hiding
+   * UI containing the currently focused entry. So grab/ungrab are not called
+   * when 'set-content-type' signal is received. E.g. Focusing on a password
+   * entry in a popup in Xorg Firefox will emit 'set-content-type' signal.
+   *
+   * https://gitlab.gnome.org/GNOME/gnome-shell/issues/391
+   * https://gitlab.gnome.org/GNOME/gnome-flashback/issues/15
+   */
+  if (!manager->reloading)
+    gf_keyboard_manager_grab (manager->keyboard_manager, GDK_CURRENT_TIME);
+
   gf_keyboard_manager_apply (manager->keyboard_manager, xkb_id);
 
   if (manager->ibus_manager == NULL)
@@ -1561,12 +1576,16 @@ gf_input_source_manager_reload (GfInputSourceManager *manager)
 {
   gchar **options;
 
+  manager->reloading = TRUE;
+
   options = gf_input_source_settings_get_xkb_options (manager->settings);
 
   gf_keyboard_manager_set_xkb_options (manager->keyboard_manager, options);
   g_strfreev (options);
 
   sources_changed_cb (manager->settings, manager);
+
+  manager->reloading = FALSE;
 }
 
 GfInputSource *


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