summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 20:36:21 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 20:36:21 +0000
commit65603fbb1afff2e20d0206d83695c2e5e952da55 (patch)
tree81f0160a694534a0a68300782aedd67c33e6db5c
parentd81706b859fa9ec8d48d0f471b6245b36aeac510 (diff)
downloadchromium_src-65603fbb1afff2e20d0206d83695c2e5e952da55.zip
chromium_src-65603fbb1afff2e20d0206d83695c2e5e952da55.tar.gz
chromium_src-65603fbb1afff2e20d0206d83695c2e5e952da55.tar.bz2
Add some hysterisis to tab dragging on Mac.
http://code.google.com/p/chromium/issues/detail?id=9670 Review URL: http://codereview.chromium.org/60072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13104 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/tab_view.mm19
1 files changed, 19 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm
index fa624a7..2aef856 100644
--- a/chrome/browser/cocoa/tab_view.mm
+++ b/chrome/browser/cocoa/tab_view.mm
@@ -73,6 +73,11 @@
BOOL dragging = YES;
BOOL moved = NO;
+ // Do not start dragging until the user has "torn" the tab off by
+ // moving more than 3 pixels.
+ BOOL torn = NO;
+ static const double kDragStartDistance = 3.0;
+
NSDate* targetDwellDate = nil; // The date this target was first chosen
NSMutableArray* targets = [NSMutableArray array];
@@ -86,6 +91,20 @@
inMode:NSDefaultRunLoopMode dequeue:YES];
NSPoint thisPoint = [NSEvent mouseLocation];
+ // TODO(alcor): Pinkerton indicated that cole is adding a more
+ // formal concept of "magnetism" to tab detachment, which would
+ // be an alternative solution.
+ if (!torn) {
+ double dx = thisPoint.x - lastPoint.x;
+ double dy = thisPoint.y - lastPoint.y;
+
+ if (dx * dx + dy * dy < kDragStartDistance * kDragStartDistance
+ && [theEvent type] == NSLeftMouseDragged) {
+ continue;
+ }
+ torn = YES;
+ }
+
// Find all the windows that could be a target. It has to be of the
// appropriate class, and visible (obviously).
if (![targets count]) {