Show window only after root view is attached

This prevents a white flicker when the page
starts to load.
This commit is contained in:
Kevin Sawicki
2013-01-17 11:18:00 -08:00
parent 17e7e05e8b
commit 7f8a64b69c
6 changed files with 18 additions and 2 deletions

View File

@@ -76,6 +76,9 @@ bool AtomCefClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
else if (name == "endTracing") {
EndTracing();
}
else if (name == "show") {
Show(browser);
}
else {
return false;
}
@@ -235,4 +238,4 @@ bool AtomCefClient::Save(const std::string& path, const std::string& data) {
fwrite(data.c_str(), data.size(), 1, f);
fclose(f);
return true;
}
}

View File

@@ -122,6 +122,7 @@ class AtomCefClient : public CefClient,
CefRefPtr<CefListValue> CreateReplyDescriptor(int replyId, int callbackIndex);
void Exit(int status);
void Log(const char *message);
void Show(CefRefPtr<CefBrowser> browser);
IMPLEMENT_REFCOUNTING(AtomCefClient);
IMPLEMENT_LOCKING(AtomCefClient);

View File

@@ -95,6 +95,11 @@ void AtomCefClient::ShowDevTools(CefRefPtr<CefBrowser> browser) {
[windowController showDevTools];
}
void AtomCefClient::Show(CefRefPtr<CefBrowser> browser) {
AtomWindowController *windowController = [[browser->GetHost()->GetWindowHandle() window] windowController];
[windowController.webView setHidden:NO];
}
void AtomCefClient::ShowSaveDialog(int replyId, CefRefPtr<CefBrowser> browser) {
CefRefPtr<CefProcessMessage> replyMessage = CefProcessMessage::Create("reply");
CefRefPtr<CefListValue> replyArguments = replyMessage->GetArgumentList();
@@ -127,4 +132,4 @@ void AtomCefClient::Exit(int status) {
void AtomCefClient::Log(const char *message) {
std::cout << message << "\n";
}
}

View File

@@ -41,6 +41,8 @@
if (!background) {
[self setShouldCascadeWindows:NO];
[self setWindowFrameAutosaveName:@"AtomWindow"];
NSColor *background = [NSColor colorWithCalibratedRed:(51.0/255.0) green:(51.0/255.0f) blue:(51.0/255.0f) alpha:1.0];
[self.window setBackgroundColor:background];
[self showWindow:self];
}
@@ -116,6 +118,7 @@
[urlString appendFormat:@"&pathToOpen=%@", [self encodeUrlParam:_pathToOpen]];
_cefClient = new AtomCefClient();
[self.webView setHidden:YES];
[self addBrowserToView:self.webView url:[urlString UTF8String] cefHandler:_cefClient];
}