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