OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gtk/back_forward_button_gtk.h" | 5 #include "chrome/browser/gtk/back_forward_button_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 // static | 104 // static |
105 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, | 105 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, |
106 GdkEventButton* event, BackForwardButtonGtk* button) { | 106 GdkEventButton* event, BackForwardButtonGtk* button) { |
107 if (event->button == 3) | 107 if (event->button == 3) |
108 button->ShowBackForwardMenu(); | 108 button->ShowBackForwardMenu(); |
109 | 109 |
110 if (event->button != 1) | 110 if (event->button != 1) |
111 return FALSE; | 111 return FALSE; |
112 | 112 |
113 button->y_position_of_last_press_ = static_cast<int>(event->y); | 113 button->y_position_of_last_press_ = event->y; |
114 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 114 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
115 button->show_menu_factory_.NewRunnableMethod( | 115 button->show_menu_factory_.NewRunnableMethod( |
116 &BackForwardButtonGtk::ShowBackForwardMenu), | 116 &BackForwardButtonGtk::ShowBackForwardMenu), |
117 kMenuTimerDelay); | 117 kMenuTimerDelay); |
118 return FALSE; | 118 return FALSE; |
119 } | 119 } |
120 | 120 |
121 // static | 121 // static |
122 gboolean BackForwardButtonGtk::OnMouseMove(GtkWidget* widget, | 122 gboolean BackForwardButtonGtk::OnMouseMove(GtkWidget* widget, |
123 GdkEventMotion* event, BackForwardButtonGtk* button) { | 123 GdkEventMotion* event, BackForwardButtonGtk* button) { |
124 // If we aren't waiting to show the back forward menu, do nothing. | 124 // If we aren't waiting to show the back forward menu, do nothing. |
125 if (button->show_menu_factory_.empty()) | 125 if (button->show_menu_factory_.empty()) |
126 return FALSE; | 126 return FALSE; |
127 | 127 |
128 // We only count moves about a certain threshold. | 128 // We only count moves about a certain threshold. |
129 GtkSettings* settings = gtk_widget_get_settings(widget); | 129 GtkSettings* settings = gtk_widget_get_settings(widget); |
130 int drag_min_distance; | 130 int drag_min_distance; |
131 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); | 131 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); |
132 if (event->y - button->y_position_of_last_press_ < drag_min_distance) | 132 if (event->y - button->y_position_of_last_press_ < drag_min_distance) |
133 return FALSE; | 133 return FALSE; |
134 | 134 |
135 // We will show the menu now. Cancel the delayed event. | 135 // We will show the menu now. Cancel the delayed event. |
136 button->show_menu_factory_.RevokeAll(); | 136 button->show_menu_factory_.RevokeAll(); |
137 button->ShowBackForwardMenu(); | 137 button->ShowBackForwardMenu(); |
138 return FALSE; | 138 return FALSE; |
139 } | 139 } |
OLD | NEW |