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

Unified Diff: ash/wm/window_resizer.cc

Issue 15008002: Make touch-resizing windows to screen edge possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move border immediately under the finger + change snapping distance back to 16 Created 7 years, 6 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 3773d0735099072ee932d1ffc915df274181a16b..2be726ad04211682f511753477bb6384dd04710a 100644
--- a/ash/wm/window_resizer.cc
+++ b/ash/wm/window_resizer.cc
@@ -107,12 +107,14 @@ WindowResizer::Details::Details()
bounds_change(0),
position_change_direction(0),
size_change_direction(0),
- is_resizable(false) {
+ is_resizable(false),
+ source(aura::client::WINDOW_MOVE_SOURCE_MOUSE) {
}
WindowResizer::Details::Details(aura::Window* window,
const gfx::Point& location,
- int window_component)
+ int window_component,
+ aura::client::WindowMoveSource source)
: window(window),
initial_bounds_in_parent(window->bounds()),
restore_bounds(gfx::Rect()),
@@ -124,7 +126,8 @@ WindowResizer::Details::Details(aura::Window* window,
GetPositionChangeDirectionForWindowComponent(window_component)),
size_change_direction(
GetSizeChangeDirectionForWindowComponent(window_component)),
- is_resizable(bounds_change != kBoundsChangeDirection_None) {
+ is_resizable(bounds_change != kBoundsChangeDirection_None),
+ source(source) {
if (wm::IsWindowNormal(window) &&
GetRestoreBoundsInScreen(window) &&
window_component == HTCAPTION)
@@ -181,6 +184,8 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag(
int delta_x = location.x() - details.initial_location_in_parent.x();
int delta_y = location.y() - details.initial_location_in_parent.y();
+ AdjustDeltaForTouchResize(details, &delta_x, &delta_y);
+
// The minimize size constraint may limit how much we change the window
// position. For example, dragging the left edge to the right should stop
// repositioning the window when the minimize size is reached.
@@ -265,6 +270,34 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag(
}
// static
+void WindowResizer::AdjustDeltaForTouchResize(const Details& details,
+ int* delta_x,
+ int* delta_y) {
+ if (details.source != aura::client::WINDOW_MOVE_SOURCE_TOUCH ||
+ !(details.bounds_change & kBoundsChange_Resizes))
+ return;
+
+ if (details.size_change_direction & kBoundsChangeDirection_Horizontal) {
+ if (IsRightEdge(details.window_component)) {
+ *delta_x += details.initial_location_in_parent.x() -
+ details.initial_bounds_in_parent.right();
sky 2013/06/14 15:57:27 nit: indent this 2 more (same on 286, 292 and 295)
mohsen 2013/06/14 16:21:48 Done.
+ } else {
+ *delta_x += details.initial_location_in_parent.x() -
+ details.initial_bounds_in_parent.x();
+ }
+ }
+ if (details.size_change_direction & kBoundsChangeDirection_Vertical) {
+ if (IsBottomEdge(details.window_component)) {
+ *delta_y += details.initial_location_in_parent.y() -
+ details.initial_bounds_in_parent.bottom();
+ } else {
+ *delta_y += details.initial_location_in_parent.y() -
+ details.initial_bounds_in_parent.y();
+ }
+ }
+}
+
+// static
bool WindowResizer::IsBottomEdge(int window_component) {
return window_component == HTBOTTOMLEFT ||
window_component == HTBOTTOM ||

Powered by Google App Engine
This is Rietveld 408576698