| 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> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return scoped_ptr<WindowResizer>(); | 77 return scoped_ptr<WindowResizer>(); |
| 78 | 78 |
| 79 int bounds_change = WindowResizer::GetBoundsChangeForWindowComponent( | 79 int bounds_change = WindowResizer::GetBoundsChangeForWindowComponent( |
| 80 window_component); | 80 window_component); |
| 81 if (bounds_change == WindowResizer::kBoundsChangeDirection_None) | 81 if (bounds_change == WindowResizer::kBoundsChangeDirection_None) |
| 82 return scoped_ptr<WindowResizer>(); | 82 return scoped_ptr<WindowResizer>(); |
| 83 | 83 |
| 84 window_state->CreateDragDetails(window, point_in_parent, window_component, | 84 window_state->CreateDragDetails(window, point_in_parent, window_component, |
| 85 source); | 85 source); |
| 86 if (window->parent() && | 86 if (window->parent() && |
| 87 (window->parent()->id() == internal::kShellWindowId_DefaultContainer || | 87 (window->parent()->id() == kShellWindowId_DefaultContainer || |
| 88 window->parent()->id() == internal::kShellWindowId_DockedContainer || | 88 window->parent()->id() == kShellWindowId_DockedContainer || |
| 89 window->parent()->id() == internal::kShellWindowId_PanelContainer)) { | 89 window->parent()->id() == kShellWindowId_PanelContainer)) { |
| 90 window_resizer = internal::WorkspaceWindowResizer::Create( | 90 window_resizer = WorkspaceWindowResizer::Create( |
| 91 window_state, | 91 window_state, std::vector<aura::Window*>()); |
| 92 std::vector<aura::Window*>()); | |
| 93 } else { | 92 } else { |
| 94 window_resizer = DefaultWindowResizer::Create(window_state); | 93 window_resizer = DefaultWindowResizer::Create(window_state); |
| 95 } | 94 } |
| 96 window_resizer = internal::DragWindowResizer::Create(window_resizer, | 95 window_resizer = DragWindowResizer::Create(window_resizer, window_state); |
| 97 window_state); | |
| 98 if (window->type() == ui::wm::WINDOW_TYPE_PANEL) | 96 if (window->type() == ui::wm::WINDOW_TYPE_PANEL) |
| 99 window_resizer = PanelWindowResizer::Create(window_resizer, window_state); | 97 window_resizer = PanelWindowResizer::Create(window_resizer, window_state); |
| 100 if (switches::UseDockedWindows() && | 98 if (switches::UseDockedWindows() && window_resizer && window->parent() && |
| 101 window_resizer && window->parent() && | |
| 102 !::wm::GetTransientParent(window) && | 99 !::wm::GetTransientParent(window) && |
| 103 (window->parent()->id() == internal::kShellWindowId_DefaultContainer || | 100 (window->parent()->id() == kShellWindowId_DefaultContainer || |
| 104 window->parent()->id() == internal::kShellWindowId_DockedContainer || | 101 window->parent()->id() == kShellWindowId_DockedContainer || |
| 105 window->parent()->id() == internal::kShellWindowId_PanelContainer)) { | 102 window->parent()->id() == kShellWindowId_PanelContainer)) { |
| 106 window_resizer = internal::DockedWindowResizer::Create(window_resizer, | 103 window_resizer = DockedWindowResizer::Create(window_resizer, window_state); |
| 107 window_state); | |
| 108 } | 104 } |
| 109 return make_scoped_ptr<WindowResizer>(window_resizer); | 105 return make_scoped_ptr<WindowResizer>(window_resizer); |
| 110 } | 106 } |
| 111 | 107 |
| 112 namespace internal { | |
| 113 | |
| 114 namespace { | 108 namespace { |
| 115 | 109 |
| 116 // Snapping distance used instead of WorkspaceWindowResizer::kScreenEdgeInset | 110 // Snapping distance used instead of WorkspaceWindowResizer::kScreenEdgeInset |
| 117 // when resizing a window using touchscreen. | 111 // when resizing a window using touchscreen. |
| 118 const int kScreenEdgeInsetForTouchDrag = 32; | 112 const int kScreenEdgeInsetForTouchDrag = 32; |
| 119 | 113 |
| 120 // Returns true if the window should stick to the edge. | 114 // Returns true if the window should stick to the edge. |
| 121 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) { | 115 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) { |
| 122 return distance_from_edge < sticky_size && | 116 return distance_from_edge < sticky_size && |
| 123 distance_from_edge > -sticky_size * 2; | 117 distance_from_edge > -sticky_size * 2; |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || | 1034 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || |
| 1041 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1035 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
| 1042 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1036 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 1043 GetTarget()); | 1037 GetTarget()); |
| 1044 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1038 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
| 1045 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1039 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
| 1046 snapped_bounds.set_width(bounds_in_parent.width()); | 1040 snapped_bounds.set_width(bounds_in_parent.width()); |
| 1047 return bounds_in_parent == snapped_bounds; | 1041 return bounds_in_parent == snapped_bounds; |
| 1048 } | 1042 } |
| 1049 | 1043 |
| 1050 } // namespace internal | |
| 1051 } // namespace ash | 1044 } // namespace ash |
| OLD | NEW |