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

Unified Diff: chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm

Issue 8574068: Mac Panels interaction with Dock modifications. (step 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more feedback Created 9 years, 1 month 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
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 293855b8e9a0a4e18c0fdb9c4576e88e892cc20b..ad2fc959c1471099d970198aa51babfd5f167411 100644
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
@@ -24,6 +24,11 @@ const int kRoundedCornerSize = 3;
const int kButtonPadding = 8;
const int kIconAndTextPadding = 5;
+// Distance that user needs to move the mouse in order to start the drag.
+// Threshold is needed to differentiate drags from attempts to click the
+// titlebar with a twitch of the mouse pointer.
+const int kDragThreshold = 3;
+
// Used to implement TestingAPI
static NSEvent* MakeMouseEvent(NSEventType type,
NSPoint point,
@@ -317,6 +322,7 @@ static NSEvent* MakeMouseEvent(NSEventType type,
- (void)mouseDown:(NSEvent*)event {
dragState_ = PANEL_DRAG_CAN_START;
+ dragStartLocation_ = [event locationInWindow];
}
- (void)mouseUp:(NSEvent*)event {
@@ -326,6 +332,12 @@ static NSEvent* MakeMouseEvent(NSEventType type,
[controller_ onTitlebarMouseClicked];
}
+- (BOOL)exceedsDragThreshold:(NSPoint)mouseLocation {
+ float deltaX = dragStartLocation_.x - mouseLocation.x;
+ float deltaY = dragStartLocation_.y - mouseLocation.y;
+ return deltaX > kDragThreshold || deltaY > kDragThreshold;
jennb 2011/11/18 00:36:55 So much simpler! Shaves a few cycles, too. :-D
+}
+
- (void)mouseDragged:(NSEvent*)event {
// In addition to events needed to control the drag operation, fetch the right
// mouse click events and key down events and ignore them, to prevent their
@@ -345,8 +357,11 @@ static NSEvent* MakeMouseEvent(NSEventType type,
switch ([event type]) {
case NSLeftMouseDragged:
- if (dragState_ == PANEL_DRAG_CAN_START)
+ if (dragState_ == PANEL_DRAG_CAN_START) {
+ if (![self exceedsDragThreshold:[event locationInWindow]])
+ return; // Don't start real drag yet.
[self startDrag];
+ }
[self dragWithDeltaX:[event deltaX]];
break;
@@ -358,7 +373,10 @@ static NSEvent* MakeMouseEvent(NSEventType type,
break;
case NSLeftMouseUp:
- [self endDrag:NO];
+ if (dragState_ == PANEL_DRAG_CAN_START)
+ [self mouseUp:event]; // Drag didn't really start, minimize instead.
+ else
+ [self endDrag:NO];
keepGoing = NO;
break;
« no previous file with comments | « chrome/browser/ui/panels/panel_titlebar_view_cocoa.h ('k') | chrome/browser/ui/panels/panel_window_controller_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698