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

Unified Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 1747803003: MacViews: Implement Tab Dragging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix include. Created 4 years, 6 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
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/cocoa_window_move_loop.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget.mm
diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
index 987b3130b06a7473c606d55d42c98528f183b814..47373d0d4a973470d3ddc37c590af7672d842173 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -26,6 +26,7 @@
#import "ui/views/cocoa/bridged_content_view.h"
#import "ui/views/cocoa/drag_drop_client_mac.h"
#import "ui/views/cocoa/cocoa_mouse_capture.h"
+#import "ui/views/cocoa/cocoa_window_move_loop.h"
#include "ui/views/cocoa/tooltip_manager_mac.h"
#import "ui/views/cocoa/views_nswindow_delegate.h"
#import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
@@ -619,6 +620,39 @@ bool BridgedNativeWidget::HasCapture() {
return mouse_capture_ && mouse_capture_->IsActive();
}
+Widget::MoveLoopResult BridgedNativeWidget::RunMoveLoop(
+ const gfx::Vector2d& drag_offset) {
+ DCHECK(!HasCapture());
+ DCHECK(!window_move_loop_);
+
+ // RunMoveLoop caller is responsible for updating the window to be under the
+ // mouse, but it does this using possibly outdated coordinate from the mouse
+ // event, and mouse is very likely moved beyound that point.
+
+ // Compensate for mouse drift by shifting the initial mouse position we pass
+ // to CocoaWindowMoveLoop, so as it handles incoming move events the window's
+ // top left corner will be |drag_offset| from the current mouse position.
+
+ const gfx::Rect frame = gfx::ScreenRectFromNSRect([window_ frame]);
+ const gfx::Point mouse_in_screen(frame.x() + drag_offset.x(),
+ frame.y() + drag_offset.y());
+ window_move_loop_.reset(new CocoaWindowMoveLoop(
+ this, gfx::ScreenPointToNSPoint(mouse_in_screen)));
+
+ return window_move_loop_->Run();
+
+ // |this| may be destroyed during the RunLoop, causing it to exit early.
+ // Even if that doesn't happen, CocoaWindowMoveLoop will clean itself up by
+ // calling EndMoveLoop(). So window_move_loop_ will always be null before the
+ // function returns. But don't DCHECK since |this| might not be valid.
+}
+
+void BridgedNativeWidget::EndMoveLoop() {
+ DCHECK(window_move_loop_);
+ window_move_loop_->End();
+ window_move_loop_.reset();
+}
+
void BridgedNativeWidget::SetNativeWindowProperty(const char* name,
void* value) {
NSString* key = [NSString stringWithUTF8String:name];
@@ -737,6 +771,10 @@ void BridgedNativeWidget::OnSizeChanged() {
[bridged_view_ updateWindowMask];
}
+void BridgedNativeWidget::OnPositionChanged() {
+ native_widget_mac_->GetWidget()->OnNativeWidgetMove();
+}
+
void BridgedNativeWidget::OnVisibilityChanged() {
OnVisibilityChangedTo([window_ isVisible]);
}
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/cocoa_window_move_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698