| 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/common/window_positioning_utils.h" |
| 10 #include "ash/wm/coordinate_conversion.h" | 11 #include "ash/wm/coordinate_conversion.h" |
| 11 #include "ash/wm/dock/docked_window_layout_manager.h" | 12 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 12 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 13 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_delegate.h" | 17 #include "ui/aura/window_delegate.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
| 19 #include "ui/base/ui_base_types.h" | 20 #include "ui/base/ui_base_types.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 GetTarget()->GetRootWindow(), kShellWindowId_DockedContainer); | 145 GetTarget()->GetRootWindow(), kShellWindowId_DockedContainer); |
| 145 DockedWindowLayoutManager* dock_layout = | 146 DockedWindowLayoutManager* dock_layout = |
| 146 static_cast<DockedWindowLayoutManager*>( | 147 static_cast<DockedWindowLayoutManager*>( |
| 147 dock_container->layout_manager()); | 148 dock_container->layout_manager()); |
| 148 | 149 |
| 149 work_area.Union(dock_layout->docked_bounds()); | 150 work_area.Union(dock_layout->docked_bounds()); |
| 150 work_area = ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), | 151 work_area = ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), |
| 151 work_area); | 152 work_area); |
| 152 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { | 153 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { |
| 153 if (IsRightEdge(details().window_component) && | 154 if (IsRightEdge(details().window_component) && |
| 154 new_bounds.right() < work_area.x() + kMinimumOnScreenArea) { | 155 new_bounds.right() < work_area.x() + wm::kMinimumOnScreenArea) { |
| 155 int delta = work_area.x() + kMinimumOnScreenArea - new_bounds.right(); | 156 int delta = |
| 157 work_area.x() + wm::kMinimumOnScreenArea - new_bounds.right(); |
| 156 new_bounds.set_width(new_bounds.width() + delta); | 158 new_bounds.set_width(new_bounds.width() + delta); |
| 157 } else if (new_bounds.x() > work_area.right() - kMinimumOnScreenArea) { | 159 } else if (new_bounds.x() > |
| 158 int width = new_bounds.right() - work_area.right() + | 160 work_area.right() - wm::kMinimumOnScreenArea) { |
| 159 kMinimumOnScreenArea; | 161 int width = |
| 160 new_bounds.set_x(work_area.right() - kMinimumOnScreenArea); | 162 new_bounds.right() - work_area.right() + wm::kMinimumOnScreenArea; |
| 163 new_bounds.set_x(work_area.right() - wm::kMinimumOnScreenArea); |
| 161 new_bounds.set_width(width); | 164 new_bounds.set_width(width); |
| 162 } | 165 } |
| 163 } | 166 } |
| 164 if (details().size_change_direction & kBoundsChangeDirection_Vertical) { | 167 if (details().size_change_direction & kBoundsChangeDirection_Vertical) { |
| 165 if (!IsBottomEdge(details().window_component) && | 168 if (!IsBottomEdge(details().window_component) && |
| 166 new_bounds.y() > work_area.bottom() - kMinimumOnScreenArea) { | 169 new_bounds.y() > work_area.bottom() - wm::kMinimumOnScreenArea) { |
| 167 int height = new_bounds.bottom() - work_area.bottom() + | 170 int height = |
| 168 kMinimumOnScreenArea; | 171 new_bounds.bottom() - work_area.bottom() + wm::kMinimumOnScreenArea; |
| 169 new_bounds.set_y(work_area.bottom() - kMinimumOnScreenArea); | 172 new_bounds.set_y(work_area.bottom() - wm::kMinimumOnScreenArea); |
| 170 new_bounds.set_height(height); | 173 new_bounds.set_height(height); |
| 171 } else if (details().window_component == HTBOTTOM || | 174 } else if (details().window_component == HTBOTTOM || |
| 172 details().window_component == HTBOTTOMRIGHT || | 175 details().window_component == HTBOTTOMRIGHT || |
| 173 details().window_component == HTBOTTOMLEFT) { | 176 details().window_component == HTBOTTOMLEFT) { |
| 174 // Update bottom edge to stay in the work area when we are resizing | 177 // Update bottom edge to stay in the work area when we are resizing |
| 175 // by dragging the bottom edge or corners. | 178 // by dragging the bottom edge or corners. |
| 176 if (new_bounds.bottom() > work_area.bottom()) | 179 if (new_bounds.bottom() > work_area.bottom()) |
| 177 new_bounds.Inset(0, 0, 0, | 180 new_bounds.Inset(0, 0, 0, |
| 178 new_bounds.bottom() - work_area.bottom()); | 181 new_bounds.bottom() - work_area.bottom()); |
| 179 } | 182 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 gfx::Screen::GetScreen()->GetDisplayMatching(near_passed_location); | 214 gfx::Screen::GetScreen()->GetDisplayMatching(near_passed_location); |
| 212 aura::Window* dock_container = | 215 aura::Window* dock_container = |
| 213 Shell::GetContainer(wm::GetRootWindowMatching(near_passed_location), | 216 Shell::GetContainer(wm::GetRootWindowMatching(near_passed_location), |
| 214 kShellWindowId_DockedContainer); | 217 kShellWindowId_DockedContainer); |
| 215 DockedWindowLayoutManager* dock_layout = | 218 DockedWindowLayoutManager* dock_layout = |
| 216 static_cast<DockedWindowLayoutManager*>( | 219 static_cast<DockedWindowLayoutManager*>( |
| 217 dock_container->layout_manager()); | 220 dock_container->layout_manager()); |
| 218 | 221 |
| 219 gfx::Rect screen_work_area = display.work_area(); | 222 gfx::Rect screen_work_area = display.work_area(); |
| 220 screen_work_area.Union(dock_layout->docked_bounds()); | 223 screen_work_area.Union(dock_layout->docked_bounds()); |
| 221 screen_work_area.Inset(kMinimumOnScreenArea, 0); | 224 screen_work_area.Inset(wm::kMinimumOnScreenArea, 0); |
| 222 gfx::Rect new_bounds_in_screen = | 225 gfx::Rect new_bounds_in_screen = |
| 223 ScreenUtil::ConvertRectToScreen(parent, new_bounds); | 226 ScreenUtil::ConvertRectToScreen(parent, new_bounds); |
| 224 if (!screen_work_area.Intersects(new_bounds_in_screen)) { | 227 if (!screen_work_area.Intersects(new_bounds_in_screen)) { |
| 225 // Make sure that the x origin does not leave the current display. | 228 // Make sure that the x origin does not leave the current display. |
| 226 new_bounds_in_screen.set_x( | 229 new_bounds_in_screen.set_x( |
| 227 std::max(screen_work_area.x() - new_bounds.width(), | 230 std::max(screen_work_area.x() - new_bounds.width(), |
| 228 std::min(screen_work_area.right(), | 231 std::min(screen_work_area.right(), |
| 229 new_bounds_in_screen.x()))); | 232 new_bounds_in_screen.x()))); |
| 230 new_bounds = | 233 new_bounds = |
| 231 ScreenUtil::ConvertRectFromScreen(parent, new_bounds_in_screen); | 234 ScreenUtil::ConvertRectFromScreen(parent, new_bounds_in_screen); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 if (height > max_height) { | 354 if (height > max_height) { |
| 352 height = max_height; | 355 height = max_height; |
| 353 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - | 356 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - |
| 354 max_height); | 357 max_height); |
| 355 } | 358 } |
| 356 } | 359 } |
| 357 return height; | 360 return height; |
| 358 } | 361 } |
| 359 | 362 |
| 360 } // namespace ash | 363 } // namespace ash |
| OLD | NEW |