Bug 1360560 - Use DBusRemoteService when running on Wayland and DBus is available, r?glandium
MozReview-Commit-ID: EeDDNmEfL4L
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -172,16 +172,19 @@
// for X remote support
#ifdef MOZ_ENABLE_XREMOTE
#include "XRemoteClient.h"
#include "nsIRemoteService.h"
#include "nsProfileLock.h"
#include "SpecialSystemDirectory.h"
#include <sched.h>
+#ifdef MOZ_ENABLE_DBUS
+#include "DBusRemoteClient.h"
+#endif
// Time to wait for the remoting service to start
#define MOZ_XREMOTE_START_TIMEOUT_SEC 5
#endif
#if defined(DEBUG) && defined(XP_WIN32)
#include <malloc.h>
#endif
@@ -1824,28 +1827,41 @@ ParseRemoteCommandLine(nsCString& progra
return REMOTE_FOUND;
}
static RemoteResult
StartRemoteClient(const char* aDesktopStartupID,
nsCString& program,
const char* profile,
- const char* username)
+ const char* username,
+ bool aIsX11Display)
{
- XRemoteClient client;
- nsresult rv = client.Init();
+ nsAutoPtr<nsRemoteClient> client;
+
+ if (aIsX11Display) {
+ client = new XRemoteClient();
+ } else {
+#if defined(MOZ_ENABLE_DBUS) && defined(MOZ_WAYLAND)
+ client = new DBusRemoteClient();
+#else
+ MOZ_ASSERT(false, "Missing remote implementation!");
+ return REMOTE_NOT_FOUND;
+#endif
+ }
+
+ nsresult rv = client->Init();
if (NS_FAILED(rv))
return REMOTE_NOT_FOUND;
nsCString response;
bool success = false;
- rv = client.SendCommandLine(program.get(), username, profile,
- gArgc, gArgv, aDesktopStartupID,
- getter_Copies(response), &success);
+ rv = client->SendCommandLine(program.get(), username, profile,
+ gArgc, gArgv, aDesktopStartupID,
+ getter_Copies(response), &success);
// did the command fail?
if (!success)
return REMOTE_NOT_FOUND;
// The "command not parseable" error is returned when the
// nsICommandLineHandler throws a NS_ERROR_ABORT.
if (response.EqualsLiteral("500 command not parseable"))
return REMOTE_ARG_BAD;
@@ -4021,17 +4037,18 @@ XREMain::XRE_mainStartup(bool* aExitFlag
NS_WARNING("Cannot lock XRemote start mutex");
}
}
// Try to remote the entire command line. If this fails, start up normally.
const char* desktopStartupIDPtr =
mDesktopStartupID.IsEmpty() ? nullptr : mDesktopStartupID.get();
- rr = StartRemoteClient(desktopStartupIDPtr, program, profile, username);
+ rr = StartRemoteClient(desktopStartupIDPtr, program, profile, username,
+ GDK_IS_X11_DISPLAY(mGdkDisplay));
if (rr == REMOTE_FOUND) {
*aExitFlag = true;
return 0;
}
if (rr == REMOTE_ARG_BAD) {
return 1;
}
}