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

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

Issue 9467021: Attempt 3: Makes managed mode constrain the height of windows so they don't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Da fix Created 8 years, 10 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
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_event_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/root_window_event_filter.h" 8 #include "ash/wm/root_window_event_filter.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 gfx::Rect bounds = GetBoundsForDrag(location); 198 gfx::Rect bounds = GetBoundsForDrag(location);
199 if (bounds != window_->bounds()) { 199 if (bounds != window_->bounds()) {
200 did_move_or_resize_ = true; 200 did_move_or_resize_ = true;
201 window_->SetBounds(bounds); 201 window_->SetBounds(bounds);
202 } 202 }
203 } 203 }
204 204
205 void WindowResizer::CompleteDrag() { 205 void WindowResizer::CompleteDrag() {
206 if (grid_size_ <= 1 || !did_move_or_resize_) 206 if (grid_size_ <= 1 || !did_move_or_resize_)
207 return; 207 return;
208 const gfx::Rect& bounds(window_->bounds()); 208 gfx::Rect new_bounds(GetFinalBounds());
209 int x = AlignToGrid(bounds.x(), grid_size_);
210 int y = AlignToGrid(bounds.y(), grid_size_);
211 gfx::Rect new_bounds(x, y, bounds.width(), bounds.height());
212 if (new_bounds == window_->bounds()) 209 if (new_bounds == window_->bounds())
213 return; 210 return;
214 211
212 if (new_bounds.size() != window_->bounds().size()) {
213 // Don't attempt to animate a size change.
214 window_->SetBounds(new_bounds);
215 return;
216 }
217
215 ui::ScopedLayerAnimationSettings scoped_setter( 218 ui::ScopedLayerAnimationSettings scoped_setter(
216 window_->layer()->GetAnimator()); 219 window_->layer()->GetAnimator());
217 // Use a small duration since the grid is small. 220 // Use a small duration since the grid is small.
218 scoped_setter.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); 221 scoped_setter.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100));
219 window_->SetBounds(new_bounds); 222 window_->SetBounds(new_bounds);
220 } 223 }
221 224
222 gfx::Rect WindowResizer::GetBoundsForDrag(const gfx::Point& location) { 225 gfx::Rect WindowResizer::GetBoundsForDrag(const gfx::Point& location) {
223 if (!is_resizable()) 226 if (!is_resizable())
224 return window_->bounds(); 227 return window_->bounds();
(...skipping 24 matching lines...) Expand all
249 } 252 }
250 if (bounds_change_ & kBoundsChange_Resizes && 253 if (bounds_change_ & kBoundsChange_Resizes &&
251 bounds_change_ & kBoundsChange_Repositions && new_bounds.y() < 0) { 254 bounds_change_ & kBoundsChange_Repositions && new_bounds.y() < 0) {
252 int delta = new_bounds.y(); 255 int delta = new_bounds.y();
253 new_bounds.set_y(0); 256 new_bounds.set_y(0);
254 new_bounds.set_height(new_bounds.height() + delta); 257 new_bounds.set_height(new_bounds.height() + delta);
255 } 258 }
256 return new_bounds; 259 return new_bounds;
257 } 260 }
258 261
262 gfx::Rect WindowResizer::GetFinalBounds() {
263 const gfx::Rect& bounds(window_->bounds());
264 int x = AlignToGrid(bounds.x(), grid_size_);
265 int y = AlignToGrid(bounds.y(), grid_size_);
266 return gfx::Rect(x, y, bounds.width(), bounds.height());
267 }
268
259 gfx::Point WindowResizer::GetOriginForDrag( 269 gfx::Point WindowResizer::GetOriginForDrag(
260 int delta_x, 270 int delta_x,
261 int delta_y) const { 271 int delta_y) const {
262 gfx::Point origin = initial_bounds_.origin(); 272 gfx::Point origin = initial_bounds_.origin();
263 if (bounds_change_ & kBoundsChange_Repositions) { 273 if (bounds_change_ & kBoundsChange_Repositions) {
264 int pos_change_direction = 274 int pos_change_direction =
265 GetPositionChangeDirectionForWindowComponent(window_component_); 275 GetPositionChangeDirectionForWindowComponent(window_component_);
266 if (pos_change_direction & kBoundsChangeDirection_Horizontal) 276 if (pos_change_direction & kBoundsChangeDirection_Horizontal)
267 origin.Offset(delta_x, 0); 277 origin.Offset(delta_x, 0);
268 if (pos_change_direction & kBoundsChangeDirection_Vertical) 278 if (pos_change_direction & kBoundsChangeDirection_Vertical)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 int max_height = gfx::Screen::GetMonitorAreaNearestWindow(window_).height(); 348 int max_height = gfx::Screen::GetMonitorAreaNearestWindow(window_).height();
339 if (height > max_height) { 349 if (height > max_height) {
340 height = max_height; 350 height = max_height;
341 *delta_y = -y_multiplier * (initial_bounds_.height() - max_height); 351 *delta_y = -y_multiplier * (initial_bounds_.height() - max_height);
342 } 352 }
343 } 353 }
344 return height; 354 return height;
345 } 355 }
346 356
347 } // namespace aura 357 } // namespace aura
OLDNEW
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698