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 126623ff0e78cda2f2f43166018376a2bf29d2f2..d7f65bf272566c44f5cdc38a2b9f4b95ed2fb3e9 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 { |
@@ -292,13 +302,39 @@ void NativeWidgetMac::InitModalType(ui::ModalType modal_type) { |
} |
gfx::Rect NativeWidgetMac::GetWindowBoundsInScreen() const { |
- return gfx::ScreenRectFromNSRect([GetNativeWindow() frame]); |
+ // -[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 frame_rect = [GetNativeWindow() frame]; |
+ if (bridge_->IsRunMoveLoopActive()) |
+ frame_rect = gfx::ScreenRectToNSRect(WindowServerFrame()); |
+ return gfx::ScreenRectFromNSRect(frame_rect); |
+} |
+ |
+gfx::Rect NativeWidgetMac::WindowServerFrame() const { |
+ CGRect bounds = NSZeroRect; |
+ CGSGetWindowBounds(_CGSDefaultConnection(), [GetNativeWindow() windowNumber], |
+ &bounds); |
+ NSRect rect = ScreenRectToNSRect(gfx::Rect(bounds)); |
+ rect.size = [GetNativeWindow() frame].size; |
+ return gfx::ScreenRectFromNSRect(rect); |
} |
gfx::Rect NativeWidgetMac::GetClientAreaBoundsInScreen() const { |
NSWindow* window = GetNativeWindow(); |
- return gfx::ScreenRectFromNSRect( |
- [window contentRectForFrameRect:[window frame]]); |
+ NSRect frame_rect = [window frame]; |
+ // -[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. |
+ if (bridge_->IsRunMoveLoopActive()) |
+ frame_rect = gfx::ScreenRectToNSRect(WindowServerFrame()); |
+ return gfx::ScreenRectFromNSRect([window contentRectForFrameRect:frame_rect]); |
} |
gfx::Rect NativeWidgetMac::GetRestoredBounds() const { |
@@ -546,12 +582,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) { |