* Revised the application startup to check how many windows have been created at

all. Open a blank page if no pages have been created from the arguments passed
  to the application.
* If no pages have been created yet, don't offset the last known window frame.
  This fixes windows shifting over the screen from session to session.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@397 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-04-07 10:55:29 +00:00 committed by Alexandre Deckner
parent c373752f78
commit 845ec8e102
2 changed files with 41 additions and 19 deletions

View File

@ -162,11 +162,13 @@ BrowserApp::ReadyToRun()
fInitialized = true;
int32 pagesCreated = 0;
if (fLaunchRefsMessage) {
RefsReceived(fLaunchRefsMessage);
_RefsReceived(fLaunchRefsMessage, &pagesCreated);
delete fLaunchRefsMessage;
fLaunchRefsMessage = 0;
} else {
}
if (pagesCreated == 0) {
BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings);
window->Show();
}
@ -236,22 +238,7 @@ BrowserApp::RefsReceived(BMessage* message)
return;
}
entry_ref ref;
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
BEntry entry(&ref, true);
if (!entry.Exists())
continue;
BPath path;
if (entry.GetPath(&path) != B_OK)
continue;
BString url;
url << path.Path();
_CreateNewPage(url);
}
BString url;
for (int32 i = 0; message->FindString("url", i, &url) == B_OK; i++)
_CreateNewPage(url);
_RefsReceived(message);
}
@ -295,6 +282,36 @@ BrowserApp::QuitRequested()
}
void
BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated)
{
int32 pagesCreated = 0;
entry_ref ref;
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
BEntry entry(&ref, true);
if (!entry.Exists())
continue;
BPath path;
if (entry.GetPath(&path) != B_OK)
continue;
BString url;
url << path.Path();
_CreateNewPage(url);
pagesCreated++;
}
BString url;
for (int32 i = 0; message->FindString("url", i, &url) == B_OK; i++) {
_CreateNewPage(url);
pagesCreated++;
}
if (_pagesCreated != NULL)
*_pagesCreated = pagesCreated;
}
void
BrowserApp::_CreateNewPage(const BString& url)
{
@ -323,7 +340,10 @@ BrowserApp::_CreateNewPage(const BString& url)
void
BrowserApp::_CreateNewWindow(const BString& url)
{
fLastWindowFrame.OffsetBy(20, 20);
// Offset the window frame unless this is the first window created in the
// session.
if (fWindowCount > 0)
fLastWindowFrame.OffsetBy(20, 20);
if (!BScreen().Frame().Contains(fLastWindowFrame))
fLastWindowFrame.OffsetTo(50, 50);

View File

@ -53,6 +53,8 @@ public:
virtual bool QuitRequested();
private:
void _RefsReceived(BMessage* message,
int32* pagesCreated = NULL);
void _CreateNewPage(const BString& url);
void _CreateNewWindow(const BString& url);
void _CreateNewTab(BrowserWindow* window,