OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tabs/tab_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
10 #include "app/gfx/path.h" | 10 #include "app/gfx/path.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 | 212 |
213 /////////////////////////////////////////////////////////////////////////////// | 213 /////////////////////////////////////////////////////////////////////////////// |
214 // TabGtk, MessageLoop::Observer implementation: | 214 // TabGtk, MessageLoop::Observer implementation: |
215 | 215 |
216 void TabGtk::WillProcessEvent(GdkEvent* event) { | 216 void TabGtk::WillProcessEvent(GdkEvent* event) { |
217 // Nothing to do. | 217 // Nothing to do. |
218 } | 218 } |
219 | 219 |
220 void TabGtk::DidProcessEvent(GdkEvent* event) { | 220 void TabGtk::DidProcessEvent(GdkEvent* event) { |
221 if (event->type != GDK_MOTION_NOTIFY) | 221 if (!(event->type == GDK_MOTION_NOTIFY || event->type == GDK_LEAVE_NOTIFY || |
| 222 event->type == GDK_ENTER_NOTIFY)) { |
222 return; | 223 return; |
| 224 } |
223 | 225 |
224 if (drag_widget_) { | 226 if (drag_widget_) { |
225 delegate_->ContinueDrag(NULL); | 227 delegate_->ContinueDrag(NULL); |
226 return; | 228 return; |
227 } | 229 } |
228 | 230 |
229 GdkEventMotion* motion = reinterpret_cast<GdkEventMotion*>(event); | 231 gint old_x = static_cast<gint>(last_mouse_down_->button.x_root); |
230 GdkEventButton* button = reinterpret_cast<GdkEventButton*>(last_mouse_down_); | 232 gint old_y = static_cast<gint>(last_mouse_down_->button.y_root); |
231 bool dragging = gtk_drag_check_threshold(widget(), | 233 gdouble new_x; |
232 static_cast<gint>(button->x), | 234 gdouble new_y; |
233 static_cast<gint>(button->y), | 235 gdk_event_get_root_coords(event, &new_x, &new_y); |
234 static_cast<gint>(motion->x), | 236 |
235 static_cast<gint>(motion->y)); | 237 if (gtk_drag_check_threshold(widget(), old_x, old_y, |
236 if (dragging) { | 238 static_cast<gint>(new_x), static_cast<gint>(new_y))) { |
237 StartDragging(gfx::Point(static_cast<int>(button->x), | 239 StartDragging(gfx::Point( |
238 static_cast<int>(button->y))); | 240 static_cast<int>(last_mouse_down_->button.x), |
| 241 static_cast<int>(last_mouse_down_->button.y))); |
239 } | 242 } |
240 } | 243 } |
241 | 244 |
242 /////////////////////////////////////////////////////////////////////////////// | 245 /////////////////////////////////////////////////////////////////////////////// |
243 // TabGtk, TabRendererGtk overrides: | 246 // TabGtk, TabRendererGtk overrides: |
244 | 247 |
245 bool TabGtk::IsSelected() const { | 248 bool TabGtk::IsSelected() const { |
246 return delegate_->IsTabSelected(this); | 249 return delegate_->IsTabSelected(this); |
247 } | 250 } |
248 | 251 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 gdk_event_free(last_mouse_down_); | 340 gdk_event_free(last_mouse_down_); |
338 last_mouse_down_ = NULL; | 341 last_mouse_down_ = NULL; |
339 } | 342 } |
340 | 343 |
341 // Notify the drag helper that we're done with any potential drag operations. | 344 // Notify the drag helper that we're done with any potential drag operations. |
342 // Clean up the drag helper, which is re-created on the next mouse press. | 345 // Clean up the drag helper, which is re-created on the next mouse press. |
343 delegate_->EndDrag(canceled); | 346 delegate_->EndDrag(canceled); |
344 | 347 |
345 MessageLoopForUI::current()->RemoveObserver(this); | 348 MessageLoopForUI::current()->RemoveObserver(this); |
346 } | 349 } |
OLD | NEW |