diff options
author | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 18:05:47 +0000 |
---|---|---|
committer | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 18:05:47 +0000 |
commit | 88fa8bf4bdda72610f727a0a3f7ce5e4fd7d2dc4 (patch) | |
tree | 63f8754188d4f1f7ec35e0e07b3bd11d98f060ca /ash/wm/window_resizer.cc | |
parent | 75ffa6b04b62224ba97d4b4a6f932ee1effe134e (diff) | |
download | chromium_src-88fa8bf4bdda72610f727a0a3f7ce5e4fd7d2dc4.zip chromium_src-88fa8bf4bdda72610f727a0a3f7ce5e4fd7d2dc4.tar.gz chromium_src-88fa8bf4bdda72610f727a0a3f7ce5e4fd7d2dc4.tar.bz2 |
Adding proper dragging behavior for L/R maximized windows.
BUG=141750
TEST=unit tests & visual
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=155840
Review URL: https://chromiumcodereview.appspot.com/10918077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156058 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/window_resizer.cc')
-rw-r--r-- | ash/wm/window_resizer.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc index 592fd81..c759c91 100644 --- a/ash/wm/window_resizer.cc +++ b/ash/wm/window_resizer.cc @@ -6,6 +6,8 @@ #include "ash/screen_ash.h" #include "ash/shell.h" +#include "ash/wm/property_util.h" +#include "ash/wm/window_util.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" @@ -112,6 +114,7 @@ WindowResizer::Details::Details(aura::Window* window, int window_component) : window(window), initial_bounds(window->bounds()), + restore_bounds(gfx::Rect()), initial_location_in_parent(location), initial_opacity(window->layer()->opacity()), window_component(window_component), @@ -121,6 +124,10 @@ WindowResizer::Details::Details(aura::Window* window, size_change_direction( GetSizeChangeDirectionForWindowComponent(window_component)), is_resizable(bounds_change != kBoundsChangeDirection_None) { + if (wm::IsWindowNormal(window) && + GetRestoreBoundsInScreen(window) && + window_component == HTCAPTION) + restore_bounds = *GetRestoreBoundsInScreen(window); } WindowResizer::Details::~Details() { @@ -175,6 +182,17 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y); gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); + // When we might want to reposition a window which is also restored to its + // previous size, to keep the cursor within the dragged window. + if (!details.restore_bounds.IsEmpty() && + details.bounds_change & kBoundsChange_Repositions) { + // However - it is not desirable to change the origin if the window would + // be still hit by the cursor. + if (details.initial_location_in_parent.x() > + details.initial_bounds.x() + details.restore_bounds.width()) + origin.set_x(location.x() - details.restore_bounds.width() / 2); + } + gfx::Rect new_bounds(origin, size); // Update bottom edge to stay in the work area when we are resizing // by dragging the bottome edge or corners. @@ -229,6 +247,8 @@ gfx::Size WindowResizer::GetSizeForDrag(const Details& details, gfx::Size min_size = details.window->delegate()->GetMinimumSize(); size.SetSize(GetWidthForDrag(details, min_size.width(), delta_x), GetHeightForDrag(details, min_size.height(), delta_y)); + } else if (!details.restore_bounds.IsEmpty()) { + size = details.restore_bounds.size(); } return size; } |