Chromium Code Reviews| 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 // Added as an kCGEventSourceUserData to the simulated CGEvents that shouldn't | |
| 27 // be processed by the BridgedContentViews. | |
| 28 static const int kCocoaWindowMoveLoopSimulatedEventUserData = 1; | |
| 
 
tapted
2016/04/20 07:30:22
sorry - I should have said to remove the 'CocoaWin
 
themblsha
2016/04/20 13:38:40
Ah, yeah, that's much better :-)
 
 | |
| 29 | |
| 30 private: | |
| 31 enum LoopExitReason { | |
| 32 ENDED_EXTERNALLY, | |
| 33 ESCAPE_PRESSED, | |
| 34 MOUSE_UP, | |
| 35 WINDOW_DESTROYED, | |
| 36 }; | |
| 37 | |
| 38 void OnPositionChanged(); | |
| 39 | |
| 40 BridgedNativeWidget* owner_; // Weak. Owns this. | |
| 41 | |
| 42 // Initial mouse location at the time before the CocoaWindowMoveLoop is | |
| 43 // created. The first simulated click will happen in this location to | |
| 44 // guarantee it reaches the expected NSWindow. | |
| 45 gfx::Point initial_mouse_in_screen_; | |
| 46 | |
| 47 // Pointer to a stack variable holding the exit reason. | |
| 48 LoopExitReason* exit_reason_ref_ = nullptr; | |
| 49 base::Closure quit_closure_; | |
| 50 | |
| 51 // WeakPtrFactory for event monitor safety. | |
| 52 base::WeakPtrFactory<CocoaWindowMoveLoop> weak_factory_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(CocoaWindowMoveLoop); | |
| 55 }; | |
| 56 | |
| 57 } // namespace views | |
| 58 | |
| 59 #endif // UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ | |
| OLD | NEW |