Introduced --fullscreen and -f command line options.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@506 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-05-19 22:52:34 +00:00 committed by Alexandre Deckner
parent f94d5e2800
commit e979801bf7
4 changed files with 61 additions and 43 deletions

View File

@ -102,6 +102,11 @@ BrowserApp::ArgvReceived(int32 argc, char** argv)
{ {
BMessage message(B_REFS_RECEIVED); BMessage message(B_REFS_RECEIVED);
for (int i = 1; i < argc; i++) { 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]; const char* url = argv[i];
BEntry entry(argv[i], true); BEntry entry(argv[i], true);
BPath path; BPath path;
@ -163,16 +168,15 @@ BrowserApp::ReadyToRun()
fInitialized = true; fInitialized = true;
int32 pagesCreated = 0; int32 pagesCreated = 0;
bool fullscreen = false;
if (fLaunchRefsMessage) { if (fLaunchRefsMessage) {
_RefsReceived(fLaunchRefsMessage, &pagesCreated); _RefsReceived(fLaunchRefsMessage, &pagesCreated, &fullscreen);
delete fLaunchRefsMessage; delete fLaunchRefsMessage;
fLaunchRefsMessage = 0; fLaunchRefsMessage = NULL;
}
if (pagesCreated == 0) {
BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings,
"");
window->Show();
} }
if (pagesCreated == 0)
_CreateNewWindow("", fullscreen);
PostMessage(PRELOAD_BROWSING_HISTORY); PostMessage(PRELOAD_BROWSING_HISTORY);
} }
@ -284,10 +288,15 @@ BrowserApp::QuitRequested()
void void
BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated) BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
bool* _fullscreen)
{ {
int32 pagesCreated = 0; int32 pagesCreated = 0;
bool fullscreen;
if (message->FindBool("fullscreen", &fullscreen) != B_OK)
fullscreen = false;
entry_ref ref; entry_ref ref;
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) { for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
BEntry entry(&ref, true); BEntry entry(&ref, true);
@ -298,23 +307,25 @@ BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated)
continue; continue;
BString url; BString url;
url << path.Path(); url << path.Path();
_CreateNewPage(url); _CreateNewPage(url, fullscreen);
pagesCreated++; pagesCreated++;
} }
BString url; BString url;
for (int32 i = 0; message->FindString("url", i, &url) == B_OK; i++) { for (int32 i = 0; message->FindString("url", i, &url) == B_OK; i++) {
_CreateNewPage(url); _CreateNewPage(url, fullscreen);
pagesCreated++; pagesCreated++;
} }
if (_pagesCreated != NULL) if (_pagesCreated != NULL)
*_pagesCreated = pagesCreated; *_pagesCreated = pagesCreated;
if (_fullscreen != NULL)
*_fullscreen = fullscreen;
} }
void void
BrowserApp::_CreateNewPage(const BString& url) BrowserApp::_CreateNewPage(const BString& url, bool fullscreen)
{ {
uint32 workspace = 1 << current_workspace(); uint32 workspace = 1 << current_workspace();
@ -334,12 +345,12 @@ BrowserApp::_CreateNewPage(const BString& url)
if (loadedInWindowOnCurrentWorkspace) if (loadedInWindowOnCurrentWorkspace)
return; return;
} }
_CreateNewWindow(url); _CreateNewWindow(url, fullscreen);
} }
void 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 // Offset the window frame unless this is the first window created in the
// session. // session.
@ -350,6 +361,8 @@ BrowserApp::_CreateNewWindow(const BString& url)
BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings, BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings,
url); url);
if (fullscreen)
window->ToggleFullscreen();
window->Show(); window->Show();
} }

View File

@ -54,9 +54,12 @@ public:
private: private:
void _RefsReceived(BMessage* message, void _RefsReceived(BMessage* message,
int32* pagesCreated = NULL); int32* pagesCreated = NULL,
void _CreateNewPage(const BString& url); bool* fullscreen = NULL);
void _CreateNewWindow(const BString& url); void _CreateNewPage(const BString& url,
bool fullscreen = false);
void _CreateNewWindow(const BString& url,
bool fullscreen = false);
void _CreateNewTab(BrowserWindow* window, void _CreateNewTab(BrowserWindow* window,
const BString& url, bool select); const BString& url, bool select);
void _ShowWindow(const BMessage* message, void _ShowWindow(const BMessage* message,

View File

@ -674,7 +674,7 @@ BrowserWindow::MessageReceived(BMessage* message)
break; break;
case TOGGLE_FULLSCREEN: case TOGGLE_FULLSCREEN:
_ToggleFullscreen(); ToggleFullscreen();
break; break;
case TOGGLE_AUTO_HIDE_INTERFACE_IN_FULLSCREEN: case TOGGLE_AUTO_HIDE_INTERFACE_IN_FULLSCREEN:
@ -863,7 +863,7 @@ BrowserWindow::MenusBeginning()
void void
BrowserWindow::Zoom(BPoint origin, float width, float height) 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 // #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 void
BrowserWindow::_ResizeToScreen() BrowserWindow::_ResizeToScreen()
{ {

View File

@ -109,6 +109,8 @@ public:
BRect WindowFrame() const; BRect WindowFrame() const;
void ToggleFullscreen();
private: private:
// WebPage notification API implementations // WebPage notification API implementations
virtual void NavigationRequested(const BString& url, virtual void NavigationRequested(const BString& url,