[epiphany] Fix Authentication dialog loses focus when switching tabs



commit 2b3776d203ef74d38f0a3278a46661444a0f4f48
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Sat May 11 19:50:28 2019 +0200

    Fix Authentication dialog loses focus when switching tabs
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/750

 embed/ephy-web-view.c | 12 ++++++++++++
 embed/ephy-web-view.h |  2 ++
 src/ephy-notebook.c   |  3 ++-
 3 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 8b7ffe2ce..cbb3eb9a9 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -79,6 +79,7 @@ struct _EphyWebView {
   guint load_failed : 1;
   guint history_frozen : 1;
   guint ever_committed : 1;
+  guint in_auth_dialog : 1;
 
   char *address;
   char *display_address;
@@ -1909,6 +1910,8 @@ load_changed_cb (WebKitWebView  *web_view,
 
   g_object_freeze_notify (object);
 
+  view->in_auth_dialog = 0;
+
   switch (load_event) {
     case WEBKIT_LOAD_STARTED: {
       const char *loading_uri = NULL;
@@ -2887,6 +2890,7 @@ authenticate_cb (WebKitWebView               *web_view,
                  WebKitAuthenticationRequest *request,
                  gpointer                     user_data)
 {
+  EphyWebView *ephy_web_view = EPHY_WEB_VIEW (web_view);
   g_autoptr(WebKitCredential) credential = NULL;
 
   credential = webkit_authentication_request_get_proposed_credential (request);
@@ -2897,6 +2901,8 @@ authenticate_cb (WebKitWebView               *web_view,
     return TRUE;
   }
 
+  ephy_web_view->in_auth_dialog = 1;
+
   return FALSE;
 }
 
@@ -3948,3 +3954,9 @@ ephy_web_view_get_web_extension_proxy (EphyWebView *view)
 {
   return view->web_extension;
 }
+
+gboolean
+ephy_web_view_is_in_auth_dialog (EphyWebView *view)
+{
+  return view->in_auth_dialog;
+}
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index d20eb6b41..1c490ec7f 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -163,6 +163,8 @@ gboolean                   ephy_web_view_is_reader_mode_available (EphyWebView
 
 gboolean                   ephy_web_view_get_reader_mode_state    (EphyWebView               *view);
 
+gboolean                   ephy_web_view_is_in_auth_dialog        (EphyWebView               *view);
+
 EphyWebExtensionProxy     *ephy_web_view_get_web_extension_proxy  (EphyWebView               *view);
 
 void                       ephy_web_view_show_auth_form_save_request (EphyWebView                    
*web_view,
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 185ef48d4..ef8d56d9d 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -257,7 +257,8 @@ ephy_notebook_switch_page_cb (GtkNotebook *notebook,
   GtkWidget *child;
 
   child = gtk_notebook_get_nth_page (notebook, page_num);
-  gtk_widget_grab_focus (child);
+  if (!ephy_web_view_is_in_auth_dialog (ephy_embed_get_web_view (EPHY_EMBED (child))))
+    gtk_widget_grab_focus (child);
 
   /* Remove the old page, we dont want to grow unnecessarily
    * the list */


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