Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Unified Diff: ash/wm/window_resizer.cc

Issue 10918077: Adding proper dragging behavior for L/R maximized windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wm/window_resizer.cc
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc
index 623be33368d37c62f586e765b8446787987e5609..cb60fb90f7ad5950af673cb78f8b30a208216ff3 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"
@@ -100,6 +102,7 @@ const int WindowResizer::kBoundsChangeDirection_Vertical = 2;
WindowResizer::Details::Details()
: window(NULL),
+ restore_bounds(gfx::Rect()),
sky 2012/09/07 02:43:30 not necessary.
Mr4D (OOO till 08-26) 2012/09/08 01:17:41 Done.
window_component(HTNOWHERE),
bounds_change(0),
position_change_direction(0),
@@ -112,6 +115,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 +125,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() {
@@ -198,6 +206,12 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag(
gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y, grid_size);
gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y);
+ // When we reposition a window which is also restored to its previous size,
+ // we center the window around the cursor.
+ if (!details.restore_bounds.IsEmpty() &&
+ details.bounds_change & kBoundsChange_Repositions)
+ origin.set_x(location.x() - details.restore_bounds.width() / 2);
sky 2012/09/07 15:46:15 One more comment here. Centering is going to be eq
Mr4D (OOO till 08-26) 2012/09/07 16:45:33 I tried it actually this way and I found it this w
+
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.
@@ -267,6 +281,9 @@ gfx::Size WindowResizer::GetSizeForDrag(const Details& details,
grid_size),
GetHeightForDrag(details, min_size.height(), delta_y,
grid_size));
+ } else {
sky 2012/09/07 02:43:30 else if
Mr4D (OOO till 08-26) 2012/09/08 01:17:41 Done.
+ if (!details.restore_bounds.IsEmpty())
+ size = details.restore_bounds.size();
}
return size;
}

Powered by Google App Engine
This is Rietveld 408576698