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

Side by Side 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 first set of comments 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 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 "ash/wm/property_util.h"
10 #include "ash/wm/window_util.h"
9 #include "ui/aura/client/aura_constants.h" 11 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
11 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
12 #include "ui/aura/window_delegate.h" 14 #include "ui/aura/window_delegate.h"
13 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
14 #include "ui/base/ui_base_types.h" 16 #include "ui/base/ui_base_types.h"
15 #include "ui/compositor/scoped_layer_animation_settings.h" 17 #include "ui/compositor/scoped_layer_animation_settings.h"
16 #include "ui/gfx/screen.h" 18 #include "ui/gfx/screen.h"
17 19
18 namespace ash { 20 namespace ash {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 95
94 // static 96 // static
95 const int WindowResizer::kBoundsChangeDirection_None = 0; 97 const int WindowResizer::kBoundsChangeDirection_None = 0;
96 // static 98 // static
97 const int WindowResizer::kBoundsChangeDirection_Horizontal = 1; 99 const int WindowResizer::kBoundsChangeDirection_Horizontal = 1;
98 // static 100 // static
99 const int WindowResizer::kBoundsChangeDirection_Vertical = 2; 101 const int WindowResizer::kBoundsChangeDirection_Vertical = 2;
100 102
101 WindowResizer::Details::Details() 103 WindowResizer::Details::Details()
102 : window(NULL), 104 : window(NULL),
105 restore_bounds(gfx::Rect()),
103 window_component(HTNOWHERE), 106 window_component(HTNOWHERE),
104 bounds_change(0), 107 bounds_change(0),
105 position_change_direction(0), 108 position_change_direction(0),
106 size_change_direction(0), 109 size_change_direction(0),
107 is_resizable(false) { 110 is_resizable(false) {
108 } 111 }
109 112
110 WindowResizer::Details::Details(aura::Window* window, 113 WindowResizer::Details::Details(aura::Window* window,
111 const gfx::Point& location, 114 const gfx::Point& location,
112 int window_component) 115 int window_component)
113 : window(window), 116 : window(window),
114 initial_bounds(window->bounds()), 117 initial_bounds(window->bounds()),
118 restore_bounds(gfx::Rect()),
115 initial_location_in_parent(location), 119 initial_location_in_parent(location),
116 initial_opacity(window->layer()->opacity()), 120 initial_opacity(window->layer()->opacity()),
117 window_component(window_component), 121 window_component(window_component),
118 bounds_change(GetBoundsChangeForWindowComponent(window_component)), 122 bounds_change(GetBoundsChangeForWindowComponent(window_component)),
119 position_change_direction( 123 position_change_direction(
120 GetPositionChangeDirectionForWindowComponent(window_component)), 124 GetPositionChangeDirectionForWindowComponent(window_component)),
121 size_change_direction( 125 size_change_direction(
122 GetSizeChangeDirectionForWindowComponent(window_component)), 126 GetSizeChangeDirectionForWindowComponent(window_component)),
123 is_resizable(bounds_change != kBoundsChangeDirection_None) { 127 is_resizable(bounds_change != kBoundsChangeDirection_None) {
128 if (wm::IsWindowNormal(window) &&
129 GetRestoreBoundsInScreen(window) &&
130 window_component == HTCAPTION)
131 restore_bounds = *GetRestoreBoundsInScreen(window);
124 } 132 }
125 133
126 WindowResizer::Details::~Details() { 134 WindowResizer::Details::~Details() {
127 } 135 }
128 136
129 WindowResizer::WindowResizer() { 137 WindowResizer::WindowResizer() {
130 } 138 }
131 139
132 WindowResizer::~WindowResizer() { 140 WindowResizer::~WindowResizer() {
133 } 141 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 int grid_size) { 268 int grid_size) {
261 gfx::Size size = details.initial_bounds.size(); 269 gfx::Size size = details.initial_bounds.size();
262 if (details.bounds_change & kBoundsChange_Resizes) { 270 if (details.bounds_change & kBoundsChange_Resizes) {
263 gfx::Size min_size = details.window->delegate()->GetMinimumSize(); 271 gfx::Size min_size = details.window->delegate()->GetMinimumSize();
264 min_size.set_width(AlignToGridRoundUp(min_size.width(), grid_size)); 272 min_size.set_width(AlignToGridRoundUp(min_size.width(), grid_size));
265 min_size.set_height(AlignToGridRoundUp(min_size.height(), grid_size)); 273 min_size.set_height(AlignToGridRoundUp(min_size.height(), grid_size));
266 size.SetSize(GetWidthForDrag(details, min_size.width(), delta_x, 274 size.SetSize(GetWidthForDrag(details, min_size.width(), delta_x,
267 grid_size), 275 grid_size),
268 GetHeightForDrag(details, min_size.height(), delta_y, 276 GetHeightForDrag(details, min_size.height(), delta_y,
269 grid_size)); 277 grid_size));
278 } else {
279 if (!details.restore_bounds.IsEmpty())
280 size = details.restore_bounds.size();
sky 2012/09/06 19:45:11 You may need to adjust the origin too. Consider th
Mr4D (OOO till 08-26) 2012/09/06 23:16:13 I was first tempted to say that this was taken car
270 } 281 }
271 return size; 282 return size;
272 } 283 }
273 284
274 // static 285 // static
275 int WindowResizer::GetWidthForDrag(const Details& details, 286 int WindowResizer::GetWidthForDrag(const Details& details,
276 int min_width, 287 int min_width,
277 int* delta_x, 288 int* delta_x,
278 int grid_size) { 289 int grid_size) {
279 int width = details.initial_bounds.width(); 290 int width = details.initial_bounds.width();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height(); 344 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height();
334 if (height > max_height) { 345 if (height > max_height) {
335 height = max_height; 346 height = max_height;
336 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); 347 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height);
337 } 348 }
338 } 349 }
339 return height; 350 return height;
340 } 351 }
341 352
342 } // namespace aura 353 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698