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..bae6098da9a920aceb949dd1a3779b5073b0b0ab |
--- /dev/null |
+++ b/ui/views/cocoa/cocoa_window_move_loop.h |
@@ -0,0 +1,59 @@ |
+// 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; |
+ |
+// Used by views::BridgedNativeWidget when dragging detached tabs. |
+class CocoaWindowMoveLoop { |
+ public: |
+ CocoaWindowMoveLoop(BridgedNativeWidget* owner, |
+ const gfx::Point& initial_mouse_in_screen); |
+ ~CocoaWindowMoveLoop(); |
+ |
+ // Initiates the drag with a simulated mouse click then monitors window server |
+ // events until a mouse up or Escape keypress is observed, or End() is called. |
+ Widget::MoveLoopResult Run(); |
+ void End(); |
+ |
+ // Added as an kCGEventSourceUserData to the simulated CGEvents that shouldn't |
+ // be processed by the BridgedContentViews. |
+ 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 :-)
|
+ |
+ private: |
+ enum LoopExitReason { |
+ 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. The first simulated click will happen in this location to |
+ // guarantee it reaches the expected NSWindow. |
+ 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_ |