diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 18:43:57 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 18:43:57 +0000 |
commit | 702c7d210cbccf936e19811b4a8f389b8dd812ae (patch) | |
tree | be9e4632151da30004f28c2c74fe47293141076e /chrome/browser | |
parent | 6b323787634825c525d1a17f402ad8252d42c924 (diff) | |
download | chromium_src-702c7d210cbccf936e19811b4a8f389b8dd812ae.zip chromium_src-702c7d210cbccf936e19811b4a8f389b8dd812ae.tar.gz chromium_src-702c7d210cbccf936e19811b4a8f389b8dd812ae.tar.bz2 |
Correctly position windows that are detached during a drag, instead of relying on the default window position in the nib. Stub a little more of WindowSizer, but only enough to get drag working. Default new windows to 1024x768.
Review URL: http://codereview.chromium.org/55023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 37 |
2 files changed, 26 insertions, 14 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 420071a..e3bc4fe 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -30,6 +30,8 @@ void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { NSScreen* screen = [window_ screen]; cocoa_bounds.origin.y = [screen frame].size.height - bounds.height() - bounds.y(); + + [window_ setFrame:cocoa_bounds display:YES]; } // Callers assume that this doesn't immediately delete the Browser object. @@ -203,4 +205,3 @@ void BrowserWindowCocoa::DestroyBrowser() { // at this point the controller is dead (autoreleased), so // make sure we don't try to reference it any more. } - diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index b749e17..bd71540 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -22,6 +22,22 @@ browser_ = browser; DCHECK(browser_); windowShim_ = new BrowserWindowCocoa(browser, self, [self window]); + + // The window is now fully realized and |-windowDidLoad:| has been + // called. We shouldn't do much in wDL because |windowShim_| won't yet + // be initialized (as it's called in response to |[self window]| above). + + // Get the most appropriate size for the window. The window shim will handle + // flipping the coordinates for us so we can use it to save some code. + gfx::Rect windowRect = browser_->GetSavedWindowBounds(); + windowShim_->SetBounds(windowRect); + + // Create a controller for the tab strip, giving it the model object for + // this window's Browser and the tab strip view. The controller will handle + // registering for the appropriate tab notifications from the back-end and + // managing the creation of new tabs. + tabStripController_ = [[TabStripController alloc] + initWithView:[self tabStripView] browser:browser_]; } return self; } @@ -39,17 +55,6 @@ return windowShim_; } -- (void)windowDidLoad { - [super windowDidLoad]; - - // Create a controller for the tab strip, giving it the model object for - // this window's Browser and the tab strip view. The controller will handle - // registering for the appropriate tab notifications from the back-end and - // managing the creation of new tabs. - tabStripController_ = [[TabStripController alloc] - initWithView:[self tabStripView] browser:browser_]; -} - - (void)destroyBrowser { // We need the window to go away now. [self autorelease]; @@ -212,8 +217,14 @@ TabContents* contents = browser_->tabstrip_model()->GetTabContentsAt(index); // Set the window size. Need to do this before we detach the tab so it's - // still in the window. - NSRect windowRect = [[tabView window] frame]; + // still in the window. We have to flip the coordinates as that's what + // is expected by the Browser code. + NSWindow* sourceWindow = [tabView window]; + NSRect windowRect = [sourceWindow frame]; + NSScreen* screen = [sourceWindow screen]; + windowRect.origin.y = + [screen frame].size.height - windowRect.size.height - + windowRect.origin.y; gfx::Rect browserRect(windowRect.origin.x, windowRect.origin.y, windowRect.size.width, windowRect.size.height); |