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/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // The maximum opacity of the drag phantom window. | 31 // The maximum opacity of the drag phantom window. |
32 const float kMaxOpacity = 0.8f; | 32 const float kMaxOpacity = 0.8f; |
33 | 33 |
34 // Returns true if Ash has more than one root window. | 34 // Returns true if Ash has more than one root window. |
35 bool HasSecondaryRootWindow() { | 35 bool HasSecondaryRootWindow() { |
36 return Shell::GetAllRootWindows().size() > 1; | 36 return Shell::GetAllRootWindows().size() > 1; |
37 } | 37 } |
38 | 38 |
39 // When there are two root windows, returns one of the root windows which is not | 39 // When there are two root windows, returns one of the root windows which is not |
40 // |root_window|. Returns NULL if only one root window exists. | 40 // |root_window|. Returns NULL if only one root window exists. |
41 aura::RootWindow* GetAnotherRootWindow(aura::RootWindow* root_window) { | 41 aura::RootWindow* GetAnotherRootWindow(aura::Window* root_window) { |
42 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 42 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
43 if (root_windows.size() < 2) | 43 if (root_windows.size() < 2) |
44 return NULL; | 44 return NULL; |
45 DCHECK_EQ(2U, root_windows.size()); | 45 DCHECK_EQ(2U, root_windows.size()); |
46 if (root_windows[0] == root_window) | 46 if (root_windows[0] == root_window) |
47 return root_windows[1]; | 47 return root_windows[1]; |
48 return root_windows[0]; | 48 return root_windows[0]; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 instance_ = this; | 165 instance_ = this; |
166 } | 166 } |
167 | 167 |
168 void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds, | 168 void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds, |
169 bool in_original_root) { | 169 bool in_original_root) { |
170 if (details_.window_component != HTCAPTION || !ShouldAllowMouseWarp()) | 170 if (details_.window_component != HTCAPTION || !ShouldAllowMouseWarp()) |
171 return; | 171 return; |
172 | 172 |
173 // It's available. Show a phantom window on the display if needed. | 173 // It's available. Show a phantom window on the display if needed. |
174 aura::RootWindow* another_root = | 174 aura::Window* another_root = |
175 GetAnotherRootWindow(GetTarget()->GetRootWindow()); | 175 GetAnotherRootWindow(GetTarget()->GetRootWindow()); |
176 const gfx::Rect root_bounds_in_screen(another_root->GetBoundsInScreen()); | 176 const gfx::Rect root_bounds_in_screen(another_root->GetBoundsInScreen()); |
177 const gfx::Rect bounds_in_screen = | 177 const gfx::Rect bounds_in_screen = |
178 ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds); | 178 ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds); |
179 gfx::Rect bounds_in_another_root = | 179 gfx::Rect bounds_in_another_root = |
180 gfx::IntersectRects(root_bounds_in_screen, bounds_in_screen); | 180 gfx::IntersectRects(root_bounds_in_screen, bounds_in_screen); |
181 const float fraction_in_another_window = | 181 const float fraction_in_another_window = |
182 (bounds_in_another_root.width() * bounds_in_another_root.height()) / | 182 (bounds_in_another_root.width() * bounds_in_another_root.height()) / |
183 static_cast<float>(bounds.width() * bounds.height()); | 183 static_cast<float>(bounds.width() * bounds.height()); |
184 | 184 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (!tray_user->TransferWindowToUser(details_.window)) { | 263 if (!tray_user->TransferWindowToUser(details_.window)) { |
264 GetTarget()->layer()->SetOpacity(old_opacity); | 264 GetTarget()->layer()->SetOpacity(old_opacity); |
265 return false; | 265 return false; |
266 } | 266 } |
267 RevertDrag(); | 267 RevertDrag(); |
268 return true; | 268 return true; |
269 } | 269 } |
270 | 270 |
271 } // namespace internal | 271 } // namespace internal |
272 } // namespace ash | 272 } // namespace ash |
OLD | NEW |