| OLD | NEW |
| 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/default_window_resizer.h" | 5 #include "ash/wm/common/default_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/wm/common/window_state.h" | 7 #include "ash/wm/common/window_state.h" |
| 8 #include "ash/wm/common/wm_globals.h" | 8 #include "ash/wm/common/wm_globals.h" |
| 9 #include "ash/wm/common/wm_window.h" | 9 #include "ash/wm/common/wm_window.h" |
| 10 | 10 |
| 11 namespace ash { | 11 namespace ash { |
| 12 | 12 |
| 13 DefaultWindowResizer::~DefaultWindowResizer() { | 13 DefaultWindowResizer::~DefaultWindowResizer() { |
| 14 globals_->UnlockCursor(); | 14 globals_->UnlockCursor(); |
| 15 } | 15 } |
| 16 | 16 |
| 17 // static | 17 // static |
| 18 DefaultWindowResizer* | 18 DefaultWindowResizer* DefaultWindowResizer::Create( |
| 19 DefaultWindowResizer::Create(wm::WindowState* window_state) { | 19 wm::WindowState* window_state) { |
| 20 return new DefaultWindowResizer(window_state); | 20 return new DefaultWindowResizer(window_state); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 23 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 24 gfx::Rect bounds(CalculateBoundsForDrag(location)); | 24 gfx::Rect bounds(CalculateBoundsForDrag(location)); |
| 25 if (bounds != GetTarget()->GetBounds()) { | 25 if (bounds != GetTarget()->GetBounds()) { |
| 26 if (!did_move_or_resize_ && !details().restore_bounds.IsEmpty()) | 26 if (!did_move_or_resize_ && !details().restore_bounds.IsEmpty()) |
| 27 window_state_->ClearRestoreBounds(); | 27 window_state_->ClearRestoreBounds(); |
| 28 did_move_or_resize_ = true; | 28 did_move_or_resize_ = true; |
| 29 GetTarget()->SetBounds(bounds); | 29 GetTarget()->SetBounds(bounds); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 void DefaultWindowResizer::CompleteDrag() { | 33 void DefaultWindowResizer::CompleteDrag() {} |
| 34 } | |
| 35 | 34 |
| 36 void DefaultWindowResizer::RevertDrag() { | 35 void DefaultWindowResizer::RevertDrag() { |
| 37 if (!did_move_or_resize_) | 36 if (!did_move_or_resize_) |
| 38 return; | 37 return; |
| 39 | 38 |
| 40 GetTarget()->SetBounds(details().initial_bounds_in_parent); | 39 GetTarget()->SetBounds(details().initial_bounds_in_parent); |
| 41 | 40 |
| 42 if (!details().restore_bounds.IsEmpty()) | 41 if (!details().restore_bounds.IsEmpty()) |
| 43 window_state_->SetRestoreBoundsInScreen(details().restore_bounds); | 42 window_state_->SetRestoreBoundsInScreen(details().restore_bounds); |
| 44 } | 43 } |
| 45 | 44 |
| 46 DefaultWindowResizer::DefaultWindowResizer(wm::WindowState* window_state) | 45 DefaultWindowResizer::DefaultWindowResizer(wm::WindowState* window_state) |
| 47 : WindowResizer(window_state), | 46 : WindowResizer(window_state), |
| 48 did_move_or_resize_(false), | 47 did_move_or_resize_(false), |
| 49 globals_(GetTarget()->GetGlobals()) { | 48 globals_(GetTarget()->GetGlobals()) { |
| 50 DCHECK(details().is_resizable); | 49 DCHECK(details().is_resizable); |
| 51 globals_->LockCursor(); | 50 globals_->LockCursor(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 } // namespace aura | 53 } // namespace aura |
| OLD | NEW |