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