diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | NEWS | 13 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 27 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 7 | ||||
-rw-r--r-- | embed/mozilla/Makefile.am | 2 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 97 | ||||
-rw-r--r-- | src/ephy-shell.c | 46 | ||||
-rw-r--r-- | src/ephy-window.c | 10 |
9 files changed, 210 insertions, 12 deletions
@@ -1,3 +1,20 @@ +2005-08-17 Marco Pesenti Gritti <mpg@redhat.com> + + * NEWS + * configure.in: + + Release 1.4.9 + + * embed/mozilla/EphyBrowser.cpp: + * embed/mozilla/EphyBrowser.h: + * embed/mozilla/Makefile.am: + * embed/mozilla/mozilla-embed.cpp: + * src/ephy-shell.c: (url_is_empty), (load_homepage), + (ephy_shell_new_tab): + * src/ephy-window.c: (ephy_window_load_url): + + Back port focus fixes from 2.10 branch + 2005-08-17 Christian Persch <chpe@cvs.gnome.org> * lib/egg/egg-editable-toolbar.c: (new_pixbuf_from_widget), @@ -1,4 +1,17 @@ ============== +Epiphany 1.4.9 +============== + +Changes + + * Fix several focus issues (some with security implications) + * Fix crash when updating tray icon + * Fix lock up with the move cursor showing + * Fix some leaks + * Fix getting the trust setting from New CA dialogue + * Don't activate the location entry if it's hidden + +============== Epiphany 1.4.8 ============== diff --git a/configure.in b/configure.in index 1e4a77d94..8394a9578 100644 --- a/configure.in +++ b/configure.in @@ -402,6 +402,9 @@ if test "x$filepicker" = "xyes"; then AC_DEFINE([ENABLE_FILEPICKER],[1],[Define to enable the native filepicker]) fi +dnl Broken everywhere +AC_DEFINE([GTKMOZEMBED_BROKEN_FOCUS],[1],[Define if GtkMozEmbed has broken focus handling]) + dnl ******************************* dnl Internationalization dnl ******************************* diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 1972f8fbb..52b83cb44 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -351,6 +351,9 @@ nsresult EphyBrowser::Init (GtkMozEmbed *mozembed) getter_AddRefs(mWebBrowser)); NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE); + mWebBrowserFocus = do_QueryInterface (mWebBrowser); + NS_ENSURE_TRUE (mWebBrowserFocus, NS_ERROR_FAILURE); + mWebBrowser->GetContentDOMWindow (getter_AddRefs (mDOMWindow)); NS_ENSURE_TRUE (mDOMWindow, NS_ERROR_FAILURE); @@ -661,13 +664,9 @@ nsresult EphyBrowser::GetTargetDocument (nsIDOMDocument **aDOMDocument) } /* Use the focused document */ - nsCOMPtr<nsIWebBrowserFocus> webBrowserFocus; - webBrowserFocus = do_QueryInterface (mWebBrowser); - NS_ENSURE_TRUE (webBrowserFocus, NS_ERROR_FAILURE); - nsresult rv; nsCOMPtr<nsIDOMWindow> DOMWindow; - rv = webBrowserFocus->GetFocusedWindow (getter_AddRefs(DOMWindow)); + rv = mWebBrowserFocus->GetFocusedWindow (getter_AddRefs(DOMWindow)); if (NS_SUCCEEDED (rv) && DOMWindow) { return DOMWindow->GetDocument (aDOMDocument); @@ -1131,3 +1130,21 @@ EphyBrowser::ShowCertificate () return NS_OK; #endif } + +#ifdef GTKMOZEMBED_BROKEN_FOCUS +nsresult +EphyBrowser::FocusActivate () +{ + NS_ENSURE_STATE (mWebBrowserFocus); + + return mWebBrowserFocus->Activate(); +} + +nsresult +EphyBrowser::FocusDeactivate () +{ + NS_ENSURE_STATE (mWebBrowserFocus); + + return mWebBrowserFocus->Deactivate(); +} +#endif /* GTKMOZEMBED_BROKEN_FOCUS */ diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index b61a88ec1..0e693f43d 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -35,6 +35,7 @@ #include <nsIWebNavigation.h> #include <nsISHistory.h> #include <nsIWebBrowser.h> +#include <nsIWebBrowserFocus.h> #include <nsIDOMDocument.h> #include <nsIDOMWindow.h> #include <nsIPrintSettings.h> @@ -149,10 +150,16 @@ public: nsresult GetSecurityInfo (PRUint32 *aState, nsACString &aDescription); nsresult ShowCertificate (); +#ifdef GTKMOZEMBED_BROKEN_FOCUS + nsresult FocusActivate (); + nsresult FocusDeactivate (); +#endif + nsCOMPtr<nsIWebBrowser> mWebBrowser; private: GtkWidget *mEmbed; + nsCOMPtr<nsIWebBrowserFocus> mWebBrowserFocus; nsCOMPtr<nsIDOMDocument> mTargetDocument; nsCOMPtr<nsIDOMEventTarget> mEventTarget; nsCOMPtr<nsIDOMWindow> mDOMWindow; diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am index 029956db0..a704fcd7d 100644 --- a/embed/mozilla/Makefile.am +++ b/embed/mozilla/Makefile.am @@ -42,7 +42,7 @@ INCLUDES = \ if MAINTAINER_MODE INCLUDES += -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGNOME_DISABLE_DEPRECATED -DBONOBO_DISABLE_DEPRECATED $(MOZILLA_WARN_CXXFLAGS) + -DBONOBO_DISABLE_DEPRECATED $(MOZILLA_WARN_CXXFLAGS) endif noinst_LTLIBRARIES = libephymozillaembed.la diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 977d04c50..ff930316f 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -92,12 +92,20 @@ struct MozillaEmbedPrivate { EphyBrowser *browser; MozillaEmbedLoadState load_state; +#ifdef GTKMOZEMBED_BROKEN_FOCUS + guint focus_connected : 1; +#endif /* GTKMOZEMBED_BROKEN_FOCUS */ }; #define WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1" static GObjectClass *parent_class = NULL; +#ifdef GTKMOZEMBED_BROKEN_FOCUS +static guint fiesid = 0; +static guint foesid = 0; +#endif /* GTKMOZEMBED_BROKEN_FOCUS */ + static void impl_manager_do_command (EphyCommandManager *manager, const char *command) @@ -211,20 +219,98 @@ impl_find_set_properties (EphyEmbed *embed, wrap_around); } +#ifdef GTKMOZEMBED_BROKEN_FOCUS +static gboolean +child_focus_in_event_cb (GtkWidget *child, + GdkEventFocus *event, + MozillaEmbed *embed) +{ + embed->priv->browser->FocusActivate (); + + return FALSE; +} + +static gboolean +child_focus_out_event_cb (GtkWidget *child, + GdkEventFocus *event, + MozillaEmbed *embed) +{ + embed->priv->browser->FocusDeactivate (); + + return FALSE; +} +#endif /* GTKMOZEMBED_BROKEN_FOCUS */ + static void mozilla_embed_realize (GtkWidget *widget) { MozillaEmbedPrivate *mpriv = MOZILLA_EMBED (widget)->priv; + GtkBin *bin = GTK_BIN (widget); - (* GTK_WIDGET_CLASS(parent_class)->realize) (widget); + GTK_WIDGET_CLASS (parent_class)->realize (widget); + /* Initialise our helper class */ nsresult rv; rv = mpriv->browser->Init (GTK_MOZ_EMBED (widget)); - if (NS_FAILED (rv)) { - g_warning ("EphyBrowser initialization failed for %p\n", widget); + g_warning ("EphyBrowser initialization failed for %p\n", widget); + return; } + +#ifdef GTKMOZEMBED_BROKEN_FOCUS + /* HACK ALERT! This depends highly on undocumented interna of + * GtkMozEmbed! + * + * GtkMozEmbed::realize installs focus-[in|out]-event handlers to + * toplevel, and, on the first realize only, to the child. + * GtkMozEmbed disconnects its focus-[in|out]-event handler + * to the toplevel on unrealize, and leaves the ones to the child + * in place. So we don't need to unblock the blocked handlers + * and therefore need no ::unrealize handler. + */ + + GtkWidget *toplevel = gtk_widget_get_toplevel (widget); + gpointer data = ((GtkMozEmbed *) widget)->data; + + guint n; + + n = g_signal_handlers_block_matched (toplevel, + (GSignalMatchType) (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), + fiesid, 0, NULL, NULL, data); + n += g_signal_handlers_block_matched (toplevel, + (GSignalMatchType) (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), + foesid, 0, NULL, NULL, data); + if (n != 2) + { + g_warning ("Unexpected number (n=%d) of toplevel focus handlers found!\n", n); + } + + if (mpriv->focus_connected) return; + + GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); + g_return_if_fail (child != NULL); + + n = g_signal_handlers_block_matched (child, + (GSignalMatchType) (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), + fiesid, 0, NULL, NULL, widget); + n += g_signal_handlers_block_matched (child, + (GSignalMatchType) (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), + foesid, 0, NULL, NULL, widget); + if (n != 2) + { + g_warning ("Unexpected number (n=%d) of child focus handlers found!\n", n); + } + + g_signal_connect_object (child, "focus-in-event", + G_CALLBACK (child_focus_in_event_cb), widget, + G_CONNECT_AFTER); + g_signal_connect_object (child, "focus-out-event", + G_CALLBACK (child_focus_out_event_cb), widget, + G_CONNECT_AFTER); + + mpriv->focus_connected = TRUE; +#endif /* GTKMOZEMBED_BROKEN_FOCUS */ } static GObject * @@ -254,6 +340,11 @@ mozilla_embed_class_init (MozillaEmbedClass *klass) widget_class->realize = mozilla_embed_realize; +#ifdef GTKMOZEMBED_BROKEN_FOCUS + fiesid = g_signal_lookup ("focus-in-event", GTK_TYPE_WIDGET); + foesid = g_signal_lookup ("focus-out-event", GTK_TYPE_WIDGET); +#endif /* GTKMOZEMBED_BROKEN_FOCUS */ + g_type_class_add_private (object_class, sizeof(MozillaEmbedPrivate)); } diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 18162b015..a95b4b0b4 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -504,10 +504,25 @@ ephy_shell_new (void) return EPHY_SHELL (g_object_new (EPHY_TYPE_SHELL, NULL)); } -static void +static gboolean +url_is_empty (const char *location) +{ + gboolean is_empty = FALSE; + + if (location == NULL || location[0] == '\0' || + strcmp (location, "about:blank") == 0) + { + is_empty = TRUE; + } + + return is_empty; +} + +static gboolean load_homepage (EphyEmbed *embed) { char *home; + gboolean is_empty; home = eel_gconf_get_string(CONF_GENERAL_HOMEPAGE); @@ -518,9 +533,13 @@ load_homepage (EphyEmbed *embed) home = g_strdup ("about:blank"); } + is_empty = url_is_empty (home); + ephy_embed_load_url (embed, home); g_free (home); + + return is_empty; } /** @@ -550,6 +569,7 @@ ephy_shell_new_tab (EphyShell *shell, EphyEmbed *previous_embed = NULL; GtkWidget *nb; int position = -1; + gboolean is_empty = FALSE; Toolbar *toolbar; if (flags & EPHY_NEW_TAB_IN_NEW_WINDOW) in_new_window = TRUE; @@ -594,12 +614,13 @@ ephy_shell_new_tab (EphyShell *shell, { ephy_tab_set_location (tab, "", TAB_ADDRESS_EXPIRE_NEXT); toolbar_activate_location (toolbar); - load_homepage (embed); + is_empty = load_homepage (embed); } else if (flags & EPHY_NEW_TAB_OPEN_PAGE) { g_assert (url != NULL); ephy_embed_load_url (embed, url); + is_empty = url_is_empty (url); } if (flags & EPHY_NEW_TAB_FULLSCREEN_MODE) @@ -607,6 +628,27 @@ ephy_shell_new_tab (EphyShell *shell, gtk_window_fullscreen (GTK_WINDOW (window)); } + /* Make sure the initial focus is somewhere sensible and not, for + * example, on the reload button. + */ + if (in_new_window || jump_to) + { + /* If the location entry is blank, focus that, except if the + * page was a copy */ + if (is_empty) + { + /* empty page, focus location entry */ + toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window)); + toolbar_activate_location (toolbar); + } + else if (embed != NULL) + { + /* non-empty page, focus the page. but make sure the widget is realised first! */ + gtk_widget_realize (GTK_WIDGET (embed)); + ephy_embed_activate (embed); + } + } + return tab; } diff --git a/src/ephy-window.c b/src/ephy-window.c index b7c8adab5..c1a541b3e 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2687,7 +2687,15 @@ ephy_window_load_url (EphyWindow *window, g_return_if_fail (url != NULL); ephy_embed_load_url (embed, url); - ephy_embed_activate (embed); + + if (url == NULL || url[0] == '\0' || strcmp (url, "about:blank") == 0) + { + toolbar_activate_location (window->priv->toolbar); + } + else + { + ephy_embed_activate (embed); + } } /** |