diff --git a/src/apps/webpositive/BrowserApp.cpp b/src/apps/webpositive/BrowserApp.cpp index 3e936e273f..5f8972a5f4 100644 --- a/src/apps/webpositive/BrowserApp.cpp +++ b/src/apps/webpositive/BrowserApp.cpp @@ -102,6 +102,11 @@ BrowserApp::ArgvReceived(int32 argc, char** argv) { BMessage message(B_REFS_RECEIVED); for (int i = 1; i < argc; i++) { + if (strcmp("-f", argv[i]) == 0 + || strcmp("--fullscreen", argv[i]) == 0) { + message.AddBool("fullscreen", true); + continue; + } const char* url = argv[i]; BEntry entry(argv[i], true); BPath path; @@ -163,16 +168,15 @@ BrowserApp::ReadyToRun() fInitialized = true; int32 pagesCreated = 0; + bool fullscreen = false; if (fLaunchRefsMessage) { - _RefsReceived(fLaunchRefsMessage, &pagesCreated); + _RefsReceived(fLaunchRefsMessage, &pagesCreated, &fullscreen); delete fLaunchRefsMessage; - fLaunchRefsMessage = 0; - } - if (pagesCreated == 0) { - BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings, - ""); - window->Show(); + fLaunchRefsMessage = NULL; } + if (pagesCreated == 0) + _CreateNewWindow("", fullscreen); + PostMessage(PRELOAD_BROWSING_HISTORY); } @@ -284,10 +288,15 @@ BrowserApp::QuitRequested() void -BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated) +BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated, + bool* _fullscreen) { int32 pagesCreated = 0; + bool fullscreen; + if (message->FindBool("fullscreen", &fullscreen) != B_OK) + fullscreen = false; + entry_ref ref; for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) { BEntry entry(&ref, true); @@ -298,23 +307,25 @@ BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated) continue; BString url; url << path.Path(); - _CreateNewPage(url); + _CreateNewPage(url, fullscreen); pagesCreated++; } BString url; for (int32 i = 0; message->FindString("url", i, &url) == B_OK; i++) { - _CreateNewPage(url); + _CreateNewPage(url, fullscreen); pagesCreated++; } if (_pagesCreated != NULL) *_pagesCreated = pagesCreated; + if (_fullscreen != NULL) + *_fullscreen = fullscreen; } void -BrowserApp::_CreateNewPage(const BString& url) +BrowserApp::_CreateNewPage(const BString& url, bool fullscreen) { uint32 workspace = 1 << current_workspace(); @@ -334,12 +345,12 @@ BrowserApp::_CreateNewPage(const BString& url) if (loadedInWindowOnCurrentWorkspace) return; } - _CreateNewWindow(url); + _CreateNewWindow(url, fullscreen); } void -BrowserApp::_CreateNewWindow(const BString& url) +BrowserApp::_CreateNewWindow(const BString& url, bool fullscreen) { // Offset the window frame unless this is the first window created in the // session. @@ -350,6 +361,8 @@ BrowserApp::_CreateNewWindow(const BString& url) BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings, url); + if (fullscreen) + window->ToggleFullscreen(); window->Show(); } diff --git a/src/apps/webpositive/BrowserApp.h b/src/apps/webpositive/BrowserApp.h index f83d379a63..1f48b9d947 100644 --- a/src/apps/webpositive/BrowserApp.h +++ b/src/apps/webpositive/BrowserApp.h @@ -54,9 +54,12 @@ public: private: void _RefsReceived(BMessage* message, - int32* pagesCreated = NULL); - void _CreateNewPage(const BString& url); - void _CreateNewWindow(const BString& url); + int32* pagesCreated = NULL, + bool* fullscreen = NULL); + void _CreateNewPage(const BString& url, + bool fullscreen = false); + void _CreateNewWindow(const BString& url, + bool fullscreen = false); void _CreateNewTab(BrowserWindow* window, const BString& url, bool select); void _ShowWindow(const BMessage* message, diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index b3e88a54de..b988105d4e 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -674,7 +674,7 @@ BrowserWindow::MessageReceived(BMessage* message) break; case TOGGLE_FULLSCREEN: - _ToggleFullscreen(); + ToggleFullscreen(); break; case TOGGLE_AUTO_HIDE_INTERFACE_IN_FULLSCREEN: @@ -863,7 +863,7 @@ BrowserWindow::MenusBeginning() void BrowserWindow::Zoom(BPoint origin, float width, float height) { - _ToggleFullscreen(); + ToggleFullscreen(); } @@ -1028,6 +1028,31 @@ BrowserWindow::WindowFrame() const } +void +BrowserWindow::ToggleFullscreen() +{ + if (fIsFullscreen) { + MoveTo(fNonFullscreenWindowFrame.LeftTop()); + ResizeTo(fNonFullscreenWindowFrame.Width(), + fNonFullscreenWindowFrame.Height()); + + SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE)); + SetLook(B_DOCUMENT_WINDOW_LOOK); + + _ShowInterface(true); + } else { + fNonFullscreenWindowFrame = Frame(); + _ResizeToScreen(); + + SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_MOVABLE)); + SetLook(B_TITLED_WINDOW_LOOK); + } + fIsFullscreen = !fIsFullscreen; + fFullscreenItem->SetMarked(fIsFullscreen); + fToggleFullscreenButton->SetVisible(fIsFullscreen); +} + + // #pragma mark - Notification API @@ -1848,31 +1873,6 @@ BrowserWindow::_ShowPage(BWebView* view) } -void -BrowserWindow::_ToggleFullscreen() -{ - if (fIsFullscreen) { - MoveTo(fNonFullscreenWindowFrame.LeftTop()); - ResizeTo(fNonFullscreenWindowFrame.Width(), - fNonFullscreenWindowFrame.Height()); - - SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE)); - SetLook(B_DOCUMENT_WINDOW_LOOK); - - _ShowInterface(true); - } else { - fNonFullscreenWindowFrame = Frame(); - _ResizeToScreen(); - - SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_MOVABLE)); - SetLook(B_TITLED_WINDOW_LOOK); - } - fIsFullscreen = !fIsFullscreen; - fFullscreenItem->SetMarked(fIsFullscreen); - fToggleFullscreenButton->SetVisible(fIsFullscreen); -} - - void BrowserWindow::_ResizeToScreen() { diff --git a/src/apps/webpositive/BrowserWindow.h b/src/apps/webpositive/BrowserWindow.h index adbe3742a2..16cb5d2b3d 100644 --- a/src/apps/webpositive/BrowserWindow.h +++ b/src/apps/webpositive/BrowserWindow.h @@ -109,6 +109,8 @@ public: BRect WindowFrame() const; + void ToggleFullscreen(); + private: // WebPage notification API implementations virtual void NavigationRequested(const BString& url,