diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/drag_utils.cc | 43 | ||||
-rw-r--r-- | ui/views/drag_utils.h | 30 | ||||
-rw-r--r-- | ui/views/views.gyp | 2 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 15 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 6 |
5 files changed, 82 insertions, 14 deletions
diff --git a/ui/views/drag_utils.cc b/ui/views/drag_utils.cc new file mode 100644 index 0000000..76a7dc3 --- /dev/null +++ b/ui/views/drag_utils.cc @@ -0,0 +1,43 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/views/drag_utils.h" + +#if defined(USE_AURA) +#include "ui/aura/client/drag_drop_client.h" +#include "ui/aura/root_window.h" +#include "ui/aura/window.h" +#elif defined(OS_WIN) +#include "ui/base/dragdrop/drag_drop_types.h" +#include "ui/base/dragdrop/drag_source.h" +#include "ui/base/dragdrop/os_exchange_data_provider_win.h" +#else +#error +#endif + +namespace views { + +void RunShellDrag(gfx::NativeView view, + const ui::OSExchangeData& data, + const gfx::Point& location, + int operation) { +#if defined(USE_AURA) + gfx::Point root_location(location); + aura::RootWindow* root_window = view->GetRootWindow(); + aura::Window::ConvertPointToWindow(view, root_window, &root_location); + if (aura::client::GetDragDropClient(root_window)) { + aura::client::GetDragDropClient(root_window)->StartDragAndDrop( + data, root_location, operation); + } +#elif defined(OS_WIN) + scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); + DWORD effects; + DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), + drag_source, + ui::DragDropTypes::DragOperationToDropEffect(operation), + &effects); +#endif +} + +} // namespace views diff --git a/ui/views/drag_utils.h b/ui/views/drag_utils.h new file mode 100644 index 0000000..5339f52 --- /dev/null +++ b/ui/views/drag_utils.h @@ -0,0 +1,30 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_DRAG_UTILS_H_ +#define UI_VIEWS_DRAG_UTILS_H_ +#pragma once + +#include "ui/gfx/native_widget_types.h" +#include "ui/views/views_export.h" + +namespace gfx { +class Point; +} + +namespace ui { +class OSExchangeData; +} + +namespace views { + +// Starts a drag operation. This blocks until the drag operation completes. +VIEWS_EXPORT void RunShellDrag(gfx::NativeView view, + const ui::OSExchangeData& data, + const gfx::Point& location, + int operation); + +} // namespace views + +#endif // UI_VIEWS_DRAG_UTILS_H_ diff --git a/ui/views/views.gyp b/ui/views/views.gyp index ca86f19..b7975e8 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -232,6 +232,8 @@ #'debug_utils.cc', #'debug_utils.h', 'drag_controller.h', + 'drag_utils.cc', + 'drag_utils.h', 'events/event.cc', 'events/event.h', 'events/event_aura.cc', diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 19292d5..116d6f1 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -27,6 +27,7 @@ #include "ui/gfx/compositor/layer.h" #include "ui/gfx/font.h" #include "ui/gfx/screen.h" +#include "ui/views/drag_utils.h" #include "ui/views/ime/input_method_bridge.h" #include "ui/views/widget/drop_helper.h" #include "ui/views/widget/native_widget_delegate.h" @@ -622,16 +623,10 @@ bool NativeWidgetAura::IsAccessibleWidget() const { } void NativeWidgetAura::RunShellDrag(View* view, - const ui::OSExchangeData& data, - const gfx::Point& location, - int operation) { - gfx::Point root_location(location); - aura::RootWindow* root_window = window_->GetRootWindow(); - aura::Window::ConvertPointToWindow(window_, root_window, &root_location); - if (aura::client::GetDragDropClient(root_window)) { - aura::client::GetDragDropClient(root_window)->StartDragAndDrop(data, - root_location, operation); - } + const ui::OSExchangeData& data, + const gfx::Point& location, + int operation) { + views::RunShellDrag(window_, data, location, operation); } void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 6887462..a128771 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -35,6 +35,7 @@ #include "ui/views/accessibility/native_view_accessibility_win.h" #include "ui/views/controls/native_control_win.h" #include "ui/views/controls/textfield/native_textfield_views.h" +#include "ui/views/drag_utils.h" #include "ui/views/focus/accelerator_handler.h" #include "ui/views/focus/view_storage.h" #include "ui/views/ime/input_method_win.h" @@ -1069,10 +1070,7 @@ void NativeWidgetWin::RunShellDrag(View* view, const ui::OSExchangeData& data, const gfx::Point& location, int operation) { - scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); - DWORD effects; - DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source, - ui::DragDropTypes::DragOperationToDropEffect(operation), &effects); + views::RunShellDrag(NULL, data, location, operation); } void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { |