| 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/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 gfx::Point origin = GetOriginForDrag(delta_x, delta_y); | 135 gfx::Point origin = GetOriginForDrag(delta_x, delta_y); |
| 136 gfx::Rect new_bounds(origin, size); | 136 gfx::Rect new_bounds(origin, size); |
| 137 | 137 |
| 138 // Sizing has to keep the result on the screen. Note that this correction | 138 // Sizing has to keep the result on the screen. Note that this correction |
| 139 // has to come first since it might have an impact on the origin as well as | 139 // has to come first since it might have an impact on the origin as well as |
| 140 // on the size. | 140 // on the size. |
| 141 if (details().bounds_change & kBoundsChange_Resizes) { | 141 if (details().bounds_change & kBoundsChange_Resizes) { |
| 142 gfx::Rect work_area = | 142 gfx::Rect work_area = |
| 143 Shell::GetScreen()->GetDisplayNearestWindow(GetTarget()).work_area(); | 143 Shell::GetScreen()->GetDisplayNearestWindow(GetTarget()).work_area(); |
| 144 aura::Window* dock_container = Shell::GetContainer( | 144 aura::Window* dock_container = Shell::GetContainer( |
| 145 GetTarget()->GetRootWindow(), | 145 GetTarget()->GetRootWindow(), kShellWindowId_DockedContainer); |
| 146 internal::kShellWindowId_DockedContainer); | 146 DockedWindowLayoutManager* dock_layout = |
| 147 internal::DockedWindowLayoutManager* dock_layout = | 147 static_cast<DockedWindowLayoutManager*>( |
| 148 static_cast<internal::DockedWindowLayoutManager*>( | |
| 149 dock_container->layout_manager()); | 148 dock_container->layout_manager()); |
| 150 | 149 |
| 151 work_area.Union(dock_layout->docked_bounds()); | 150 work_area.Union(dock_layout->docked_bounds()); |
| 152 work_area = ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), | 151 work_area = ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), |
| 153 work_area); | 152 work_area); |
| 154 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { | 153 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { |
| 155 if (IsRightEdge(details().window_component) && | 154 if (IsRightEdge(details().window_component) && |
| 156 new_bounds.right() < work_area.x() + kMinimumOnScreenArea) { | 155 new_bounds.right() < work_area.x() + kMinimumOnScreenArea) { |
| 157 int delta = work_area.x() + kMinimumOnScreenArea - new_bounds.right(); | 156 int delta = work_area.x() + kMinimumOnScreenArea - new_bounds.right(); |
| 158 new_bounds.set_width(new_bounds.width() + delta); | 157 new_bounds.set_width(new_bounds.width() + delta); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // the |work_area| above isn't good for this check since it is the work area | 203 // the |work_area| above isn't good for this check since it is the work area |
| 205 // for the current display but the window can move to a different one. | 204 // for the current display but the window can move to a different one. |
| 206 aura::Window* parent = GetTarget()->parent(); | 205 aura::Window* parent = GetTarget()->parent(); |
| 207 gfx::Point passed_location_in_screen(passed_location); | 206 gfx::Point passed_location_in_screen(passed_location); |
| 208 wm::ConvertPointToScreen(parent, &passed_location_in_screen); | 207 wm::ConvertPointToScreen(parent, &passed_location_in_screen); |
| 209 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); | 208 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); |
| 210 // Use a pointer location (matching the logic in DragWindowResizer) to | 209 // Use a pointer location (matching the logic in DragWindowResizer) to |
| 211 // calculate the target display after the drag. | 210 // calculate the target display after the drag. |
| 212 const gfx::Display& display = | 211 const gfx::Display& display = |
| 213 Shell::GetScreen()->GetDisplayMatching(near_passed_location); | 212 Shell::GetScreen()->GetDisplayMatching(near_passed_location); |
| 214 aura::Window* dock_container = Shell::GetContainer( | 213 aura::Window* dock_container = |
| 215 wm::GetRootWindowMatching(near_passed_location), | 214 Shell::GetContainer(wm::GetRootWindowMatching(near_passed_location), |
| 216 internal::kShellWindowId_DockedContainer); | 215 kShellWindowId_DockedContainer); |
| 217 internal::DockedWindowLayoutManager* dock_layout = | 216 DockedWindowLayoutManager* dock_layout = |
| 218 static_cast<internal::DockedWindowLayoutManager*>( | 217 static_cast<DockedWindowLayoutManager*>( |
| 219 dock_container->layout_manager()); | 218 dock_container->layout_manager()); |
| 220 | 219 |
| 221 gfx::Rect screen_work_area = display.work_area(); | 220 gfx::Rect screen_work_area = display.work_area(); |
| 222 screen_work_area.Union(dock_layout->docked_bounds()); | 221 screen_work_area.Union(dock_layout->docked_bounds()); |
| 223 screen_work_area.Inset(kMinimumOnScreenArea, 0); | 222 screen_work_area.Inset(kMinimumOnScreenArea, 0); |
| 224 gfx::Rect new_bounds_in_screen = | 223 gfx::Rect new_bounds_in_screen = |
| 225 ScreenUtil::ConvertRectToScreen(parent, new_bounds); | 224 ScreenUtil::ConvertRectToScreen(parent, new_bounds); |
| 226 if (!screen_work_area.Intersects(new_bounds_in_screen)) { | 225 if (!screen_work_area.Intersects(new_bounds_in_screen)) { |
| 227 // Make sure that the x origin does not leave the current display. | 226 // Make sure that the x origin does not leave the current display. |
| 228 new_bounds_in_screen.set_x( | 227 new_bounds_in_screen.set_x( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 if (height > max_height) { | 348 if (height > max_height) { |
| 350 height = max_height; | 349 height = max_height; |
| 351 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - | 350 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - |
| 352 max_height); | 351 max_height); |
| 353 } | 352 } |
| 354 } | 353 } |
| 355 return height; | 354 return height; |
| 356 } | 355 } |
| 357 | 356 |
| 358 } // namespace ash | 357 } // namespace ash |
| OLD | NEW |