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

Side by Side Diff: ash/wm/window_resizer.cc

Issue 10834097: Allow the user to drag a window from one display to another (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/window_resizer.h" 5 #include "ash/wm/window_resizer.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/screen_position_client.h"
10 #include "ui/aura/root_window.h" 11 #include "ui/aura/root_window.h"
11 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
12 #include "ui/aura/window_delegate.h" 13 #include "ui/aura/window_delegate.h"
13 #include "ui/base/hit_test.h" 14 #include "ui/base/hit_test.h"
14 #include "ui/base/ui_base_types.h" 15 #include "ui/base/ui_base_types.h"
15 #include "ui/compositor/scoped_layer_animation_settings.h" 16 #include "ui/compositor/scoped_layer_animation_settings.h"
16 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
17 18
18 namespace ash { 19 namespace ash {
19 20
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // static 177 // static
177 int WindowResizer::AlignToGridRoundDown(int location, int grid_size) { 178 int WindowResizer::AlignToGridRoundDown(int location, int grid_size) {
178 if (grid_size <= 1 || location % grid_size == 0) 179 if (grid_size <= 1 || location % grid_size == 0)
179 return location; 180 return location;
180 return location / grid_size * grid_size; 181 return location / grid_size * grid_size;
181 } 182 }
182 183
183 // static 184 // static
184 gfx::Rect WindowResizer::CalculateBoundsForDrag( 185 gfx::Rect WindowResizer::CalculateBoundsForDrag(
185 const Details& details, 186 const Details& details,
186 const gfx::Point& location, 187 const gfx::Point& location_in_screen,
187 int grid_size) { 188 int grid_size) {
188 if (!details.is_resizable) 189 if (!details.is_resizable)
189 return details.initial_bounds; 190 return details.initial_bounds;
190 191
192 gfx::Point location = location_in_screen;
193 aura::client::GetScreenPositionClient(details.window->GetRootWindow())->
194 ConvertPointFromScreen(details.window->GetRootWindow(), &location);
195
191 int delta_x = location.x() - details.initial_location_in_parent.x(); 196 int delta_x = location.x() - details.initial_location_in_parent.x();
192 int delta_y = location.y() - details.initial_location_in_parent.y(); 197 int delta_y = location.y() - details.initial_location_in_parent.y();
193 198
194 // The minimize size constraint may limit how much we change the window 199 // The minimize size constraint may limit how much we change the window
195 // position. For example, dragging the left edge to the right should stop 200 // position. For example, dragging the left edge to the right should stop
196 // repositioning the window when the minimize size is reached. 201 // repositioning the window when the minimize size is reached.
197 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y, grid_size); 202 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y, grid_size);
198 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); 203 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y);
199 204
200 gfx::Rect new_bounds(origin, size); 205 gfx::Rect new_bounds(origin, size);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height(); 337 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height();
333 if (height > max_height) { 338 if (height > max_height) {
334 height = max_height; 339 height = max_height;
335 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); 340 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height);
336 } 341 }
337 } 342 }
338 return height; 343 return height;
339 } 344 }
340 345
341 } // namespace aura 346 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698