Return saved boolean from button_press in button_release

It may or may not happen that WebKit reacts on clicks
regardless of the boolean returned in button_press, as
a work-around button_release returns the same value now.

Fixes: https://bugs.launchpad.net/midori/+bug/707024
This commit is contained in:
Christian Dywan 2012-01-29 19:14:24 +01:00
parent e16e1d14d4
commit f0c4b3d538

View file

@ -79,6 +79,7 @@ struct _MidoriView
gchar* statusbar_text; gchar* statusbar_text;
WebKitHitTestResult* hit_test; WebKitHitTestResult* hit_test;
gchar* link_uri; gchar* link_uri;
gboolean button_press_handled;
gboolean has_selection; gboolean has_selection;
gchar* selected_text; gchar* selected_text;
MidoriWebSettings* settings; MidoriWebSettings* settings;
@ -1662,7 +1663,7 @@ midori_view_ensure_link_uri (MidoriView* view,
| GDK_MOD1_MASK | GDK_META_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK ) | GDK_MOD1_MASK | GDK_META_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK )
static gboolean static gboolean
gtk_widget_button_press_event_cb (WebKitWebView* web_view, midori_view_web_view_button_press_event_cb (WebKitWebView* web_view,
GdkEventButton* event, GdkEventButton* event,
MidoriView* view) MidoriView* view)
{ {
@ -1675,6 +1676,7 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
event->state = event->state & MIDORI_KEYS_MODIFIER_MASK; event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
midori_view_ensure_link_uri (view, NULL, NULL, event); midori_view_ensure_link_uri (view, NULL, NULL, event);
link_uri = midori_view_get_link_uri (view); link_uri = midori_view_get_link_uri (view);
view->button_press_handled = FALSE;
switch (event->button) switch (event->button)
{ {
@ -1692,12 +1694,14 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
if (MIDORI_MOD_BACKGROUND (event->state)) if (MIDORI_MOD_BACKGROUND (event->state))
background = !background; background = !background;
g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background); g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
view->button_press_handled = TRUE;
return TRUE; return TRUE;
} }
else if (MIDORI_MOD_NEW_WINDOW (event->state)) else if (MIDORI_MOD_NEW_WINDOW (event->state))
{ {
/* Open link in new window */ /* Open link in new window */
g_signal_emit (view, signals[NEW_WINDOW], 0, link_uri); g_signal_emit (view, signals[NEW_WINDOW], 0, link_uri);
view->button_press_handled = TRUE;
return TRUE; return TRUE;
} }
break; break;
@ -1712,6 +1716,7 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
if (MIDORI_MOD_BACKGROUND (event->state)) if (MIDORI_MOD_BACKGROUND (event->state))
background = !background; background = !background;
g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background); g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
view->button_press_handled = TRUE;
return TRUE; return TRUE;
} }
else if (MIDORI_MOD_SCROLL (event->state)) else if (MIDORI_MOD_SCROLL (event->state))
@ -1775,6 +1780,7 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
gtk_widget_grab_focus (GTK_WIDGET (view)); gtk_widget_grab_focus (GTK_WIDGET (view));
} }
g_free (uri); g_free (uri);
view->button_press_handled = TRUE;
return TRUE; return TRUE;
} }
} }
@ -1787,14 +1793,17 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
midori_view_populate_popup (view, menu, TRUE); midori_view_populate_popup (view, menu, TRUE);
katze_widget_popup (GTK_WIDGET (web_view), GTK_MENU (menu), event, katze_widget_popup (GTK_WIDGET (web_view), GTK_MENU (menu), event,
KATZE_MENU_POSITION_CURSOR); KATZE_MENU_POSITION_CURSOR);
view->button_press_handled = TRUE;
return TRUE; return TRUE;
} }
break; break;
case 8: case 8:
midori_view_go_back (view); midori_view_go_back (view);
view->button_press_handled = TRUE;
return TRUE; return TRUE;
case 9: case 9:
midori_view_go_forward (view); midori_view_go_forward (view);
view->button_press_handled = TRUE;
return TRUE; return TRUE;
/* /*
* On some fancier mice the scroll wheel can be used to scroll horizontally. * On some fancier mice the scroll wheel can be used to scroll horizontally.
@ -1804,8 +1813,8 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
* accidentally being interpreted as first button clicks. * accidentally being interpreted as first button clicks.
*/ */
case 11: case 11:
return TRUE;
case 12: case 12:
view->button_press_handled = TRUE;
return TRUE; return TRUE;
} }
@ -1815,6 +1824,17 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
return FALSE; return FALSE;
} }
static gboolean
midori_view_web_view_button_release_event_cb (WebKitWebView* web_view,
GdkEventButton* event,
MidoriView* view)
{
gboolean button_press_handled = view->button_press_handled;
view->button_press_handled = FALSE;
return button_press_handled;
}
static gboolean static gboolean
midori_view_inspector_window_key_press_event_cb (GtkWidget* window, midori_view_inspector_window_key_press_event_cb (GtkWidget* window,
GdkEventKey* event, GdkEventKey* event,
@ -3619,7 +3639,9 @@ midori_view_construct_web_view (MidoriView* view)
"signal::hovering-over-link", "signal::hovering-over-link",
webkit_web_view_hovering_over_link_cb, view, webkit_web_view_hovering_over_link_cb, view,
"signal::button-press-event", "signal::button-press-event",
gtk_widget_button_press_event_cb, view, midori_view_web_view_button_press_event_cb, view,
"signal::button-release-event",
midori_view_web_view_button_release_event_cb, view,
"signal-after::key-press-event", "signal-after::key-press-event",
gtk_widget_key_press_event_cb, view, gtk_widget_key_press_event_cb, view,
"signal::scroll-event", "signal::scroll-event",