@@ -0,0 +1,592 @@
+Index: widget/public/nsIXRemoteClient.idl
+===================================================================
+RCS file: /cvsroot/mozilla/widget/public/nsIXRemoteClient.idl,v
+retrieving revision 1.3
+diff -u -p -6 -r1.3 nsIXRemoteClient.idl
+--- widget/public/nsIXRemoteClient.idl 18 Apr 2004 22:00:14 -0000 1.3
++++ widget/public/nsIXRemoteClient.idl 1 Mar 2005 07:18:09 -0000
+@@ -42,13 +42,13 @@
+ [scriptable, uuid(0bafc924-1dd2-11b2-8345-b59762ae0df7)]
+ interface nsIXRemoteClient : nsISupports
+ {
+ /**
+ * Initializes the client
+ */
+- void init();
++ void init(in string aDisplay);
+
+ /**
+ * Sends a command to a running instance. If it returns false then
+ * there is no running instance.
+ *
+ * @param aProgram This is the preferred program that we want to use
+Index: widget/src/xremoteclient/XRemoteClient.cpp
+===================================================================
+RCS file: /cvsroot/mozilla/widget/src/xremoteclient/XRemoteClient.cpp,v
+retrieving revision 1.16
+diff -u -p -6 -r1.16 XRemoteClient.cpp
+--- widget/src/xremoteclient/XRemoteClient.cpp 19 Feb 2005 16:11:58 -0000 1.16
++++ widget/src/xremoteclient/XRemoteClient.cpp 1 Mar 2005 07:18:19 -0000
+@@ -106,20 +106,20 @@ static char *XAtomNames[] = {
+ MOZILLA_PROFILE_PROP,
+ MOZILLA_PROGRAM_PROP
+ };
+ static Atom XAtoms[ARRAY_LENGTH(XAtomNames)];
+
+ NS_IMETHODIMP
+-XRemoteClient::Init (void)
++XRemoteClient::Init (const char *aDisplay)
+ {
+ PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("XRemoteClient::Init"));
+
+ if (mInitialized)
+ return NS_OK;
+ // try to open the display
+- mDisplay = XOpenDisplay(0);
++ mDisplay = XOpenDisplay(aDisplay);
+ if (!mDisplay)
+ return NS_ERROR_FAILURE;
+
+ // get our atoms
+ XInternAtoms(mDisplay, XAtomNames, ARRAY_LENGTH(XAtomNames), False, XAtoms);
+
+Index: widget/src/xremoteclient/mozilla-xremote-client.cpp
+===================================================================
+RCS file: /cvsroot/mozilla/widget/src/xremoteclient/mozilla-xremote-client.cpp,v
+retrieving revision 1.5
+diff -u -p -6 -r1.5 mozilla-xremote-client.cpp
+--- widget/src/xremoteclient/mozilla-xremote-client.cpp 1 Dec 2004 22:27:00 -0000 1.5
++++ widget/src/xremoteclient/mozilla-xremote-client.cpp 1 Mar 2005 07:18:33 -0000
+@@ -41,29 +41,42 @@
+ #include <plgetopt.h>
+ #ifdef MOZ_WIDGET_PHOTON
+ #include "PhRemoteClient.h"
+ #else
+ #include "XRemoteClient.h"
+ #endif
++#include <string.h>
+
+ static void print_usage(void);
+
+ int main(int argc, char **argv)
+ {
+ nsresult rv;
+ XRemoteClient client;
+ char *browser = 0;
+ char *profile = 0;
+ char *username = 0;
+ char *command = 0;
++ char *display = 0;
++ PRInt32 i = 0;
+
+ if (argc < 2) {
+ print_usage();
+ return 4;
+ }
+
++ for (i=1; i < argc - 1; i++) {
++ if (strcmp(argv[i], "--display") == 0) {
++ display = argv[i + 1];
++ /* Now remove the --display parameters from the command line */
++ memmove(&argv[i], &argv[i + 2], sizeof(argv[i])*(argc - (i + 2)));
++ argc -= 2;
++ break;
++ }
++ }
++
+ PLOptStatus os;
+ PLOptState *opt = PL_CreateOptState(argc, argv, "ha:u:p:");
+ while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {
+ if (PL_OPT_BAD == os) {
+ print_usage();
+ return 4;
+@@ -87,13 +100,13 @@ int main(int argc, char **argv)
+ command = strdup(opt->value);
+ default:
+ break;
+ }
+ }
+
+- rv = client.Init();
++ rv = client.Init(display);
+ // failed to connect to the X server
+ if (NS_FAILED(rv))
+ return 1;
+
+ // send the command - it doesn't get any easier than this
+ PRBool success = PR_FALSE;
+@@ -124,10 +137,11 @@ int main(int argc, char **argv)
+ // else, everything is fine.
+ return 0;
+ }
+
+ /* static */
+ void print_usage(void) {
+- fprintf(stderr, "Usage: mozilla-xremote-client [-a firefox|thunderbird|mozilla|any]\n");
++ fprintf(stderr, "Usage: mozilla-xremote-client [--display DISPLAY]\n");
++ fprintf(stderr, " [-a firefox|thunderbird|mozilla|any]\n");
+ fprintf(stderr, " [-u <username>]\n");
+ fprintf(stderr, " [-p <profile>] COMMAND\n");
+ }
+Index: xpfe/bootstrap/nsAppRunner.cpp
+===================================================================
+RCS file: /cvsroot/mozilla/xpfe/bootstrap/nsAppRunner.cpp,v
+retrieving revision 1.428
+diff -u -p -6 -r1.428 nsAppRunner.cpp
+--- xpfe/bootstrap/nsAppRunner.cpp 20 Dec 2004 21:53:33 -0000 1.428
++++ xpfe/bootstrap/nsAppRunner.cpp 1 Mar 2005 07:18:46 -0000
+@@ -1436,13 +1436,13 @@ static nsresult DumpVersion(char *appnam
+ return rv;
+ }
+
+ #ifdef MOZ_ENABLE_XREMOTE
+ // use int here instead of a PR type since it will be returned
+ // from main - just to keep types consistent
+-static int HandleRemoteArguments(int argc, char* argv[], PRBool *aArgUsed)
++static int HandleRemoteArguments(int argc, char* argv[], char* display, PRBool *aArgUsed)
+ {
+ int i = 0;
+
+ const char *remote = 0;
+ const char *profile = 0;
+ const char *program = 0;
+@@ -1497,13 +1497,13 @@ static int HandleRemoteArguments(int arg
+ nsCOMPtr<nsIXRemoteClient> client (do_CreateInstance(NS_XREMOTECLIENT_CONTRACTID));
+ if (!client)
+ return 1;
+
+ nsresult rv;
+ // try to init - connects to the X server and stuff
+- rv = client->Init();
++ rv = client->Init(display);
+ if (NS_FAILED(rv)) {
+ PR_fprintf(PR_STDERR, "Error: Failed to connect to X server.\n");
+ return 1;
+ }
+
+ // Make sure to set a username if possible
+@@ -1691,12 +1691,28 @@ int main(int argc, char* argv[])
+ fprintf(stderr, "%s: XInitThreads failure.", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ }
+ #endif /* MOZ_X11 */
+
++ // save --display parameter for possible -remote handling
++ // (it will be lost after gtk_init)
++ char *display = 0;
++ char *param = 0;
++ for (int i=1; i<argc; i++) {
++ if ((PL_strncasecmp(argv[i], "-display", 7) == 0)
++ || (PL_strncasecmp(argv[i], "--display", 8) == 0)) {
++ if ((param = PL_strchr(argv[i], '=')) != NULL)
++ display = PL_strdup(++param);
++ else
++ display = PL_strdup(argv[i + 1]);
++ if (! *display)
++ display = nsnull;
++ }
++ }
++
+ #if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
+ // setup for private colormap. Ideally we'd like to do this
+ // in nsAppShell::Create, but we need to get in before gtk
+ // has been initialized to make sure everything is running
+ // consistently.
+ for (i=1; i<argc; i++)
+@@ -1793,13 +1809,13 @@ int main(int argc, char* argv[])
+ #ifdef MOZ_ENABLE_XREMOTE
+ // handle -remote now that xpcom is fired up
|