Now sends the B_SILENT_RELAUNCH message if the app is already running and has
no arguments (or doesn't want them). We even already had the correct handler for B_SILENT_RELAUNCH around :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19359 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -354,9 +354,11 @@ BApplication::_InitData(const char *signature, bool initGUI, status_t *_error)
|
|||||||
// An instance is already running and we asked for
|
// An instance is already running and we asked for
|
||||||
// single/exclusive launch. Send our argv to the running app.
|
// single/exclusive launch. Send our argv to the running app.
|
||||||
// Do that only, if the app is NOT B_ARGV_ONLY.
|
// Do that only, if the app is NOT B_ARGV_ONLY.
|
||||||
if (otherTeam >= 0 && __libc_argc > 1) {
|
if (otherTeam >= 0) {
|
||||||
|
BMessenger otherApp(NULL, otherTeam);
|
||||||
app_info otherAppInfo;
|
app_info otherAppInfo;
|
||||||
if (be_roster->GetRunningAppInfo(otherTeam, &otherAppInfo) == B_OK
|
if (__libc_argc > 1
|
||||||
|
&& be_roster->GetRunningAppInfo(otherTeam, &otherAppInfo) == B_OK
|
||||||
&& !(otherAppInfo.flags & B_ARGV_ONLY)) {
|
&& !(otherAppInfo.flags & B_ARGV_ONLY)) {
|
||||||
// create an B_ARGV_RECEIVED message
|
// create an B_ARGV_RECEIVED message
|
||||||
BMessage argvMessage(B_ARGV_RECEIVED);
|
BMessage argvMessage(B_ARGV_RECEIVED);
|
||||||
@@ -369,8 +371,9 @@ BApplication::_InitData(const char *signature, bool initGUI, status_t *_error)
|
|||||||
argvMessage.ReplaceString("argv", 0, path.Path());
|
argvMessage.ReplaceString("argv", 0, path.Path());
|
||||||
|
|
||||||
// send the message
|
// send the message
|
||||||
BMessenger(NULL, otherTeam).SendMessage(&argvMessage);
|
otherApp.SendMessage(&argvMessage);
|
||||||
}
|
} else
|
||||||
|
otherApp.SendMessage(B_SILENT_RELAUNCH);
|
||||||
}
|
}
|
||||||
} else if (fInitError == B_OK) {
|
} else if (fInitError == B_OK) {
|
||||||
// the registrations was successful
|
// the registrations was successful
|
||||||
@@ -398,30 +401,27 @@ BApplication::_InitData(const char *signature, bool initGUI, status_t *_error)
|
|||||||
PostMessage(B_READY_TO_RUN, this);
|
PostMessage(B_READY_TO_RUN, this);
|
||||||
#endif // ifndef RUN_WITHOUT_REGISTRAR
|
#endif // ifndef RUN_WITHOUT_REGISTRAR
|
||||||
|
|
||||||
|
if (fInitError == B_OK) {
|
||||||
// TODO: Not completely sure about the order, but this should be close.
|
// TODO: Not completely sure about the order, but this should be close.
|
||||||
|
|
||||||
// init be_app and be_app_messenger
|
// init be_app and be_app_messenger
|
||||||
if (fInitError == B_OK) {
|
|
||||||
be_app = this;
|
be_app = this;
|
||||||
be_app_messenger = BMessenger(NULL, this);
|
be_app_messenger = BMessenger(NULL, this);
|
||||||
}
|
|
||||||
|
|
||||||
// set the BHandler's name
|
// set the BHandler's name
|
||||||
if (fInitError == B_OK)
|
|
||||||
SetName(ref.name);
|
SetName(ref.name);
|
||||||
|
|
||||||
// create meta MIME
|
// create meta MIME
|
||||||
if (fInitError == B_OK) {
|
|
||||||
BPath path;
|
BPath path;
|
||||||
if (path.SetTo(&ref) == B_OK)
|
if (path.SetTo(&ref) == B_OK)
|
||||||
create_app_meta_mime(path.Path(), false, true, false);
|
create_app_meta_mime(path.Path(), false, true, false);
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef RUN_WITHOUT_APP_SERVER
|
#ifndef RUN_WITHOUT_APP_SERVER
|
||||||
// app server connection and IK initialization
|
// app server connection and IK initialization
|
||||||
if (fInitError == B_OK && initGUI)
|
if (initGUI)
|
||||||
fInitError = _InitGUIContext();
|
fInitError = _InitGUIContext();
|
||||||
#endif // RUN_WITHOUT_APP_SERVER
|
#endif // RUN_WITHOUT_APP_SERVER
|
||||||
|
}
|
||||||
|
|
||||||
// Return the error or exit, if there was an error and no error variable
|
// Return the error or exit, if there was an error and no error variable
|
||||||
// has been supplied.
|
// has been supplied.
|
||||||
@@ -578,12 +578,12 @@ BApplication::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bebook says: B_SILENT_RELAUNCH
|
|
||||||
// Sent to a single-launch application when it's activated by being launched
|
|
||||||
// (for example, if the user double-clicks its icon in Tracker).
|
|
||||||
case B_SILENT_RELAUNCH:
|
case B_SILENT_RELAUNCH:
|
||||||
|
// Sent to a B_SINGLE_LAUNCH application when it's launched again
|
||||||
|
// (see _InitData())
|
||||||
be_roster->ActivateApp(Team());
|
be_roster->ActivateApp(Team());
|
||||||
// supposed to fall through
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BLooper::MessageReceived(message);
|
BLooper::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user