| 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/window_resizer.h" | 5 #include "ash/wm/window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
| 8 #include "ash/wm/common/root_window_finder.h" | 8 #include "ash/wm/common/root_window_finder.h" |
| 9 #include "ash/wm/common/window_positioning_utils.h" | 9 #include "ash/wm/common/window_positioning_utils.h" |
| 10 #include "ash/wm/dock/docked_window_layout_manager.h" | 10 #include "ash/wm/dock/docked_window_layout_manager.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // repositioning the window when the minimize size is reached. | 125 // repositioning the window when the minimize size is reached. |
| 126 gfx::Size size = GetSizeForDrag(&delta_x, &delta_y); | 126 gfx::Size size = GetSizeForDrag(&delta_x, &delta_y); |
| 127 gfx::Point origin = GetOriginForDrag(delta_x, delta_y); | 127 gfx::Point origin = GetOriginForDrag(delta_x, delta_y); |
| 128 gfx::Rect new_bounds(origin, size); | 128 gfx::Rect new_bounds(origin, size); |
| 129 | 129 |
| 130 // Sizing has to keep the result on the screen. Note that this correction | 130 // Sizing has to keep the result on the screen. Note that this correction |
| 131 // has to come first since it might have an impact on the origin as well as | 131 // has to come first since it might have an impact on the origin as well as |
| 132 // on the size. | 132 // on the size. |
| 133 if (details().bounds_change & kBoundsChange_Resizes) { | 133 if (details().bounds_change & kBoundsChange_Resizes) { |
| 134 gfx::Rect work_area = GetTarget()->GetDisplayNearestWindow().work_area(); | 134 gfx::Rect work_area = GetTarget()->GetDisplayNearestWindow().work_area(); |
| 135 wm::WmWindow* dock_container = | |
| 136 GetTarget()->GetRootWindow()->GetChildByShellWindowId( | |
| 137 kShellWindowId_DockedContainer); | |
| 138 DockedWindowLayoutManager* dock_layout = | 135 DockedWindowLayoutManager* dock_layout = |
| 139 static_cast<DockedWindowLayoutManager*>( | 136 DockedWindowLayoutManager::Get(GetTarget()); |
| 140 wm::WmWindowAura::GetAuraWindow(dock_container)->layout_manager()); | |
| 141 | 137 |
| 142 work_area.Union(dock_layout->docked_bounds()); | 138 work_area.Union(dock_layout->docked_bounds()); |
| 143 work_area = GetTarget()->GetParent()->ConvertRectFromScreen(work_area); | 139 work_area = GetTarget()->GetParent()->ConvertRectFromScreen(work_area); |
| 144 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { | 140 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { |
| 145 if (IsRightEdge(details().window_component) && | 141 if (IsRightEdge(details().window_component) && |
| 146 new_bounds.right() < work_area.x() + wm::kMinimumOnScreenArea) { | 142 new_bounds.right() < work_area.x() + wm::kMinimumOnScreenArea) { |
| 147 int delta = | 143 int delta = |
| 148 work_area.x() + wm::kMinimumOnScreenArea - new_bounds.right(); | 144 work_area.x() + wm::kMinimumOnScreenArea - new_bounds.right(); |
| 149 new_bounds.set_width(new_bounds.width() + delta); | 145 new_bounds.set_width(new_bounds.width() + delta); |
| 150 } else if (new_bounds.x() > | 146 } else if (new_bounds.x() > |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // the |work_area| above isn't good for this check since it is the work area | 192 // the |work_area| above isn't good for this check since it is the work area |
| 197 // for the current display but the window can move to a different one. | 193 // for the current display but the window can move to a different one. |
| 198 wm::WmWindow* parent = GetTarget()->GetParent(); | 194 wm::WmWindow* parent = GetTarget()->GetParent(); |
| 199 gfx::Point passed_location_in_screen( | 195 gfx::Point passed_location_in_screen( |
| 200 parent->ConvertPointToScreen(passed_location)); | 196 parent->ConvertPointToScreen(passed_location)); |
| 201 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); | 197 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); |
| 202 // Use a pointer location (matching the logic in DragWindowResizer) to | 198 // Use a pointer location (matching the logic in DragWindowResizer) to |
| 203 // calculate the target display after the drag. | 199 // calculate the target display after the drag. |
| 204 const gfx::Display& display = | 200 const gfx::Display& display = |
| 205 gfx::Screen::GetScreen()->GetDisplayMatching(near_passed_location); | 201 gfx::Screen::GetScreen()->GetDisplayMatching(near_passed_location); |
| 206 wm::WmWindow* dock_container = | 202 DockedWindowLayoutManager* dock_layout = DockedWindowLayoutManager::Get( |
| 207 wm::GetRootWindowMatching(near_passed_location) | 203 wm::GetRootWindowMatching(near_passed_location)); |
| 208 ->GetChildByShellWindowId(kShellWindowId_DockedContainer); | |
| 209 DockedWindowLayoutManager* dock_layout = | |
| 210 static_cast<DockedWindowLayoutManager*>( | |
| 211 wm::WmWindowAura::GetAuraWindow(dock_container)->layout_manager()); | |
| 212 | 204 |
| 213 gfx::Rect screen_work_area = display.work_area(); | 205 gfx::Rect screen_work_area = display.work_area(); |
| 214 screen_work_area.Union(dock_layout->docked_bounds()); | 206 screen_work_area.Union(dock_layout->docked_bounds()); |
| 215 screen_work_area.Inset(wm::kMinimumOnScreenArea, 0); | 207 screen_work_area.Inset(wm::kMinimumOnScreenArea, 0); |
| 216 gfx::Rect new_bounds_in_screen = parent->ConvertRectToScreen(new_bounds); | 208 gfx::Rect new_bounds_in_screen = parent->ConvertRectToScreen(new_bounds); |
| 217 if (!screen_work_area.Intersects(new_bounds_in_screen)) { | 209 if (!screen_work_area.Intersects(new_bounds_in_screen)) { |
| 218 // Make sure that the x origin does not leave the current display. | 210 // Make sure that the x origin does not leave the current display. |
| 219 new_bounds_in_screen.set_x( | 211 new_bounds_in_screen.set_x( |
| 220 std::max(screen_work_area.x() - new_bounds.width(), | 212 std::max(screen_work_area.x() - new_bounds.width(), |
| 221 std::min(screen_work_area.right(), | 213 std::min(screen_work_area.right(), |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 if (height > max_height) { | 329 if (height > max_height) { |
| 338 height = max_height; | 330 height = max_height; |
| 339 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - | 331 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - |
| 340 max_height); | 332 max_height); |
| 341 } | 333 } |
| 342 } | 334 } |
| 343 return height; | 335 return height; |
| 344 } | 336 } |
| 345 | 337 |
| 346 } // namespace ash | 338 } // namespace ash |
| OLD | NEW |