Chromium Code Reviews| Index: ash/mus/window_manager.cc |
| diff --git a/ash/mus/window_manager.cc b/ash/mus/window_manager.cc |
| index 02101212c93ed96acdc252c4145d7ca2aff8bfff..6229e5f5211b8bfffacc89d2c5bdae9fc496ed5a 100644 |
| --- a/ash/mus/window_manager.cc |
| +++ b/ash/mus/window_manager.cc |
| @@ -8,6 +8,7 @@ |
| #include <utility> |
| +#include "ash/common/drag_drop/drag_image_view.h" |
| #include "ash/common/session/session_controller.h" |
| #include "ash/common/wm/container_finder.h" |
| #include "ash/common/wm/window_state.h" |
| @@ -366,6 +367,48 @@ void WindowManager::OnWmClientJankinessChanged( |
| window->SetProperty(kWindowIsJanky, janky); |
| } |
| +void WindowManager::OnWmBuildDragImage( |
| + const gfx::Point& location_in_screen_coordinates, |
| + const SkBitmap& drag_image, |
| + const gfx::Vector2d& drag_image_offset, |
| + ui::mojom::DragEventSource source) { |
| + if (drag_image.isNull()) |
| + return; |
| + |
| + // TODO(erg): Get the right display for this drag image. Right now, none of |
| + // the drag drop code is multidisplay aware. |
| + |
| + // TODO(erg): SkBitmap is the wrong data type for the drag image; we should |
| + // be passing ImageSkias once http://crbug.com/655874 is implemented. |
| + |
| + WmWindow* root_window = |
| + WmWindow::Get((*GetRootWindowControllers().begin())->GetRootWindow()); |
| + |
| + ui::DragDropTypes::DragEventSource ui_source = |
| + source == ui::mojom::DragEventSource::MOUSE |
| + ? ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE |
| + : ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
| + drag_image_.reset(new DragImageView(root_window, ui_source)); |
|
sky
2017/03/23 00:05:35
MakeUnique.
Elliot Glaysher
2017/03/23 19:58:43
Done.
|
| + drag_image_->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(drag_image)); |
| + gfx::Size size = drag_image_->GetPreferredSize(); |
| + gfx::Rect drag_image_bounds( |
| + location_in_screen_coordinates - drag_image_offset, size); |
| + drag_image_->SetBoundsInScreen(drag_image_bounds); |
| + drag_image_->SetWidgetVisible(true); |
| + |
| + drag_image_offset_ = drag_image_offset; |
| +} |
| + |
| +void WindowManager::OnWmMoveDragImage(const gfx::Point& cursor_location) { |
| + if (drag_image_) |
| + drag_image_->SetScreenPosition(cursor_location - drag_image_offset_); |
| +} |
| + |
| +void WindowManager::OnWmDestroyDragImage() { |
| + drag_image_.reset(); |
| + drag_image_offset_ = gfx::Vector2d(0, 0); |
| +} |
| + |
| void WindowManager::OnWmWillCreateDisplay(const display::Display& display) { |
| // A call to this function means a new display is being added, so the |
| // DisplayList needs to be updated. Calling AddDisplay() results in |