From 845ec8e102a5530f5a1e3037f7c6e0fe571438e3 Mon Sep 17 00:00:00 2001 From: stippi Date: Wed, 7 Apr 2010 10:55:29 +0000 Subject: [PATCH] * 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 --- src/apps/webpositive/BrowserApp.cpp | 58 +++++++++++++++++++---------- src/apps/webpositive/BrowserApp.h | 2 + 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/apps/webpositive/BrowserApp.cpp b/src/apps/webpositive/BrowserApp.cpp index 1cade8cd09..a32bbd04c0 100644 --- a/src/apps/webpositive/BrowserApp.cpp +++ b/src/apps/webpositive/BrowserApp.cpp @@ -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); diff --git a/src/apps/webpositive/BrowserApp.h b/src/apps/webpositive/BrowserApp.h index dfc9433e5e..f83d379a63 100644 --- a/src/apps/webpositive/BrowserApp.h +++ b/src/apps/webpositive/BrowserApp.h @@ -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,