| 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/common/wm/window_resizer.h" | 5 #include "ash/common/wm/window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/dock/docked_window_layout_manager.h" | |
| 8 #include "ash/common/wm/root_window_finder.h" | 7 #include "ash/common/wm/root_window_finder.h" |
| 9 #include "ash/common/wm/window_positioning_utils.h" | 8 #include "ash/common/wm/window_positioning_utils.h" |
| 10 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 11 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
| 12 #include "ui/base/hit_test.h" | 11 #include "ui/base/hit_test.h" |
| 13 #include "ui/base/ui_base_types.h" | 12 #include "ui/base/ui_base_types.h" |
| 14 #include "ui/display/display.h" | 13 #include "ui/display/display.h" |
| 15 #include "ui/display/screen.h" | 14 #include "ui/display/screen.h" |
| 16 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 17 | 16 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // repositioning the window when the minimize size is reached. | 119 // repositioning the window when the minimize size is reached. |
| 121 gfx::Size size = GetSizeForDrag(&delta_x, &delta_y); | 120 gfx::Size size = GetSizeForDrag(&delta_x, &delta_y); |
| 122 gfx::Point origin = GetOriginForDrag(delta_x, delta_y); | 121 gfx::Point origin = GetOriginForDrag(delta_x, delta_y); |
| 123 gfx::Rect new_bounds(origin, size); | 122 gfx::Rect new_bounds(origin, size); |
| 124 | 123 |
| 125 // Sizing has to keep the result on the screen. Note that this correction | 124 // Sizing has to keep the result on the screen. Note that this correction |
| 126 // has to come first since it might have an impact on the origin as well as | 125 // has to come first since it might have an impact on the origin as well as |
| 127 // on the size. | 126 // on the size. |
| 128 if (details().bounds_change & kBoundsChange_Resizes) { | 127 if (details().bounds_change & kBoundsChange_Resizes) { |
| 129 gfx::Rect work_area = GetTarget()->GetDisplayNearestWindow().work_area(); | 128 gfx::Rect work_area = GetTarget()->GetDisplayNearestWindow().work_area(); |
| 130 DockedWindowLayoutManager* dock_layout = | |
| 131 DockedWindowLayoutManager::Get(GetTarget()); | |
| 132 | |
| 133 work_area.Union(dock_layout->docked_bounds()); | |
| 134 work_area = GetTarget()->GetParent()->ConvertRectFromScreen(work_area); | 129 work_area = GetTarget()->GetParent()->ConvertRectFromScreen(work_area); |
| 135 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { | 130 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { |
| 136 if (IsRightEdge(details().window_component) && | 131 if (IsRightEdge(details().window_component) && |
| 137 new_bounds.right() < work_area.x() + wm::kMinimumOnScreenArea) { | 132 new_bounds.right() < work_area.x() + wm::kMinimumOnScreenArea) { |
| 138 int delta = | 133 int delta = |
| 139 work_area.x() + wm::kMinimumOnScreenArea - new_bounds.right(); | 134 work_area.x() + wm::kMinimumOnScreenArea - new_bounds.right(); |
| 140 new_bounds.set_width(new_bounds.width() + delta); | 135 new_bounds.set_width(new_bounds.width() + delta); |
| 141 } else if (new_bounds.x() > | 136 } else if (new_bounds.x() > |
| 142 work_area.right() - wm::kMinimumOnScreenArea) { | 137 work_area.right() - wm::kMinimumOnScreenArea) { |
| 143 int width = | 138 int width = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // the |work_area| above isn't good for this check since it is the work area | 181 // the |work_area| above isn't good for this check since it is the work area |
| 187 // for the current display but the window can move to a different one. | 182 // for the current display but the window can move to a different one. |
| 188 WmWindow* parent = GetTarget()->GetParent(); | 183 WmWindow* parent = GetTarget()->GetParent(); |
| 189 gfx::Point passed_location_in_screen( | 184 gfx::Point passed_location_in_screen( |
| 190 parent->ConvertPointToScreen(passed_location)); | 185 parent->ConvertPointToScreen(passed_location)); |
| 191 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); | 186 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); |
| 192 // Use a pointer location (matching the logic in DragWindowResizer) to | 187 // Use a pointer location (matching the logic in DragWindowResizer) to |
| 193 // calculate the target display after the drag. | 188 // calculate the target display after the drag. |
| 194 const display::Display& display = | 189 const display::Display& display = |
| 195 display::Screen::GetScreen()->GetDisplayMatching(near_passed_location); | 190 display::Screen::GetScreen()->GetDisplayMatching(near_passed_location); |
| 196 DockedWindowLayoutManager* dock_layout = DockedWindowLayoutManager::Get( | |
| 197 wm::GetRootWindowMatching(near_passed_location)); | |
| 198 | |
| 199 gfx::Rect screen_work_area = display.work_area(); | 191 gfx::Rect screen_work_area = display.work_area(); |
| 200 screen_work_area.Union(dock_layout->docked_bounds()); | |
| 201 screen_work_area.Inset(wm::kMinimumOnScreenArea, 0); | 192 screen_work_area.Inset(wm::kMinimumOnScreenArea, 0); |
| 202 gfx::Rect new_bounds_in_screen = parent->ConvertRectToScreen(new_bounds); | 193 gfx::Rect new_bounds_in_screen = parent->ConvertRectToScreen(new_bounds); |
| 203 if (!screen_work_area.Intersects(new_bounds_in_screen)) { | 194 if (!screen_work_area.Intersects(new_bounds_in_screen)) { |
| 204 // Make sure that the x origin does not leave the current display. | 195 // Make sure that the x origin does not leave the current display. |
| 205 new_bounds_in_screen.set_x(std::max( | 196 new_bounds_in_screen.set_x(std::max( |
| 206 screen_work_area.x() - new_bounds.width(), | 197 screen_work_area.x() - new_bounds.width(), |
| 207 std::min(screen_work_area.right(), new_bounds_in_screen.x()))); | 198 std::min(screen_work_area.right(), new_bounds_in_screen.x()))); |
| 208 new_bounds = parent->ConvertRectFromScreen(new_bounds_in_screen); | 199 new_bounds = parent->ConvertRectFromScreen(new_bounds_in_screen); |
| 209 } | 200 } |
| 210 } | 201 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 if (height > max_height) { | 311 if (height > max_height) { |
| 321 height = max_height; | 312 height = max_height; |
| 322 *delta_y = -y_multiplier * | 313 *delta_y = -y_multiplier * |
| 323 (details().initial_bounds_in_parent.height() - max_height); | 314 (details().initial_bounds_in_parent.height() - max_height); |
| 324 } | 315 } |
| 325 } | 316 } |
| 326 return height; | 317 return height; |
| 327 } | 318 } |
| 328 | 319 |
| 329 } // namespace ash | 320 } // namespace ash |
| OLD | NEW |