 mozilla-embed.cpp |   51 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 37 insertions(+), 14 deletions(-)

--- mozilla/mozilla-embed.cpp
+++ mozilla/mozilla-embed.cpp
@@ -211,6 +211,33 @@
 }
 
 /**
+ * Hack: Whenever the *user* wants the focus on the embed there's always going
+ * to be an associated GdkEvent (click on embed, enter on location entry, etc...)
+ * If the event doesn't exist (none being processed at the moment) we'll assume
+ * it's Mozilla trying to steal the focus after done loading the page.  In that
+ * case stop the focus from moving anywhere.
+ *
+ * Yet another attempt to fix http://bugzilla.gnome.org/show_bug.cgi?id=72125
+ * and work around https://bugzilla.mozilla.org/show_bug.cgi?id=210373
+ */
+static void
+mozilla_embed_child_grab_focus_cb (GtkWidget *widget, MozillaEmbed *embed)
+{
+	GdkEvent *event;
+       
+	event = gtk_get_current_event ();
+
+	if (!event)
+	{
+		g_signal_stop_emission_by_name (widget, "grab-focus");
+	}
+	else
+	{
+		gdk_event_free (event);
+	}
+}
+
+/**
  *  Hack: We know that the parent class is really GtkBin object, so
  *  hook onto the "add" signal and connect appropriate signals for the
  *  child
@@ -222,11 +249,11 @@
 
 	GTK_CONTAINER_CLASS(parent_class)->add (container, widget);
 
-	g_signal_connect (widget, "scroll-event",
-			  G_CALLBACK (mozilla_embed_child_scroll_event_cb), embed);
-
-	g_signal_connect (widget, "event-after",
-			  G_CALLBACK (mozilla_embed_child_event_after_cb), embed);
+	g_object_connect (widget,
+			  "signal::scroll-event", mozilla_embed_child_scroll_event_cb, embed,
+			  "signal::event-after", mozilla_embed_child_event_after_cb, embed,
+			  "signal::grab-focus", mozilla_embed_child_grab_focus_cb, embed,
+			  NULL);
 }
 
 
@@ -238,15 +265,11 @@
 {
 	MozillaEmbed *embed = MOZILLA_EMBED (container);
 
-	g_signal_handlers_disconnect_by_func 
-		(widget,
-		 (gpointer)mozilla_embed_child_scroll_event_cb,
-		 embed);
-
-	g_signal_handlers_disconnect_by_func 
-		(widget,
-		 (gpointer)mozilla_embed_child_event_after_cb,
-		 embed);
+	g_object_disconnect (widget,
+			     "any_signal::scroll-event", mozilla_embed_child_scroll_event_cb, embed,
+			     "any_signal::event-after", mozilla_embed_child_event_after_cb, embed,
+			     "any_signal::grab-focus", mozilla_embed_child_grab_focus_cb, embed,
+			     NULL);
 
 	GTK_CONTAINER_CLASS(parent_class)->remove (container, widget);
 }
