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 #import <Cocoa/Cocoa.h> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "ui/views/widget/widget.h" |
| 13 |
| 14 namespace views { |
| 15 class BridgedNativeWidget; |
| 16 |
| 17 // Used by views::BridgedNativeWidget when dragging detached tabs. |
| 18 class CocoaWindowMoveLoop { |
| 19 public: |
| 20 CocoaWindowMoveLoop(BridgedNativeWidget* owner, |
| 21 const NSPoint& initial_mouse_in_screen); |
| 22 ~CocoaWindowMoveLoop(); |
| 23 |
| 24 // Initiates the drag until a mouse up event is observed, or End() is called. |
| 25 Widget::MoveLoopResult Run(); |
| 26 void End(); |
| 27 |
| 28 private: |
| 29 enum LoopExitReason { |
| 30 ENDED_EXTERNALLY, |
| 31 MOUSE_UP, |
| 32 WINDOW_DESTROYED, |
| 33 }; |
| 34 |
| 35 BridgedNativeWidget* owner_; // Weak. Owns this. |
| 36 |
| 37 // Initial mouse location at the time before the CocoaWindowMoveLoop is |
| 38 // created. |
| 39 NSPoint initial_mouse_in_screen_; |
| 40 |
| 41 // Pointer to a stack variable holding the exit reason. |
| 42 LoopExitReason* exit_reason_ref_ = nullptr; |
| 43 base::Closure quit_closure_; |
| 44 |
| 45 // WeakPtrFactory for event monitor safety. |
| 46 base::WeakPtrFactory<CocoaWindowMoveLoop> weak_factory_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(CocoaWindowMoveLoop); |
| 49 }; |
| 50 |
| 51 } // namespace views |
| 52 |
| 53 #endif // UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |
OLD | NEW |