| 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/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/display/window_tree_host_manager.h" | 12 #include "ash/display/window_tree_host_manager.h" |
| 13 #include "ash/metrics/user_metrics_recorder.h" | 13 #include "ash/metrics/user_metrics_recorder.h" |
| 14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 18 #include "ash/wm/common/wm_event.h" | 18 #include "ash/wm/common/wm_event.h" |
| 19 #include "ash/wm/default_window_resizer.h" | 19 #include "ash/wm/default_window_resizer.h" |
| 20 #include "ash/wm/dock/docked_window_layout_manager.h" | 20 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 21 #include "ash/wm/dock/docked_window_resizer.h" | 21 #include "ash/wm/dock/docked_window_resizer.h" |
| 22 #include "ash/wm/drag_window_resizer.h" | 22 #include "ash/wm/drag_window_resizer.h" |
| 23 #include "ash/wm/panels/panel_window_resizer.h" | 23 #include "ash/wm/panels/panel_window_resizer.h" |
| 24 #include "ash/wm/window_state.h" | 24 #include "ash/wm/window_state.h" |
| 25 #include "ash/wm/window_state_aura.h" |
| 25 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
| 26 #include "ash/wm/workspace/phantom_window_controller.h" | 27 #include "ash/wm/workspace/phantom_window_controller.h" |
| 27 #include "ash/wm/workspace/two_step_edge_cycler.h" | 28 #include "ash/wm/workspace/two_step_edge_cycler.h" |
| 28 #include "base/command_line.h" | 29 #include "base/command_line.h" |
| 29 #include "base/memory/ptr_util.h" | 30 #include "base/memory/ptr_util.h" |
| 30 #include "base/memory/weak_ptr.h" | 31 #include "base/memory/weak_ptr.h" |
| 31 #include "ui/aura/client/aura_constants.h" | 32 #include "ui/aura/client/aura_constants.h" |
| 32 #include "ui/aura/client/screen_position_client.h" | 33 #include "ui/aura/client/screen_position_client.h" |
| 33 #include "ui/aura/window.h" | 34 #include "ui/aura/window.h" |
| 34 #include "ui/aura/window_delegate.h" | 35 #include "ui/aura/window_delegate.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 WindowResizer* window_resizer = NULL; | 75 WindowResizer* window_resizer = NULL; |
| 75 | 76 |
| 76 if (!window_state->IsNormalOrSnapped() && !window_state->IsDocked()) | 77 if (!window_state->IsNormalOrSnapped() && !window_state->IsDocked()) |
| 77 return std::unique_ptr<WindowResizer>(); | 78 return std::unique_ptr<WindowResizer>(); |
| 78 | 79 |
| 79 int bounds_change = WindowResizer::GetBoundsChangeForWindowComponent( | 80 int bounds_change = WindowResizer::GetBoundsChangeForWindowComponent( |
| 80 window_component); | 81 window_component); |
| 81 if (bounds_change == WindowResizer::kBoundsChangeDirection_None) | 82 if (bounds_change == WindowResizer::kBoundsChangeDirection_None) |
| 82 return std::unique_ptr<WindowResizer>(); | 83 return std::unique_ptr<WindowResizer>(); |
| 83 | 84 |
| 84 window_state->CreateDragDetails(window, point_in_parent, window_component, | 85 window_state->CreateDragDetails(point_in_parent, window_component, source); |
| 85 source); | |
| 86 if (window->parent() && | 86 if (window->parent() && |
| 87 (window->parent()->id() == kShellWindowId_DefaultContainer || | 87 (window->parent()->id() == kShellWindowId_DefaultContainer || |
| 88 window->parent()->id() == kShellWindowId_DockedContainer || | 88 window->parent()->id() == kShellWindowId_DockedContainer || |
| 89 window->parent()->id() == kShellWindowId_PanelContainer)) { | 89 window->parent()->id() == kShellWindowId_PanelContainer)) { |
| 90 window_resizer = WorkspaceWindowResizer::Create( | 90 window_resizer = WorkspaceWindowResizer::Create( |
| 91 window_state, std::vector<aura::Window*>()); | 91 window_state, std::vector<aura::Window*>()); |
| 92 } else { | 92 } else { |
| 93 window_resizer = DefaultWindowResizer::Create(window_state); | 93 window_resizer = DefaultWindowResizer::Create(window_state); |
| 94 } | 94 } |
| 95 window_resizer = DragWindowResizer::Create(window_resizer, window_state); | 95 window_resizer = DragWindowResizer::Create(window_resizer, window_state); |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 757 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 758 for (aura::Window::Windows::iterator iter = root_windows.begin(); | 758 for (aura::Window::Windows::iterator iter = root_windows.begin(); |
| 759 iter != root_windows.end(); ++iter) { | 759 iter != root_windows.end(); ++iter) { |
| 760 const aura::Window* root_window = *iter; | 760 const aura::Window* root_window = *iter; |
| 761 // Test all children from the desktop in each root window. | 761 // Test all children from the desktop in each root window. |
| 762 const aura::Window::Windows& children = Shell::GetContainer( | 762 const aura::Window::Windows& children = Shell::GetContainer( |
| 763 root_window, kShellWindowId_DefaultContainer)->children(); | 763 root_window, kShellWindowId_DefaultContainer)->children(); |
| 764 for (aura::Window::Windows::const_reverse_iterator i = children.rbegin(); | 764 for (aura::Window::Windows::const_reverse_iterator i = children.rbegin(); |
| 765 i != children.rend() && !matcher.AreEdgesObscured(); ++i) { | 765 i != children.rend() && !matcher.AreEdgesObscured(); ++i) { |
| 766 wm::WindowState* other_state = wm::GetWindowState(*i); | 766 wm::WindowState* other_state = wm::GetWindowState(*i); |
| 767 if (other_state->window() == GetTarget() || | 767 if (other_state->aura_window() == GetTarget() || |
| 768 !other_state->window()->IsVisible() || | 768 !other_state->window()->IsVisible() || |
| 769 !other_state->IsNormalOrSnapped() || | 769 !other_state->IsNormalOrSnapped() || !other_state->CanResize()) { |
| 770 !other_state->CanResize()) { | |
| 771 continue; | 770 continue; |
| 772 } | 771 } |
| 773 if (matcher.ShouldAttach( | 772 if (matcher.ShouldAttach( |
| 774 other_state->window()->GetBoundsInScreen(), &magnetism_edge_)) { | 773 other_state->window()->GetBoundsInScreen(), &magnetism_edge_)) { |
| 775 magnetism_window_ = other_state->window(); | 774 magnetism_window_ = other_state->aura_window(); |
| 776 window_tracker_.Add(magnetism_window_); | 775 window_tracker_.Add(magnetism_window_); |
| 777 return true; | 776 return true; |
| 778 } | 777 } |
| 779 } | 778 } |
| 780 } | 779 } |
| 781 return false; | 780 return false; |
| 782 } | 781 } |
| 783 | 782 |
| 784 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( | 783 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( |
| 785 int sticky_size, | 784 int sticky_size, |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1055 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
| 1057 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1056 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 1058 GetTarget()); | 1057 GetTarget()); |
| 1059 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1058 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
| 1060 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1059 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
| 1061 snapped_bounds.set_width(bounds_in_parent.width()); | 1060 snapped_bounds.set_width(bounds_in_parent.width()); |
| 1062 return bounds_in_parent == snapped_bounds; | 1061 return bounds_in_parent == snapped_bounds; |
| 1063 } | 1062 } |
| 1064 | 1063 |
| 1065 } // namespace ash | 1064 } // namespace ash |
| OLD | NEW |