Index: ash/wm/window_resizer.cc |
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc |
index 1609c3d41e1eb3cdee17d0df91a893c394243d6f..af79954abcbe9d4e2dbe9bde6843e144fc887862 100644 |
--- a/ash/wm/window_resizer.cc |
+++ b/ash/wm/window_resizer.cc |
@@ -8,11 +8,14 @@ |
#include "ash/wm/window_positioning_utils.h" |
#include "ash/wm/window_state.h" |
#include "ash/wm_window.h" |
+#include "ui/aura/window.h" |
+#include "ui/aura/window_delegate.h" |
#include "ui/base/hit_test.h" |
#include "ui/base/ui_base_types.h" |
#include "ui/display/display.h" |
#include "ui/display/screen.h" |
#include "ui/gfx/geometry/rect.h" |
+#include "ui/wm/core/coordinate_conversion.h" |
namespace ash { |
@@ -103,6 +106,10 @@ int WindowResizer::GetPositionChangeDirectionForWindowComponent( |
return pos_change_direction; |
} |
+aura::Window* WindowResizer::GetTarget() const { |
+ return window_state_ ? window_state_->window()->aura_window() : nullptr; |
+} |
+ |
gfx::Rect WindowResizer::CalculateBoundsForDrag( |
const gfx::Point& passed_location) { |
if (!details().is_resizable) |
@@ -125,8 +132,10 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( |
// has to come first since it might have an impact on the origin as well as |
// on the size. |
if (details().bounds_change & kBoundsChange_Resizes) { |
- gfx::Rect work_area = GetTarget()->GetDisplayNearestWindow().work_area(); |
- work_area = GetTarget()->GetParent()->ConvertRectFromScreen(work_area); |
+ gfx::Rect work_area = display::Screen::GetScreen() |
+ ->GetDisplayNearestWindow(GetTarget()) |
+ .work_area(); |
+ ::wm::ConvertRectFromScreen(GetTarget()->parent(), &work_area); |
if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { |
if (IsRightEdge(details().window_component) && |
new_bounds.right() < work_area.x() + wm::kMinimumOnScreenArea) { |
@@ -180,9 +189,9 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( |
// Make sure that |new_bounds| doesn't leave any of the displays. Note that |
// the |work_area| above isn't good for this check since it is the work area |
// for the current display but the window can move to a different one. |
- WmWindow* parent = GetTarget()->GetParent(); |
- gfx::Point passed_location_in_screen( |
- parent->ConvertPointToScreen(passed_location)); |
+ aura::Window* parent = GetTarget()->parent(); |
+ gfx::Point passed_location_in_screen(passed_location); |
+ ::wm::ConvertPointToScreen(parent, &passed_location_in_screen); |
gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); |
// Use a pointer location (matching the logic in DragWindowResizer) to |
// calculate the target display after the drag. |
@@ -190,13 +199,15 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( |
display::Screen::GetScreen()->GetDisplayMatching(near_passed_location); |
gfx::Rect screen_work_area = display.work_area(); |
screen_work_area.Inset(wm::kMinimumOnScreenArea, 0); |
- gfx::Rect new_bounds_in_screen = parent->ConvertRectToScreen(new_bounds); |
+ gfx::Rect new_bounds_in_screen(new_bounds); |
+ ::wm::ConvertRectToScreen(parent, &new_bounds_in_screen); |
if (!screen_work_area.Intersects(new_bounds_in_screen)) { |
// Make sure that the x origin does not leave the current display. |
new_bounds_in_screen.set_x(std::max( |
screen_work_area.x() - new_bounds.width(), |
std::min(screen_work_area.right(), new_bounds_in_screen.x()))); |
- new_bounds = parent->ConvertRectFromScreen(new_bounds_in_screen); |
+ new_bounds = new_bounds_in_screen; |
+ ::wm::ConvertRectFromScreen(parent, &new_bounds); |
} |
} |
@@ -250,7 +261,9 @@ gfx::Point WindowResizer::GetOriginForDrag(int delta_x, int delta_y) { |
gfx::Size WindowResizer::GetSizeForDrag(int* delta_x, int* delta_y) { |
gfx::Size size = details().initial_bounds_in_parent.size(); |
if (details().bounds_change & kBoundsChange_Resizes) { |
- gfx::Size min_size = GetTarget()->GetMinimumSize(); |
+ gfx::Size min_size = GetTarget()->delegate() |
+ ? GetTarget()->delegate()->GetMinimumSize() |
+ : gfx::Size(); |
size.SetSize(GetWidthForDrag(min_size.width(), delta_x), |
GetHeightForDrag(min_size.height(), delta_y)); |
} else if (!details().restore_bounds.IsEmpty()) { |
@@ -275,8 +288,13 @@ int WindowResizer::GetWidthForDrag(int min_width, int* delta_x) { |
} |
// And don't let the window go bigger than the display. |
- int max_width = GetTarget()->GetDisplayNearestWindow().bounds().width(); |
- gfx::Size max_size = GetTarget()->GetMaximumSize(); |
+ int max_width = display::Screen::GetScreen() |
+ ->GetDisplayNearestWindow(GetTarget()) |
+ .bounds() |
+ .width(); |
+ gfx::Size max_size = GetTarget()->delegate() |
+ ? GetTarget()->delegate()->GetMaximumSize() |
+ : gfx::Size(); |
if (max_size.width() != 0) |
max_width = std::min(max_width, max_size.width()); |
if (width > max_width) { |
@@ -304,8 +322,13 @@ int WindowResizer::GetHeightForDrag(int min_height, int* delta_y) { |
} |
// And don't let the window go bigger than the display. |
- int max_height = GetTarget()->GetDisplayNearestWindow().bounds().height(); |
- gfx::Size max_size = GetTarget()->GetMaximumSize(); |
+ int max_height = display::Screen::GetScreen() |
+ ->GetDisplayNearestWindow(GetTarget()) |
+ .bounds() |
+ .height(); |
+ gfx::Size max_size = GetTarget()->delegate() |
+ ? GetTarget()->delegate()->GetMaximumSize() |
+ : gfx::Size(); |
if (max_size.height() != 0) |
max_height = std::min(max_height, max_size.height()); |
if (height > max_height) { |