From e81506ffe3645fcd3b36704345aafa9bae684fe3 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Tue, 14 Jun 2011 21:05:25 +0000 Subject: Handle button press event, part of OLPC #10623 (Daniel Drake) --- diff --git a/src/hulahop-web-view.cpp b/src/hulahop-web-view.cpp index 9104b20..d51401c 100644 --- a/src/hulahop-web-view.cpp +++ b/src/hulahop-web-view.cpp @@ -81,6 +81,20 @@ child_focus_out_cb(GtkWidget *widget, return FALSE; } +static gboolean +child_button_press_cb(GtkWidget *widget, + GdkEventFocus *event, + HulahopWebView *web_view) +{ + nsCOMPtr webBrowserFocus; + webBrowserFocus = do_QueryInterface(web_view->browser); + NS_ENSURE_TRUE(webBrowserFocus, FALSE); + + webBrowserFocus->Activate(); + + return FALSE; +} + static void hulahop_web_view_unrealize(GtkWidget *widget) { @@ -142,6 +156,24 @@ hulahop_web_view_realize(GtkWidget *widget) "focus-out-event", G_CALLBACK(child_focus_out_cb), web_view, (GConnectFlags)0); + + /* + * xulrunner-1.9.2 doesn't like receiving click events on text inputs + * without being told that it has been focused first. However, GTK+ + * sends button-press-event before focus-in-event, so we must use + * button-press-event to tell mozilla that it has been given focus. + * + * Ordinarily, mozilla would not let us bind to button_press_event here + * because it has it's own handler which stops emission of the signal + * (our handler would simply not be called). This workaround will only + * come into effect with a patched xulrunner at time of writing. + * + * See https://bugzilla.mozilla.org/show_bug.cgi?id=533245 + */ + g_signal_connect_object(web_view->mozilla_widget, + "button-press-event", + G_CALLBACK(child_button_press_cb), + web_view, (GConnectFlags)0); } static void -- cgit v0.9.1