Index: chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm |
diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm |
index f637494ac95ed9f19e0ef0f0df412e1817f0b593..f2218c4132e1d11004845bff95da53d0703ed772 100644 |
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm |
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm |
@@ -392,7 +392,7 @@ static NSEvent* MakeMouseEvent(NSEventType type, |
- (void)mouseDown:(NSEvent*)event { |
if ([controller_ isDraggable]) { |
dragState_ = PANEL_DRAG_CAN_START; |
- dragStartLocation_ = [event locationInWindow]; |
+ dragStartLocation_ = [NSEvent mouseLocation]; |
} |
} |
@@ -406,7 +406,7 @@ static NSEvent* MakeMouseEvent(NSEventType type, |
- (BOOL)exceedsDragThreshold:(NSPoint)mouseLocation { |
float deltaX = dragStartLocation_.x - mouseLocation.x; |
float deltaY = dragStartLocation_.y - mouseLocation.y; |
- return deltaX > kDragThreshold || deltaY > kDragThreshold; |
+ return fabs(deltaX) > kDragThreshold || fabs(deltaY) > kDragThreshold; |
} |
- (void)mouseDragged:(NSEvent*)event { |
@@ -432,12 +432,12 @@ static NSEvent* MakeMouseEvent(NSEventType type, |
switch ([event type]) { |
case NSLeftMouseDragged: |
if (dragState_ == PANEL_DRAG_CAN_START) { |
- if (![self exceedsDragThreshold:[event locationInWindow]]) |
+ if (![self exceedsDragThreshold:[NSEvent mouseLocation]]) |
return; // Don't start real drag yet. |
- [self startDrag]; |
+ [self startDrag:dragStartLocation_]; |
} |
- [self dragWithDeltaX:[event deltaX] |
- deltaY:[event deltaY]]; |
+ if (dragState_ == PANEL_DRAG_IN_PROGRESS) |
+ [self drag:[NSEvent mouseLocation]]; |
break; |
case NSKeyUp: |
@@ -468,10 +468,10 @@ static NSEvent* MakeMouseEvent(NSEventType type, |
} |
} |
-- (void)startDrag { |
+- (void)startDrag:(NSPoint)mouseLocation { |
DCHECK(dragState_ == PANEL_DRAG_CAN_START); |
dragState_ = PANEL_DRAG_IN_PROGRESS; |
- [controller_ startDrag]; |
+ [controller_ startDrag:mouseLocation]; |
} |
- (void)endDrag:(BOOL)cancelled { |
@@ -480,12 +480,10 @@ static NSEvent* MakeMouseEvent(NSEventType type, |
dragState_ = PANEL_DRAG_SUPPRESSED; |
} |
-- (void)dragWithDeltaX:(int)deltaX |
- deltaY:(int)deltaY { |
+- (void)drag:(NSPoint)mouseLocation { |
if (dragState_ != PANEL_DRAG_IN_PROGRESS) |
return; |
- [controller_ dragWithDeltaX:deltaX |
- deltaY:deltaY]; |
+ [controller_ drag:mouseLocation]; |
} |
- (void)drawAttention { |
@@ -569,8 +567,9 @@ static NSEvent* MakeMouseEvent(NSEventType type, |
[[closeButton_ cell] performClick:closeButton_]; |
} |
-- (void)pressLeftMouseButtonTitlebar { |
- NSEvent* event = MakeMouseEvent(NSLeftMouseDown, NSZeroPoint, 0); |
+- (void)pressLeftMouseButtonTitlebar:(NSPoint)mouseLocation { |
+ NSEvent* event = MakeMouseEvent(NSLeftMouseDown, |
+ [self convertPoint:mouseLocation fromView:nil], 0); |
[self mouseDown:event]; |
} |
@@ -579,12 +578,10 @@ static NSEvent* MakeMouseEvent(NSEventType type, |
[self mouseUp:event]; |
} |
-- (void)dragTitlebarDeltaX:(double)delta_x |
- deltaY:(double)delta_y { |
+- (void)dragTitlebar:(NSPoint)mouseLocation { |
if (dragState_ == PANEL_DRAG_CAN_START) |
- [self startDrag]; |
- [self dragWithDeltaX:delta_x |
- deltaY:delta_y]; |
+ [self startDrag:dragStartLocation_]; |
+ [self drag:mouseLocation]; |
} |
- (void)cancelDragTitlebar { |