| 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/drag_window_resizer.h" | 5 #include "ash/wm/drag_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/display/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 aura::RootWindow* GetAnotherRootWindow(aura::RootWindow* root_window) { | 37 aura::RootWindow* GetAnotherRootWindow(aura::RootWindow* root_window) { |
| 38 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 38 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 39 if (root_windows.size() < 2) | 39 if (root_windows.size() < 2) |
| 40 return NULL; | 40 return NULL; |
| 41 DCHECK_EQ(2U, root_windows.size()); | 41 DCHECK_EQ(2U, root_windows.size()); |
| 42 if (root_windows[0] == root_window) | 42 if (root_windows[0] == root_window) |
| 43 return root_windows[1]; | 43 return root_windows[1]; |
| 44 return root_windows[0]; | 44 return root_windows[0]; |
| 45 } | 45 } |
| 46 | 46 |
| 47 } | 47 } // namespace |
| 48 |
| 49 // static |
| 50 DragWindowResizer* DragWindowResizer::instance_ = NULL; |
| 48 | 51 |
| 49 DragWindowResizer::~DragWindowResizer() { | 52 DragWindowResizer::~DragWindowResizer() { |
| 50 Shell* shell = Shell::GetInstance(); | 53 Shell* shell = Shell::GetInstance(); |
| 51 shell->mouse_cursor_filter()->set_mouse_warp_mode( | 54 shell->mouse_cursor_filter()->set_mouse_warp_mode( |
| 52 MouseCursorEventFilter::WARP_ALWAYS); | 55 MouseCursorEventFilter::WARP_ALWAYS); |
| 53 shell->mouse_cursor_filter()->HideSharedEdgeIndicator(); | 56 shell->mouse_cursor_filter()->HideSharedEdgeIndicator(); |
| 57 if (instance_ == this) |
| 58 instance_ = NULL; |
| 54 | 59 |
| 55 if (destroyed_) | 60 if (destroyed_) |
| 56 *destroyed_ = true; | 61 *destroyed_ = true; |
| 57 } | 62 } |
| 58 | 63 |
| 59 // static | 64 // static |
| 60 DragWindowResizer* DragWindowResizer::Create(WindowResizer* next_window_resizer, | 65 DragWindowResizer* DragWindowResizer::Create(WindowResizer* next_window_resizer, |
| 61 aura::Window* window, | 66 aura::Window* window, |
| 62 const gfx::Point& location, | 67 const gfx::Point& location, |
| 63 int window_component) { | 68 int window_component) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 next_window_resizer_->RevertDrag(); | 123 next_window_resizer_->RevertDrag(); |
| 119 | 124 |
| 120 drag_window_controller_.reset(); | 125 drag_window_controller_.reset(); |
| 121 GetTarget()->layer()->SetOpacity(details_.initial_opacity); | 126 GetTarget()->layer()->SetOpacity(details_.initial_opacity); |
| 122 } | 127 } |
| 123 | 128 |
| 124 aura::Window* DragWindowResizer::GetTarget() { | 129 aura::Window* DragWindowResizer::GetTarget() { |
| 125 return next_window_resizer_->GetTarget(); | 130 return next_window_resizer_->GetTarget(); |
| 126 } | 131 } |
| 127 | 132 |
| 133 const gfx::Point& DragWindowResizer::GetInitialLocationForTest() const { |
| 134 return details_.initial_location_in_parent; |
| 135 } |
| 136 |
| 128 DragWindowResizer::DragWindowResizer(WindowResizer* next_window_resizer, | 137 DragWindowResizer::DragWindowResizer(WindowResizer* next_window_resizer, |
| 129 const Details& details) | 138 const Details& details) |
| 130 : next_window_resizer_(next_window_resizer), | 139 : next_window_resizer_(next_window_resizer), |
| 131 details_(details), | 140 details_(details), |
| 132 destroyed_(NULL) { | 141 destroyed_(NULL) { |
| 133 // The pointer should be confined in one display during resizing a window | 142 // The pointer should be confined in one display during resizing a window |
| 134 // because the window cannot span two displays at the same time anyway. The | 143 // because the window cannot span two displays at the same time anyway. The |
| 135 // exception is window/tab dragging operation. During that operation, | 144 // exception is window/tab dragging operation. During that operation, |
| 136 // |mouse_warp_mode_| should be set to WARP_DRAG so that the user could move a | 145 // |mouse_warp_mode_| should be set to WARP_DRAG so that the user could move a |
| 137 // window/tab to another display. | 146 // window/tab to another display. |
| 138 MouseCursorEventFilter* mouse_cursor_filter = | 147 MouseCursorEventFilter* mouse_cursor_filter = |
| 139 Shell::GetInstance()->mouse_cursor_filter(); | 148 Shell::GetInstance()->mouse_cursor_filter(); |
| 140 mouse_cursor_filter->set_mouse_warp_mode( | 149 mouse_cursor_filter->set_mouse_warp_mode( |
| 141 ShouldAllowMouseWarp() ? | 150 ShouldAllowMouseWarp() ? |
| 142 MouseCursorEventFilter::WARP_DRAG : MouseCursorEventFilter::WARP_NONE); | 151 MouseCursorEventFilter::WARP_DRAG : MouseCursorEventFilter::WARP_NONE); |
| 143 if (ShouldAllowMouseWarp()) { | 152 if (ShouldAllowMouseWarp()) { |
| 144 mouse_cursor_filter->ShowSharedEdgeIndicator( | 153 mouse_cursor_filter->ShowSharedEdgeIndicator( |
| 145 details.window->GetRootWindow()); | 154 details.window->GetRootWindow()); |
| 146 } | 155 } |
| 156 instance_ = this; |
| 147 } | 157 } |
| 148 | 158 |
| 149 void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds, | 159 void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds, |
| 150 bool in_original_root) { | 160 bool in_original_root) { |
| 151 if (details_.window_component != HTCAPTION || !ShouldAllowMouseWarp()) | 161 if (details_.window_component != HTCAPTION || !ShouldAllowMouseWarp()) |
| 152 return; | 162 return; |
| 153 | 163 |
| 154 // It's available. Show a phantom window on the display if needed. | 164 // It's available. Show a phantom window on the display if needed. |
| 155 aura::RootWindow* another_root = | 165 aura::RootWindow* another_root = |
| 156 GetAnotherRootWindow(GetTarget()->GetRootWindow()); | 166 GetAnotherRootWindow(GetTarget()->GetRootWindow()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 200 |
| 191 bool DragWindowResizer::ShouldAllowMouseWarp() { | 201 bool DragWindowResizer::ShouldAllowMouseWarp() { |
| 192 return (details_.window_component == HTCAPTION) && | 202 return (details_.window_component == HTCAPTION) && |
| 193 !GetTarget()->transient_parent() && | 203 !GetTarget()->transient_parent() && |
| 194 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || | 204 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || |
| 195 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); | 205 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); |
| 196 } | 206 } |
| 197 | 207 |
| 198 } // namespace internal | 208 } // namespace internal |
| 199 } // namespace ash | 209 } // namespace ash |
| OLD | NEW |