Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: ui/views/cocoa/cocoa_window_move_loop.h

Issue 1747803003: MacViews: Implement Tab Dragging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed click simulation, reimplemented CocoaWindowMoveLoop without relying on the WindowServer. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b34b63e449314731186ec975d1557ac882562063
--- /dev/null
+++ b/ui/views/cocoa/cocoa_window_move_loop.h
@@ -0,0 +1,54 @@
+// 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();
+
+ private:
+ enum LoopExitReason {
+ ENDED_EXTERNALLY,
+ 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_

Powered by Google App Engine
This is Rietveld 408576698