Open bookmarks in the current window

* Instead of looking for the first window in the workspace, add the
current one to the message.
* Fixes #6623.
This commit is contained in:
Adrien Destugues
2014-01-14 10:31:41 +01:00
parent d21e9097b6
commit dd71f18175
3 changed files with 25 additions and 4 deletions
+23 -4
View File
@@ -356,6 +356,10 @@ BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
{ {
int32 pagesCreated = 0; int32 pagesCreated = 0;
BrowserWindow* window = NULL;
if (message->FindPointer("window", (void**)&window) != B_OK)
window = NULL;
bool fullscreen; bool fullscreen;
if (message->FindBool("fullscreen", &fullscreen) != B_OK) if (message->FindBool("fullscreen", &fullscreen) != B_OK)
fullscreen = false; fullscreen = false;
@@ -370,13 +374,13 @@ BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
continue; continue;
BString url; BString url;
url << path.Path(); url << path.Path();
_CreateNewPage(url, fullscreen); _CreateNewPage(url, window, 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, fullscreen); _CreateNewPage(url, window, fullscreen);
pagesCreated++; pagesCreated++;
} }
@@ -388,13 +392,28 @@ BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
void void
BrowserApp::_CreateNewPage(const BString& url, bool fullscreen) BrowserApp::_CreateNewPage(const BString& url, BrowserWindow* webWindow,
bool fullscreen)
{ {
// Let's first see if we must target a specific window
if (webWindow && webWindow->Lock()) {
if (webWindow->IsBlankTab()) {
if (url.Length() != 0)
webWindow->CurrentWebView()->LoadURL(url);
} else
webWindow->CreateNewTab(url, true);
webWindow->Activate();
webWindow->CurrentWebView()->MakeFocus(true);
webWindow->Unlock();
return;
}
// In other cases, try to find a suitable one
uint32 workspace = 1 << current_workspace(); uint32 workspace = 1 << current_workspace();
bool loadedInWindowOnCurrentWorkspace = false; bool loadedInWindowOnCurrentWorkspace = false;
for (int i = 0; BWindow* window = WindowAt(i); i++) { for (int i = 0; BWindow* window = WindowAt(i); i++) {
BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window); webWindow = dynamic_cast<BrowserWindow*>(window);
if (!webWindow) if (!webWindow)
continue; continue;
if (webWindow->Lock()) { if (webWindow->Lock()) {
+1
View File
@@ -59,6 +59,7 @@ private:
int32* pagesCreated = NULL, int32* pagesCreated = NULL,
bool* fullscreen = NULL); bool* fullscreen = NULL);
void _CreateNewPage(const BString& url, void _CreateNewPage(const BString& url,
BrowserWindow* window = NULL,
bool fullscreen = false); bool fullscreen = false);
void _CreateNewWindow(const BString& url, void _CreateNewWindow(const BString& url,
bool fullscreen = false); bool fullscreen = false);
+1
View File
@@ -841,6 +841,7 @@ BrowserWindow::MessageReceived(BMessage* message)
if (alert->Go() == 0) if (alert->Go() == 0)
break; break;
} }
message->AddPointer("window", this);
be_app->PostMessage(message); be_app->PostMessage(message);
break; break;
} }