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

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm

Issue 2541653002: Add a dead zone when dragging tabs horizontally on Mac (Closed)
Patch Set: Addressing review comments. Created 4 years 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
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm
index 3d168310cbb5820ab90d3ccf9d4b9e060d6e76ba..074476a276614c9312140774a33caf325561f25b 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm
@@ -17,6 +17,7 @@
#include "ui/base/cocoa/cocoa_base_utils.h"
#include "ui/gfx/mac/scoped_cocoa_disable_screen_updates.h"
+const CGFloat kHorizontalTearDistance = 10.0; // Using the same value as Views.
const CGFloat kTearDistance = 36.0;
const NSTimeInterval kTearDuration = 0.333;
@@ -171,9 +172,17 @@ static BOOL PointIsInsideView(NSPoint screenPoint, NSView* view) {
if (draggingWithinTabStrip_) {
NSPoint thisPoint = [NSEvent mouseLocation];
CGFloat offset = thisPoint.x - dragOrigin_.x;
- [sourceController_ insertPlaceholderForTab:[draggedTab_ tabView]
- frame:NSOffsetRect(sourceTabFrame_,
- offset, 0)];
+ // Only begin dragging the tab horizontally if it's torn out of its dead
+ // zone.
+ if (!outOfTabHorizontalDeadZone_ &&
+ fabs(offset) > kHorizontalTearDistance) {
+ outOfTabHorizontalDeadZone_ = YES;
+ }
+ if (outOfTabHorizontalDeadZone_) {
erikchen 2016/11/30 21:07:34 I patched this in and tried tab dragging. It seeme
njagsarran 2016/12/02 16:43:12 I'm seeing that error, too. I undid my changed and
erikchen 2016/12/07 17:53:20 You're right. Tried again and I can reproduce the
+ [sourceController_ insertPlaceholderForTab:[draggedTab_ tabView]
+ frame:NSOffsetRect(sourceTabFrame_,
+ offset, 0)];
+ }
// Check that we haven't pulled the tab too far to start a drag. This
// can include either pulling it too far down, or off the side of the tab
// strip that would cause it to no longer be fully visible.
@@ -403,6 +412,7 @@ static BOOL PointIsInsideView(NSPoint screenPoint, NSView* view) {
- (void)endDrag:(NSEvent*)event {
// Cancel any delayed -continueDrag: requests that may still be pending.
[NSObject cancelPreviousPerformRequestsWithTarget:self];
+ outOfTabHorizontalDeadZone_ = NO;
// Special-case this to keep the logic below simpler.
if (moveWindowOnDrag_) {
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698