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

Unified Diff: ui/views/widget/native_widget_mac.mm

Issue 1747803003: MacViews: Implement Tab Dragging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extract CocoaWindowMoveLoop, fix review issues. Created 4 years, 9 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
« ui/views/cocoa/cocoa_window_move_loop.mm ('K') | « ui/views/views.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/native_widget_mac.mm
diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm
index f307abddba85e17fd28e663327522fdd9d25a34b..31eed6b8b6665790b1346446567d549a93d0af1d 100644
--- a/ui/views/widget/native_widget_mac.mm
+++ b/ui/views/widget/native_widget_mac.mm
@@ -37,6 +37,16 @@
@end
+extern "C" {
+
+typedef int32_t CGSWindow;
+typedef int32_t CGSConnection;
+CGSConnection _CGSDefaultConnection();
+OSStatus CGSGetWindowBounds(
+ CGSConnection connection, CGSWindow window, CGRect* bounds);
+
+}
+
namespace views {
namespace {
@@ -60,6 +70,20 @@ NSInteger StyleMaskForParams(const Widget::InitParams& params) {
return NSBorderlessWindowMask;
}
+// -[NSWindow frame] doesn't update during a window drag. This is not what
+// toolkit-views expects, so ask the window server directly.
+//
+// Note: Moving the window using the window server is asynchronous, and it can
+// continue sending the frame updates (using NSWindowMovedEventType event) even
+// after the mouse button is released.
+NSRect FrameIncludingDrag(NSWindow* window) {
+ CGRect bounds = NSZeroRect;
+ CGSGetWindowBounds(_CGSDefaultConnection(), [window windowNumber], &bounds);
+ const NSRect rect = ScreenRectToNSRect(gfx::Rect(bounds));
tapted 2016/03/11 09:38:28 perhaps NSRect rect = ScreenRectToNSRect(gfx::Re
themblsha 2016/04/05 17:20:42 Done. Although the code now lives inside NativeWid
+ const NSSize size = [window frame].size;
+ return NSMakeRect(rect.origin.x, rect.origin.y, size.width, size.height);
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -295,8 +319,10 @@ gfx::Rect NativeWidgetMac::GetWindowBoundsInScreen() const {
gfx::Rect NativeWidgetMac::GetClientAreaBoundsInScreen() const {
NSWindow* window = GetNativeWindow();
- return gfx::ScreenRectFromNSRect(
- [window contentRectForFrameRect:[window frame]]);
+ NSRect frame_rect = [window frame];
+ if (bridge_->IsRunMoveLoopActive())
+ frame_rect = FrameIncludingDrag(window);
+ return gfx::ScreenRectFromNSRect([window contentRectForFrameRect:frame_rect]);
}
gfx::Rect NativeWidgetMac::GetRestoredBounds() const {
@@ -548,12 +574,15 @@ Widget::MoveLoopResult NativeWidgetMac::RunMoveLoop(
const gfx::Vector2d& drag_offset,
Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) {
- NOTIMPLEMENTED();
- return Widget::MOVE_LOOP_CANCELED;
+ if (!bridge_)
+ return Widget::MOVE_LOOP_CANCELED;
+
+ return bridge_->RunMoveLoop(drag_offset);
}
void NativeWidgetMac::EndMoveLoop() {
- NOTIMPLEMENTED();
+ if (bridge_)
+ bridge_->EndMoveLoop();
}
void NativeWidgetMac::SetVisibilityChangedAnimationsEnabled(bool value) {
« ui/views/cocoa/cocoa_window_move_loop.mm ('K') | « ui/views/views.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698