diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2012-07-04 21:43:05 +0800 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2012-10-11 18:37:59 +0800 |
commit | 357d3270fa5dc65e99cda695752939996e998534 (patch) | |
tree | a9a15b5927c852a2c2d3206de691de261f6ddfb2 /src | |
parent | 45cadd35c88699e4483f7934aaad7b2ddc0aa3c8 (diff) | |
download | gsoc2013-epiphany-357d3270fa5dc65e99cda695752939996e998534.tar.gz gsoc2013-epiphany-357d3270fa5dc65e99cda695752939996e998534.tar.zst gsoc2013-epiphany-357d3270fa5dc65e99cda695752939996e998534.zip |
ephy-window: Port button press actions to WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=679395
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-window.c | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c index 2295aa622..7b1d87b5b 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -363,6 +363,7 @@ struct _EphyWindowPrivate EphyWebViewChrome chrome; EphyWebViewChrome pre_fullscreen_chrome; EphyEmbedEvent *context_event; + WebKitHitTestResult *hit_test_result; guint idle_worker; GtkWidget *downloads_box; @@ -2225,14 +2226,14 @@ ephy_window_dom_mouse_click_cb (WebKitWebView *view, GdkEventButton *event, EphyWindow *window) { -#ifdef HAVE_WEBKIT2 - /* TODO: Button press actions */ - return FALSE; -#else WebKitHitTestResult *hit_test_result; gboolean handled = FALSE; +#ifdef HAVE_WEBKIT2 + hit_test_result = g_object_ref (window->priv->hit_test_result); +#else hit_test_result = webkit_web_view_get_hit_test_result (view, event); +#endif switch (event->button) { @@ -2242,10 +2243,12 @@ ephy_window_dom_mouse_click_cb (WebKitWebView *view, case GDK_BUTTON_MIDDLE: handled = open_selected_url (window, view, event, hit_test_result); break; +#ifndef HAVE_WEBKIT2 case GDK_BUTTON_SECONDARY: show_embed_popup (window, view, event, hit_test_result); handled = TRUE; break; +#endif default: break; } @@ -2253,9 +2256,23 @@ ephy_window_dom_mouse_click_cb (WebKitWebView *view, g_object_unref (hit_test_result); return handled; -#endif } +#ifdef HAVE_WEBKIT2 +static void +ephy_window_mouse_target_changed_cb (WebKitWebView *web_view, + WebKitHitTestResult *hit_test_result, + guint modifiers, + EphyWindow *window) +{ + EphyWindowPrivate *priv = window->priv; + + if (priv->hit_test_result) + g_object_unref (hit_test_result); + priv->hit_test_result = g_object_ref (hit_test_result); +} +#endif + static void ephy_window_visibility_cb (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) { @@ -2814,6 +2831,17 @@ ephy_window_connect_active_embed (EphyWindow *window) g_signal_connect_object (view, "notify::is-blank", G_CALLBACK (sync_tab_is_blank), window, 0); +#ifdef HAVE_WEBKIT2 + g_signal_connect_object (view, "button-press-event", + G_CALLBACK (ephy_window_dom_mouse_click_cb), + window, 0); + g_signal_connect_object (view, "context-menu", + G_CALLBACK (populate_context_menu), + window, 0); + g_signal_connect_object (view, "mouse-target-changed", + G_CALLBACK (ephy_window_mouse_target_changed_cb), + window, 0); +#else /* We run our button-press-event after the default * handler to make sure pages have a chance to perform * their own handling - for instance, have their own @@ -2822,10 +2850,6 @@ ephy_window_connect_active_embed (EphyWindow *window) g_signal_connect_object (view, "button-press-event", G_CALLBACK (ephy_window_dom_mouse_click_cb), window, G_CONNECT_AFTER); -#ifdef HAVE_WEBKIT2 - g_signal_connect_object (view, "context-menu", - G_CALLBACK (populate_context_menu), - window, 0); #endif g_signal_connect_object (view, "notify::visibility", G_CALLBACK (ephy_window_visibility_cb), @@ -2941,6 +2965,9 @@ ephy_window_disconnect_active_embed (EphyWindow *window) g_signal_handlers_disconnect_by_func (view, G_CALLBACK (populate_context_menu), window); + g_signal_handlers_disconnect_by_func (view, + G_CALLBACK (ephy_window_mouse_target_changed_cb), + window); #endif } @@ -3458,6 +3485,8 @@ ephy_window_dispose (GObject *object) priv->manager = NULL; _ephy_window_set_context_event (window, NULL); + + g_clear_object (&priv->hit_test_result); } G_OBJECT_CLASS (ephy_window_parent_class)->dispose (object); |