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 "ash/wm/default_window_resizer.h" | 5 #include "ash/wm/default_window_resizer.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/coordinate_conversion.h" |
8 #include "ash/wm/cursor_manager.h" | 9 #include "ash/wm/cursor_manager.h" |
9 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
11 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/aura/window_delegate.h" | 14 #include "ui/aura/window_delegate.h" |
14 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
15 #include "ui/base/ui_base_types.h" | 16 #include "ui/base/ui_base_types.h" |
16 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
17 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
18 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
19 | 20 |
20 namespace ash { | 21 namespace ash { |
21 | 22 |
22 DefaultWindowResizer::~DefaultWindowResizer() { | 23 DefaultWindowResizer::~DefaultWindowResizer() { |
23 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); | 24 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
24 } | 25 } |
25 | 26 |
26 // static | 27 // static |
27 DefaultWindowResizer* | 28 DefaultWindowResizer* |
28 DefaultWindowResizer::Create(aura::Window* window, | 29 DefaultWindowResizer::Create(aura::Window* window, |
29 const gfx::Point& location, | 30 const gfx::Point& location, |
30 int window_component) { | 31 int window_component) { |
31 Details details(window, location, window_component); | 32 Details details(window, location, window_component); |
32 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; | 33 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; |
33 } | 34 } |
34 | 35 |
35 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 36 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 37 std::pair<aura::RootWindow*, gfx::Point> actual_location = |
| 38 wm::GetRootWindowRelativeToWindow(details_.window->parent(), location); |
| 39 |
| 40 // TODO(mazda|yusukes): Implement dragging an item from one display to another |
| 41 aura::RootWindow* current_root = actual_location.first; |
| 42 if (current_root != details_.window->GetRootWindow()) |
| 43 return; |
| 44 |
36 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 45 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
37 0 : ash::Shell::GetInstance()->GetGridSize(); | 46 0 : ash::Shell::GetInstance()->GetGridSize(); |
38 gfx::Rect bounds(CalculateBoundsForDrag(details_, location, grid_size)); | 47 gfx::Rect bounds(CalculateBoundsForDrag(details_, location, grid_size)); |
39 if (bounds != details_.window->bounds()) { | 48 if (bounds != details_.window->bounds()) { |
40 did_move_or_resize_ = true; | 49 did_move_or_resize_ = true; |
41 details_.window->SetBounds(bounds); | 50 details_.window->SetBounds(bounds); |
42 } | 51 } |
43 } | 52 } |
44 | 53 |
45 void DefaultWindowResizer::CompleteDrag(int event_flags) { | 54 void DefaultWindowResizer::CompleteDrag(int event_flags) { |
(...skipping 27 matching lines...) Expand all Loading... |
73 } | 82 } |
74 | 83 |
75 DefaultWindowResizer::DefaultWindowResizer(const Details& details) | 84 DefaultWindowResizer::DefaultWindowResizer(const Details& details) |
76 : details_(details), | 85 : details_(details), |
77 did_move_or_resize_(false) { | 86 did_move_or_resize_(false) { |
78 DCHECK(details_.is_resizable); | 87 DCHECK(details_.is_resizable); |
79 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); | 88 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
80 } | 89 } |
81 | 90 |
82 } // namespace aura | 91 } // namespace aura |
OLD | NEW |