Index: ui/views/cocoa/bridged_native_widget.h |
diff --git a/ui/views/cocoa/bridged_native_widget.h b/ui/views/cocoa/bridged_native_widget.h |
index e4df8e78faa70618d410ebea6d4e33daf9923193..d2bebc7e4ac1d18187fbf01aa89fabc45e7bd9a3 100644 |
--- a/ui/views/cocoa/bridged_native_widget.h |
+++ b/ui/views/cocoa/bridged_native_widget.h |
@@ -17,6 +17,7 @@ |
#include "ui/compositor/layer_owner.h" |
#import "ui/views/cocoa/bridged_native_widget_owner.h" |
#import "ui/views/cocoa/cocoa_mouse_capture_delegate.h" |
+#import "ui/views/cocoa/cocoa_window_move_loop.h" |
#import "ui/views/focus/focus_manager.h" |
#include "ui/views/views_export.h" |
#include "ui/views/widget/widget.h" |
@@ -34,6 +35,7 @@ class BridgedNativeWidgetTestApi; |
} |
class CocoaMouseCapture; |
+class CocoaWindowMoveLoop; |
class NativeWidgetMac; |
class View; |
@@ -99,6 +101,12 @@ class VIEWS_EXPORT BridgedNativeWidget |
void ReleaseCapture(); |
bool HasCapture(); |
+ // Start moving the window, pinned to the mouse cursor, and monitor events. |
+ // Return MOVE_LOOP_SUCCESSFUL on mouse up or MOVE_LOOP_CANCELED on escape. |
+ Widget::MoveLoopResult RunMoveLoop(const gfx::Vector2d& drag_offset); |
+ void EndMoveLoop(); |
+ bool IsRunMoveLoopActive() const; |
+ |
// See views::Widget. |
void SetNativeWindowProperty(const char* key, void* value); |
void* GetNativeWindowProperty(const char* key) const; |
@@ -125,6 +133,10 @@ class VIEWS_EXPORT BridgedNativeWidget |
// Called by the NSWindowDelegate when the size of the window changes. |
void OnSizeChanged(); |
+ // Called once by the NSWindowDelegate when the position of the window has |
+ // changed. Called for each mouse event during RunMoveLoop(). |
+ void OnPositionChanged(); |
+ |
// Called by the NSWindowDelegate when the visibility of the window may have |
// changed. For example, due to a (de)miniaturize operation, or the window |
// being reordered in (or out of) the screen list. |
@@ -156,6 +168,9 @@ class VIEWS_EXPORT BridgedNativeWidget |
// fullscreen or transitioning between fullscreen states. |
gfx::Rect GetRestoredBounds() const; |
+ // Returns the actual frame as the WindowServer sees it. |
+ NSRect WindowServerFrame() const; |
+ |
// Creates a ui::Compositor which becomes responsible for drawing the window. |
void CreateLayer(ui::LayerType layer_type, bool translucent); |
@@ -187,6 +202,7 @@ class VIEWS_EXPORT BridgedNativeWidget |
private: |
friend class test::BridgedNativeWidgetTestApi; |
+ friend class CocoaWindowMoveLoop; |
// Closes all child windows. BridgedNativeWidget children will be destroyed. |
void RemoveOrDestroyChildren(); |
@@ -262,6 +278,7 @@ class VIEWS_EXPORT BridgedNativeWidget |
base::scoped_nsobject<BridgedContentView> bridged_view_; |
std::unique_ptr<ui::InputMethod> input_method_; |
std::unique_ptr<CocoaMouseCapture> mouse_capture_; |
+ std::unique_ptr<CocoaWindowMoveLoop> window_move_loop_; |
std::unique_ptr<TooltipManager> tooltip_manager_; |
FocusManager* focus_manager_; // Weak. Owned by our Widget. |
Widget::InitParams::Type widget_type_; |
@@ -278,6 +295,8 @@ class VIEWS_EXPORT BridgedNativeWidget |
// has its own copy, but doesn't provide access to it). |
gfx::Rect bounds_before_fullscreen_; |
+ base::RunLoop* drag_run_loop_ = nullptr; |
+ |
// Whether this window wants to be fullscreen. If a fullscreen animation is in |
// progress then it might not be actually fullscreen. |
bool target_fullscreen_state_; |