diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-25 21:30:31 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-25 21:30:31 +0000 |
commit | d4e72a0a7f1087853e704e6a7cbebfdaf8ccdbca (patch) | |
tree | a2daddbe92622a6d0177b057ce1d9eab67f09a60 /chrome/browser/cocoa | |
parent | d351c9065715a3a989c8ecc322306d457e843780 (diff) | |
download | chromium_src-d4e72a0a7f1087853e704e6a7cbebfdaf8ccdbca.zip chromium_src-d4e72a0a7f1087853e704e6a7cbebfdaf8ccdbca.tar.gz chromium_src-d4e72a0a7f1087853e704e6a7cbebfdaf8ccdbca.tar.bz2 |
[Mac] Add methods to prevent tab detaching or window moving if needed. Modify tab view to respect these new settings. Prereq for fullscreen.
(Changes really made by viettrungluu@chromium.org.)
BUG=31638
TEST=Tab dragging and window moving should still work when not in fullscreen mode.
Review URL: http://codereview.chromium.org/554064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37045 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/tab_view.mm | 17 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_window_controller.h | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_window_controller.mm | 10 |
3 files changed, 26 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index d97b6b3..8167071 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -317,11 +317,13 @@ const CGFloat kRapidCloseDist = 2.5; - (void)mouseDragged:(NSEvent*)theEvent { // Special-case this to keep the logic below simpler. if (moveWindowOnDrag_) { - NSPoint thisPoint = [NSEvent mouseLocation]; - NSPoint origin = sourceWindowFrame_.origin; - origin.x += (thisPoint.x - dragOrigin_.x); - origin.y += (thisPoint.y - dragOrigin_.y); - [sourceWindow_ setFrameOrigin:NSMakePoint(origin.x, origin.y)]; + if ([sourceController_ windowMovementAllowed]) { + NSPoint thisPoint = [NSEvent mouseLocation]; + NSPoint origin = sourceWindowFrame_.origin; + origin.x += (thisPoint.x - dragOrigin_.x); + origin.y += (thisPoint.y - dragOrigin_.y); + [sourceWindow_ setFrameOrigin:NSMakePoint(origin.x, origin.y)]; + } // else do nothing. return; } @@ -346,7 +348,8 @@ const CGFloat kRapidCloseDist = 2.5; // strip that would cause it to no longer be fully visible. BOOL stillVisible = [sourceController_ isTabFullyVisible:self]; CGFloat tearForce = fabs(thisPoint.y - dragOrigin_.y); - if (tearForce > kTearDistance || !stillVisible) { + if ([sourceController_ tabTearingAllowed] && + (tearForce > kTearDistance || !stillVisible)) { draggingWithinTabStrip_ = NO; // When you finally leave the strip, we treat that as the origin. dragOrigin_.x = thisPoint.x; diff --git a/chrome/browser/cocoa/tab_window_controller.h b/chrome/browser/cocoa/tab_window_controller.h index 850b203..8598766 100644 --- a/chrome/browser/cocoa/tab_window_controller.h +++ b/chrome/browser/cocoa/tab_window_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -76,10 +76,13 @@ // implementation. - (void)removePlaceholder; -// Returns YES if tab dragging is currently allowed. Any number of things -// can choose to disable it, such as pending animations. The default is to -// always return YES. Subclasses should override as appropriate. +// The follow return YES if tab dragging/tab tearing (off the tab strip)/window +// movement is currently allowed. Any number of things can choose to disable it, +// such as pending animations. The default implementations always return YES. +// Subclasses should override as appropriate. - (BOOL)tabDraggingAllowed; +- (BOOL)tabTearingAllowed; +- (BOOL)windowMovementAllowed; // Show or hide the new tab button. The button is hidden immediately, but // waits until the next call to |-layoutTabs| to show it again. diff --git a/chrome/browser/cocoa/tab_window_controller.mm b/chrome/browser/cocoa/tab_window_controller.mm index 984ab35f..2cbe4ba 100644 --- a/chrome/browser/cocoa/tab_window_controller.mm +++ b/chrome/browser/cocoa/tab_window_controller.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -172,6 +172,14 @@ return YES; } +- (BOOL)tabTearingAllowed { + return YES; +} + +- (BOOL)windowMovementAllowed { + return YES; +} + - (BOOL)isTabFullyVisible:(TabView*)tab { // Subclasses should implement this, but it's not necessary. return YES; |