OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #ifndef UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |
| 6 #define UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |
| 7 |
| 8 #include "ui/gfx/geometry/point.h" |
| 9 #include "ui/views/widget/widget.h" |
| 10 |
| 11 namespace views { |
| 12 class BridgedNativeWidget; |
| 13 |
| 14 // Used by views::BridgedNativeWidget when dragging detached tabs. |
| 15 class CocoaWindowMoveLoop { |
| 16 public: |
| 17 CocoaWindowMoveLoop(BridgedNativeWidget* owner, |
| 18 const gfx::Point& initial_mouse_in_screen); |
| 19 ~CocoaWindowMoveLoop(); |
| 20 |
| 21 // Initiates the drag with a simulated mouse click then monitors window server |
| 22 // events until a mouse up or Escape keypress is observed, or End() is called. |
| 23 Widget::MoveLoopResult Run(); |
| 24 void End(); |
| 25 |
| 26 private: |
| 27 enum LoopExitReason { |
| 28 ENDED_EXTERNALLY, |
| 29 MOUSE_UP, |
| 30 WINDOW_DESTROYED, |
| 31 }; |
| 32 |
| 33 void OnPositionChanged(); |
| 34 |
| 35 BridgedNativeWidget* owner_; // Weak. Owns this. |
| 36 |
| 37 // Initial mouse location at the time before the CocoaWindowMoveLoop is |
| 38 // created. The first simulated click will happen in this location to |
| 39 // guarantee it reaches the expected NSWindow. |
| 40 gfx::Point initial_mouse_in_screen_; |
| 41 |
| 42 // Pointer to a stack variable holding the exit reason. |
| 43 LoopExitReason* exit_reason_ref_ = nullptr; |
| 44 base::Closure quit_closure_; |
| 45 |
| 46 // WeakPtrFactory for event monitor safety. |
| 47 base::WeakPtrFactory<CocoaWindowMoveLoop> weak_factory_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(CocoaWindowMoveLoop); |
| 50 }; |
| 51 |
| 52 } // namespace views |
| 53 |
| 54 #endif // UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |
OLD | NEW |