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 // Added as an kCGEventSourceUserData to the simulated CGEvents that shouldn't |
| 15 // be processed by the BridgedContentViews. |
| 16 extern const int kCocoaWindowMoveLoopSimulatedEventUserData; |
| 17 |
| 18 // Used by views::BridgedNativeWidget |
| 19 class CocoaWindowMoveLoop { |
| 20 public: |
| 21 explicit CocoaWindowMoveLoop(BridgedNativeWidget* owner, |
| 22 gfx::Point initial_mouse_in_screen); |
| 23 ~CocoaWindowMoveLoop(); |
| 24 |
| 25 Widget::MoveLoopResult Run(); |
| 26 void End(); |
| 27 |
| 28 private: |
| 29 enum LoopExitReason { |
| 30 RUNNING, |
| 31 ENDED_EXTERNALLY, |
| 32 ESCAPE_PRESSED, |
| 33 MOUSE_UP, |
| 34 WINDOW_DESTROYED, |
| 35 }; |
| 36 |
| 37 void OnPositionChanged(); |
| 38 |
| 39 BridgedNativeWidget* owner_; // Weak. Owns this. |
| 40 |
| 41 // Initial mouse location at the time before the CocoaWindowMoveLoop is |
| 42 // created. Cache this as the mouse could be moved when we're inside Run(), |
| 43 // and then sending the MouseDown event will fail. |
| 44 gfx::Point initial_mouse_in_screen_; |
| 45 |
| 46 // Pointer to a stack variable holding the exit reason. |
| 47 LoopExitReason* exit_reason_ref_ = nullptr; |
| 48 base::Closure quit_closure_; |
| 49 |
| 50 // WeakPtrFactory for event monitor safety. |
| 51 base::WeakPtrFactory<CocoaWindowMoveLoop> weak_factory_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(CocoaWindowMoveLoop); |
| 54 }; |
| 55 |
| 56 } // namespace views |
| 57 |
| 58 #endif // UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |
OLD | NEW |