diff --git a/browser/native_window_mac.h b/browser/native_window_mac.h index 6c485e79f7c4..ea359fa101b4 100644 --- a/browser/native_window_mac.h +++ b/browser/native_window_mac.h @@ -98,7 +98,7 @@ class NativeWindowMac : public NativeWindow { // Mouse location since the last mouse event, in screen coordinates. This is // used in custom drag to compute the window movement. - NSPoint last_mouse_location_; + NSPoint last_mouse_offset_; DISALLOW_COPY_AND_ASSIGN(NativeWindowMac); }; diff --git a/browser/native_window_mac.mm b/browser/native_window_mac.mm index e293074e34b9..d6858a191bb0 100644 --- a/browser/native_window_mac.mm +++ b/browser/native_window_mac.mm @@ -435,17 +435,18 @@ bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const { } void NativeWindowMac::HandleMouseEvent(NSEvent* event) { + NSPoint current_mouse_location = + [window() convertBaseToScreen:[event locationInWindow]]; + if ([event type] == NSLeftMouseDown) { - last_mouse_location_ = - [window() convertBaseToScreen:[event locationInWindow]]; - } else if ([event type] == NSLeftMouseDragged) { - NSPoint current_mouse_location = - [window() convertBaseToScreen:[event locationInWindow]]; NSPoint frame_origin = [window() frame].origin; - frame_origin.x += current_mouse_location.x - last_mouse_location_.x; - frame_origin.y += current_mouse_location.y - last_mouse_location_.y; - [window() setFrameOrigin:frame_origin]; - last_mouse_location_ = current_mouse_location; + last_mouse_offset_ = NSMakePoint( + frame_origin.x - current_mouse_location.x, + frame_origin.y - current_mouse_location.y); + } else if ([event type] == NSLeftMouseDragged) { + [window() setFrameOrigin:NSMakePoint( + current_mouse_location.x + last_mouse_offset_.x, + current_mouse_location.y + last_mouse_offset_.y)]; } }