default_window_resizer.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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/wm/default_window_resizer.h" 6 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" 16 17namespace ash { 18 19DefaultWindowResizer::~DefaultWindowResizer() { 20 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); 21} 22 23// static 24DefaultWindowResizer* 25DefaultWindowResizer::Create(wm::WindowState* window_state) { 26 return new DefaultWindowResizer(window_state); 27} 28 29void 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); 36 } 37} 38 39void DefaultWindowResizer::CompleteDrag() { 40} 41 42void DefaultWindowResizer::RevertDrag() { 43 if (!did_move_or_resize_) 44 return; 45 46 GetTarget()->SetBounds(details().initial_bounds_in_parent); 47 48 if (!details().restore_bounds.IsEmpty()) 49 window_state_->SetRestoreBoundsInScreen(details().restore_bounds); 50} 51 52DefaultWindowResizer::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(); 57} 58 59} // namespace aura 60