default_window_resizer.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "ash/wm/default_window_resizer.h"
  5. #include "ash/shell.h"
  6. #include "ash/wm/window_state.h"
  7. #include "ui/aura/window.h"
  8. #include "ui/wm/core/cursor_manager.h"
  9. namespace ash {
  10. DefaultWindowResizer::~DefaultWindowResizer() {
  11. Shell::Get()->cursor_manager()->UnlockCursor();
  12. }
  13. // static
  14. std::unique_ptr<DefaultWindowResizer> DefaultWindowResizer::Create(
  15. WindowState* window_state) {
  16. return base::WrapUnique(new DefaultWindowResizer(window_state));
  17. }
  18. void DefaultWindowResizer::Drag(const gfx::PointF& location, int event_flags) {
  19. gfx::Rect bounds(CalculateBoundsForDrag(location));
  20. if (bounds != GetTarget()->bounds()) {
  21. if (!did_move_or_resize_ && !details().restore_bounds_in_parent.IsEmpty())
  22. window_state_->ClearRestoreBounds();
  23. did_move_or_resize_ = true;
  24. SetBoundsDuringResize(bounds);
  25. }
  26. }
  27. void DefaultWindowResizer::CompleteDrag() {}
  28. void DefaultWindowResizer::RevertDrag() {
  29. if (!did_move_or_resize_)
  30. return;
  31. GetTarget()->SetBounds(details().initial_bounds_in_parent);
  32. if (!details().restore_bounds_in_parent.IsEmpty())
  33. window_state_->SetRestoreBoundsInParent(details().restore_bounds_in_parent);
  34. }
  35. void DefaultWindowResizer::FlingOrSwipe(ui::GestureEvent* event) {}
  36. DefaultWindowResizer::DefaultWindowResizer(WindowState* window_state)
  37. : WindowResizer(window_state) {
  38. DCHECK(details().is_resizable);
  39. Shell::Get()->cursor_manager()->LockCursor();
  40. }
  41. } // namespace ash