diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 17:45:15 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 17:45:15 +0000 |
commit | d643226d0d4e79338a8393fb7c6c84ca7bb470cb (patch) | |
tree | 44ea533644853ef12df9ae89b6aff1f3ff29f15a /chrome/browser | |
parent | 85ab30372062556bdff6518c808ee344db1d6c58 (diff) | |
download | chromium_src-d643226d0d4e79338a8393fb7c6c84ca7bb470cb.zip chromium_src-d643226d0d4e79338a8393fb7c6c84ca7bb470cb.tar.gz chromium_src-d643226d0d4e79338a8393fb7c6c84ca7bb470cb.tar.bz2 |
Fix tab dragging when windows overlap. Bring window to front when dragging a tab into it (allowing drags to window whose tab strip is fully obscured).
BUG=22283
TEST=all tab dragging between windows.
Review URL: http://codereview.chromium.org/281001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/tab_view.mm | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index fd1be74..626e841 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -145,22 +145,21 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; return YES; } -// Find all the windows that could be a target. It has to be of the -// appropriate class, and visible (obviously). Note that the window cannot be -// a target for itself. +// Returns an array of controllers that could be a drop target, ordered front to +// back. It has to be of the appropriate class, and visible (obviously). Note +// that the window cannot be a target for itself. - (NSArray*)dropTargetsForController:(TabWindowController*)dragController { NSMutableArray* targets = [NSMutableArray array]; NSWindow* dragWindow = [dragController window]; - for (NSWindow* window in [NSApp windows]) { + for (NSWindow* window in [NSApp orderedWindows]) { if (window == dragWindow) continue; if (![window isVisible]) continue; NSWindowController* controller = [window windowController]; if ([controller isKindOfClass:[TabWindowController class]]) { TabWindowController* realController = static_cast<TabWindowController*>(controller); - if ([realController canReceiveFrom:dragController]) { + if ([realController canReceiveFrom:dragController]) [targets addObject:controller]; - } } } return targets; @@ -335,12 +334,20 @@ static const CGFloat kRapidCloseDist = 2.5; NSPoint thisPoint = [NSEvent mouseLocation]; // Iterate over possible targets checking for the one the mouse is in. - // The mouse can be in either the tab or window frame. + // If the tab is just in the frame, bring the window forward to make it + // easier to drop something there. If it's in the tab strip, set the new + // target so that it pops into that window. We can't cache this because we + // need the z-order to be correct. NSArray* targets = [self dropTargetsForController:draggedController_]; TabWindowController* newTarget = nil; for (TabWindowController* target in targets) { NSRect windowFrame = [[target window] frame]; if (NSPointInRect(thisPoint, windowFrame)) { + // TODO(pinkerton): If bringing the window to the front immediately is too + // annoying, use another dwell date. Can't use |targetDwellDate| because + // this hasn't yet become the new target until the mouse is in the tab + // strip. + [[target window] orderFront:self]; NSRect tabStripFrame = [[target tabStripView] frame]; tabStripFrame.origin = [[target window] convertBaseToScreen:tabStripFrame.origin]; |