Index: ui/views/cocoa/cocoa_window_move_loop.h |
diff --git a/ui/views/cocoa/cocoa_window_move_loop.h b/ui/views/cocoa/cocoa_window_move_loop.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a6806c8f7135d6f4fb6f24faf70cfef10c6219cd |
--- /dev/null |
+++ b/ui/views/cocoa/cocoa_window_move_loop.h |
@@ -0,0 +1,58 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |
+#define UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |
+ |
+#include "ui/gfx/geometry/point.h" |
+#include "ui/views/widget/widget.h" |
+ |
+namespace views { |
+class BridgedNativeWidget; |
+ |
+// Added as an kCGEventSourceUserData to the simulated CGEvents that shouldn't |
+// be processed by the BridgedContentViews. |
+extern const int kCocoaWindowMoveLoopSimulatedEventUserData; |
+ |
+// Used by views::BridgedNativeWidget |
+class CocoaWindowMoveLoop { |
+ public: |
+ explicit CocoaWindowMoveLoop(BridgedNativeWidget* owner, |
+ gfx::Point initial_mouse_in_screen); |
+ ~CocoaWindowMoveLoop(); |
+ |
+ Widget::MoveLoopResult Run(); |
+ void End(); |
+ |
+ private: |
+ enum LoopExitReason { |
+ RUNNING, |
+ ENDED_EXTERNALLY, |
+ ESCAPE_PRESSED, |
+ MOUSE_UP, |
+ WINDOW_DESTROYED, |
+ }; |
+ |
+ void OnPositionChanged(); |
+ |
+ BridgedNativeWidget* owner_; // Weak. Owns this. |
+ |
+ // Initial mouse location at the time before the CocoaWindowMoveLoop is |
+ // created. Cache this as the mouse could be moved when we're inside Run(), |
+ // and then sending the MouseDown event will fail. |
+ gfx::Point initial_mouse_in_screen_; |
+ |
+ // Pointer to a stack variable holding the exit reason. |
+ LoopExitReason* exit_reason_ref_ = nullptr; |
+ base::Closure quit_closure_; |
+ |
+ // WeakPtrFactory for event monitor safety. |
+ base::WeakPtrFactory<CocoaWindowMoveLoop> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CocoaWindowMoveLoop); |
+}; |
+ |
+} // namespace views |
+ |
+#endif // UI_VIEWS_COCOA_COCOA_WINDOW_MOVE_LOOP_H_ |