OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/back_forward_button_gtk.h" | 5 #include "chrome/browser/ui/gtk/back_forward_button_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, | 99 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, |
100 GdkEventButton* event) { | 100 GdkEventButton* event) { |
101 if (event->button == 3) | 101 if (event->button == 3) |
102 ShowBackForwardMenu(event->button, event->time); | 102 ShowBackForwardMenu(event->button, event->time); |
103 | 103 |
104 if (event->button != 1) | 104 if (event->button != 1) |
105 return FALSE; | 105 return FALSE; |
106 | 106 |
107 y_position_of_last_press_ = static_cast<int>(event->y); | 107 y_position_of_last_press_ = static_cast<int>(event->y); |
108 MessageLoop::current()->PostDelayedTask( | 108 base::MessageLoop::current()->PostDelayedTask( |
109 FROM_HERE, | 109 FROM_HERE, |
110 base::Bind(&BackForwardButtonGtk::ShowBackForwardMenu, | 110 base::Bind(&BackForwardButtonGtk::ShowBackForwardMenu, |
111 weak_factory_.GetWeakPtr(), | 111 weak_factory_.GetWeakPtr(), |
112 event->button, | 112 event->button, |
113 event->time), | 113 event->time), |
114 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); | 114 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); |
115 return FALSE; | 115 return FALSE; |
116 } | 116 } |
117 | 117 |
118 gboolean BackForwardButtonGtk::OnMouseMove(GtkWidget* widget, | 118 gboolean BackForwardButtonGtk::OnMouseMove(GtkWidget* widget, |
119 GdkEventMotion* event) { | 119 GdkEventMotion* event) { |
120 // If we aren't waiting to show the back forward menu, do nothing. | 120 // If we aren't waiting to show the back forward menu, do nothing. |
121 if (!weak_factory_.HasWeakPtrs()) | 121 if (!weak_factory_.HasWeakPtrs()) |
122 return FALSE; | 122 return FALSE; |
123 | 123 |
124 // We only count moves about a certain threshold. | 124 // We only count moves about a certain threshold. |
125 GtkSettings* settings = gtk_widget_get_settings(widget); | 125 GtkSettings* settings = gtk_widget_get_settings(widget); |
126 int drag_min_distance; | 126 int drag_min_distance; |
127 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); | 127 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); |
128 if (event->y - y_position_of_last_press_ < drag_min_distance) | 128 if (event->y - y_position_of_last_press_ < drag_min_distance) |
129 return FALSE; | 129 return FALSE; |
130 | 130 |
131 // We will show the menu now. Cancel the delayed event. | 131 // We will show the menu now. Cancel the delayed event. |
132 weak_factory_.InvalidateWeakPtrs(); | 132 weak_factory_.InvalidateWeakPtrs(); |
133 ShowBackForwardMenu(/* button */ 1, event->time); | 133 ShowBackForwardMenu(/* button */ 1, event->time); |
134 return FALSE; | 134 return FALSE; |
135 } | 135 } |
OLD | NEW |