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

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: Adjust unit tests with final behavior 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
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_resizer.cc
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc
index 3773d0735099072ee932d1ffc915df274181a16b..41a40119ea15b5fa3d5ff346154d113f652ae4e2 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.
@@ -273,6 +278,34 @@ bool WindowResizer::IsBottomEdge(int window_component) {
}
// 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();
+ } 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
gfx::Point WindowResizer::GetOriginForDrag(const Details& details,
int delta_x,
int delta_y) {
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698