drag_window_resizer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef ASH_WM_DRAG_WINDOW_RESIZER_H_
  5. #define ASH_WM_DRAG_WINDOW_RESIZER_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ash/wm/window_resizer.h"
  9. #include "base/compiler_specific.h"
  10. #include "base/gtest_prod_util.h"
  11. #include "base/memory/weak_ptr.h"
  12. #include "ui/gfx/geometry/point_f.h"
  13. namespace ash {
  14. class DragWindowController;
  15. // DragWindowResizer is a decorator of WindowResizer and adds the ability to
  16. // drag windows across displays.
  17. class ASH_EXPORT DragWindowResizer : public WindowResizer {
  18. public:
  19. // Creates DragWindowResizer that adds the ability of dragging windows across
  20. // displays to |next_window_resizer|.
  21. DragWindowResizer(std::unique_ptr<WindowResizer> next_window_resizer,
  22. WindowState* window_state);
  23. DragWindowResizer(const DragWindowResizer&) = delete;
  24. DragWindowResizer& operator=(const DragWindowResizer&) = delete;
  25. ~DragWindowResizer() override;
  26. // WindowResizer:
  27. void Drag(const gfx::PointF& location, int event_flags) override;
  28. void CompleteDrag() override;
  29. void RevertDrag() override;
  30. void FlingOrSwipe(ui::GestureEvent* event) override;
  31. WindowResizer* next_window_resizer_for_testing() {
  32. return next_window_resizer_.get();
  33. }
  34. private:
  35. FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, DragWindowController);
  36. FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest,
  37. DragWindowControllerAcrossThreeDisplays);
  38. // Updates the bounds of the drag window for window dragging.
  39. void UpdateDragWindow();
  40. // Returns true if we should allow the mouse pointer to warp.
  41. bool ShouldAllowMouseWarp();
  42. // Do the real work of ending a drag. If the drag ends in a different display,
  43. // move the dragged window to that display.
  44. void EndDragImpl();
  45. std::unique_ptr<WindowResizer> next_window_resizer_;
  46. // Shows a semi-transparent image of the window being dragged.
  47. std::unique_ptr<DragWindowController> drag_window_controller_;
  48. gfx::PointF last_mouse_location_;
  49. // Current instance for use by the DragWindowResizerTest.
  50. static DragWindowResizer* instance_;
  51. base::WeakPtrFactory<DragWindowResizer> weak_ptr_factory_{this};
  52. };
  53. } // namespace ash
  54. #endif // ASH_WM_DRAG_WINDOW_RESIZER_H_