Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / ash / wm / default_window_resizer.cc
blobac0042d000e9482149de1b1fd50a7d5c4ee8f234
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
3 // found in the LICENSE file.
5 #include "ash/wm/default_window_resizer.h"
7 #include "ash/shell.h"
8 #include "ash/wm/window_state.h"
9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/env.h"
11 #include "ui/aura/window.h"
12 #include "ui/aura/window_delegate.h"
13 #include "ui/base/hit_test.h"
14 #include "ui/base/ui_base_types.h"
15 #include "ui/gfx/screen.h"
17 namespace ash {
19 DefaultWindowResizer::~DefaultWindowResizer() {
20 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
23 // static
24 DefaultWindowResizer*
25 DefaultWindowResizer::Create(wm::WindowState* window_state) {
26 return new DefaultWindowResizer(window_state);
29 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) {
30 gfx::Rect bounds(CalculateBoundsForDrag(location));
31 if (bounds != GetTarget()->bounds()) {
32 if (!did_move_or_resize_ && !details().restore_bounds.IsEmpty())
33 window_state_->ClearRestoreBounds();
34 did_move_or_resize_ = true;
35 GetTarget()->SetBounds(bounds);
39 void DefaultWindowResizer::CompleteDrag() {
42 void DefaultWindowResizer::RevertDrag() {
43 if (!did_move_or_resize_)
44 return;
46 GetTarget()->SetBounds(details().initial_bounds_in_parent);
48 if (!details().restore_bounds.IsEmpty())
49 window_state_->SetRestoreBoundsInScreen(details().restore_bounds);
52 DefaultWindowResizer::DefaultWindowResizer(wm::WindowState* window_state)
53 : WindowResizer(window_state),
54 did_move_or_resize_(false) {
55 DCHECK(details().is_resizable);
56 ash::Shell::GetInstance()->cursor_manager()->LockCursor();
59 } // namespace aura