Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1118)

Unified Diff: chrome/common/gtk_util.cc

Issue 131071: Implement window open disposition for (some) navigation buttons.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: bool->int Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/gtk_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/gtk_util.cc
===================================================================
--- chrome/common/gtk_util.cc (revision 18718)
+++ chrome/common/gtk_util.cc (working copy)
@@ -19,6 +19,31 @@
gtk_container_remove(GTK_CONTAINER(container), widget);
}
+// These two functions are copped almost directly from gtk core. The only
+// difference is that they accept middle clicks.
+gboolean OnMouseButtonPressed(GtkWidget* widget, GdkEventButton* event,
+ gpointer unused) {
+ if (event->type == GDK_BUTTON_PRESS) {
+ if (gtk_button_get_focus_on_click(GTK_BUTTON(widget)) &&
+ !GTK_WIDGET_HAS_FOCUS(widget)) {
+ gtk_widget_grab_focus(widget);
+ }
+
+ if (event->button == 1 || event->button == 2)
+ gtk_button_pressed(GTK_BUTTON(widget));
+ }
+
+ return TRUE;
+}
+
+gboolean OnMouseButtonReleased(GtkWidget* widget, GdkEventButton* event,
+ gpointer unused) {
+ if (event->button == 1 || event->button == 2)
+ gtk_button_released(GTK_BUTTON(widget));
+
+ return TRUE;
+}
+
} // namespace
namespace event_utils {
@@ -207,4 +232,13 @@
g_list_free(stack);
}
+void SetButtonTriggersNavigation(GtkWidget* button) {
+ // We handle button activation manually because we want to accept middle mouse
+ // clicks.
+ g_signal_connect(G_OBJECT(button), "button-press-event",
+ G_CALLBACK(OnMouseButtonPressed), NULL);
+ g_signal_connect(G_OBJECT(button), "button-release-event",
+ G_CALLBACK(OnMouseButtonReleased), NULL);
+}
+
} // namespace gtk_util
« no previous file with comments | « chrome/common/gtk_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698