Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Remember window size and location on the mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
gruehle committed Sep 20, 2012
1 parent f44dae7 commit abbf0e2
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions appshell/cefclient_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -353,23 +353,41 @@ - (void)createApp:(id)object {

settings.web_security_disabled = true;

window_info.SetAsChild(contentView, 0, 0, kWindowWidth, kWindowHeight);
[[mainWnd windowController] setShouldCascadeWindows: NO];

// Set the initial default size of the window.
NSRect defSize = [mainWnd contentRectForFrameRect:[mainWnd frame]];
defSize.size.width = kWindowWidth;
defSize.size.height = kWindowHeight
#ifdef SHOW_TOOLBAR_UI
+ URLBAR_HEIGHT
#endif
;

[mainWnd setFrame:[mainWnd frameRectForContentRect:defSize] display:NO];

// Set the "autosave" name for the window. If there is a previously stored
// size for the window, it will be loaded here.
[mainWnd setFrameAutosaveName:APP_NAME @"MainWindow"];

// Get the actual content size of the window since setFrameAutosaveName could
// result in the window size changing.
NSRect r = [mainWnd contentRectForFrameRect:[mainWnd frame]];

window_info.SetAsChild(contentView, 0, 0,
r.size.width,
r.size.height
#ifdef SHOW_TOOLBAR_UI
+ URLBAR_HEIGHT
#endif
);

CefBrowserHost::CreateBrowser(window_info, g_handler.get(),
[[startupUrl absoluteString] UTF8String], settings);

// Show the window.
[mainWnd display];
[mainWnd makeKeyAndOrderFront: nil];

// Size the window.
NSRect r = [mainWnd contentRectForFrameRect:[mainWnd frame]];
r.size.width = kWindowWidth;
r.size.height = kWindowHeight
#ifdef SHOW_TOOLBAR_UI
+ URLBAR_HEIGHT
#endif
;

[mainWnd setFrame:[mainWnd frameRectForContentRect:r] display:YES];
}

// Sent by the default notification center immediately before the application
Expand Down

0 comments on commit abbf0e2

Please sign in to comment.