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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 // Widgets that it uses. | 2289 // Widgets that it uses. |
2290 if (widget && widget->native_widget_private()->GetTooltipManager()) | 2290 if (widget && widget->native_widget_private()->GetTooltipManager()) |
2291 widget->native_widget_private()->GetTooltipManager()->UpdateTooltip(); | 2291 widget->native_widget_private()->GetTooltipManager()->UpdateTooltip(); |
2292 } | 2292 } |
2293 | 2293 |
2294 // Drag and drop --------------------------------------------------------------- | 2294 // Drag and drop --------------------------------------------------------------- |
2295 | 2295 |
2296 bool View::DoDrag(const ui::LocatedEvent& event, | 2296 bool View::DoDrag(const ui::LocatedEvent& event, |
2297 const gfx::Point& press_pt, | 2297 const gfx::Point& press_pt, |
2298 ui::DragDropTypes::DragEventSource source) { | 2298 ui::DragDropTypes::DragEventSource source) { |
2299 #if !defined(OS_MACOSX) | |
2300 int drag_operations = GetDragOperations(press_pt); | 2299 int drag_operations = GetDragOperations(press_pt); |
2301 if (drag_operations == ui::DragDropTypes::DRAG_NONE) | 2300 if (drag_operations == ui::DragDropTypes::DRAG_NONE) |
2302 return false; | 2301 return false; |
2303 | 2302 |
2304 Widget* widget = GetWidget(); | 2303 Widget* widget = GetWidget(); |
2305 // We should only start a drag from an event, implying we have a widget. | 2304 // We should only start a drag from an event, implying we have a widget. |
2306 DCHECK(widget); | 2305 DCHECK(widget); |
2307 | 2306 |
2308 // Don't attempt to start a drag while in the process of dragging. This is | 2307 // Don't attempt to start a drag while in the process of dragging. This is |
2309 // especially important on X where we can get multiple mouse move events when | 2308 // especially important on X where we can get multiple mouse move events when |
2310 // we start the drag. | 2309 // we start the drag. |
2311 if (widget->dragged_view()) | 2310 if (widget->dragged_view()) |
2312 return false; | 2311 return false; |
2313 | 2312 |
2314 OSExchangeData data; | 2313 OSExchangeData data; |
2315 WriteDragData(press_pt, &data); | 2314 WriteDragData(press_pt, &data); |
2316 | 2315 |
2317 // Message the RootView to do the drag and drop. That way if we're removed | 2316 // Message the RootView to do the drag and drop. That way if we're removed |
2318 // the RootView can detect it and avoid calling us back. | 2317 // the RootView can detect it and avoid calling us back. |
2319 gfx::Point widget_location(event.location()); | 2318 gfx::Point widget_location(event.location()); |
2320 ConvertPointToWidget(this, &widget_location); | 2319 ConvertPointToWidget(this, &widget_location); |
2321 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2320 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2322 // WARNING: we may have been deleted. | 2321 // WARNING: we may have been deleted. |
2323 return true; | 2322 return true; |
2324 #else | |
2325 return false; | |
2326 #endif // !defined(OS_MACOSX) | |
2327 } | 2323 } |
2328 | 2324 |
2329 } // namespace views | 2325 } // namespace views |
OLD | NEW |