diff options
author | Will Rogers | 2020-08-28 11:12:02 +0000 |
---|---|---|
committer | Lars Vogel | 2020-09-07 07:14:22 +0000 |
commit | 3ca3f06eed3590e589fc5f8d79968245b635e47a (patch) | |
tree | 9d5b1f0b69ac870645c059197db35b9df1ec50ee | |
parent | 07e00b6afdbac167fa940c135b167e1044537562 (diff) | |
download | eclipse.platform.swt-3ca3f06eed3590e589fc5f8d79968245b635e47a.tar.gz eclipse.platform.swt-3ca3f06eed3590e589fc5f8d79968245b635e47a.tar.xz eclipse.platform.swt-3ca3f06eed3590e589fc5f8d79968245b635e47a.zip |
Bug 566133 - Use appName in launcher.
Change-Id: I4cf56210baeb6f6b24b89c467dbe87e882d128b2
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java | 19 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java | 10 |
2 files changed, 21 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java index 2e3b3d62f0..bd1e9d776d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java @@ -129,12 +129,19 @@ public class GDBus { /** * Instantiate GDBus for use by SWT. - * Note, a new SWT instance that runs this "Steals" org.eclipse.swt session bus, + * Note, a new SWT instance that runs this "Steals" the session bus, * but upon termination it returns the session back to the previous owner. * + * To make this more flexible we append appName (derived from the + * application executable but can be set with the command-line argument + * -name) to the session name. + * * @param methods GDBus methods that we should handle. + * @param appName appName to append to GDBus object name if not null */ - public static void init (GDBusMethod[] methods) { + public static void init (GDBusMethod[] methods, String appName) { + String serviceName = DBUS_SERVICE_NAME; + if (!initialized) initialized = true; else @@ -145,10 +152,14 @@ public class GDBus { return; } + if (appName != null) { + serviceName += "." + appName; + } + gdbusMethods = Arrays.asList(methods); int owner_id = OS.g_bus_own_name(OS.G_BUS_TYPE_SESSION, - Converter.javaStringToCString(DBUS_SERVICE_NAME), + Converter.javaStringToCString(serviceName), OS.G_BUS_NAME_OWNER_FLAGS_REPLACE | OS.G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, // Allow name to be used by other eclipse instances. onBusAcquired.getAddress(), onNameAcquired.getAddress(), // name_acquired_handler @@ -157,7 +168,7 @@ public class GDBus { 0); // user_data_free_func if (owner_id == 0) { - System.err.println("SWT GDBus: Failed to aquire bus name: " + DBUS_SERVICE_NAME); + System.err.println("SWT GDBus: Failed to aquire bus name: " + serviceName); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java index 8236afae69..b37bb0ecc7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java @@ -763,8 +763,10 @@ public void addListener (int eventType, Listener listener) { * Handle gdbus on 'org.eclipse.swt' DBus session. * E.g equinox launcher passes files/urls to SWT via gdbus. "./eclipse myFile" or "./eclipse http://www.google.com" * - * Only one SWT instance can hold the unique and well-known name at one time, so we have to be mindful - * of the case where an SWT app could steal the well-known name and make the equinox launcher confused. + * Only one SWT instance can hold the unique and well-known name at one time. + * We construct the name as org.eclipse.swt.NAME (e.g. org.eclipse.swt.Eclipse), + * where NAME is derived from the application executable but may be changed + * using the command-line argument -name. * * For equinox launcher, See eclipseGtk.c:gtkPlatformJavaSystemProperties */ @@ -772,7 +774,7 @@ private void gdbus_init_methods() { GDBusMethod[] methods = { new GDBusMethod( // FileOpen call can be reached via: - // gdbus call --session --dest org.eclipse.swt --object-path /org/eclipse/swt --method org.eclipse.swt.FileOpen "['/tmp/hi','http://www.eclipse.org']" + // gdbus call --session --dest org.eclipse.swt.Eclipse --object-path /org/eclipse/swt --method org.eclipse.swt.FileOpen "['/tmp/hi','http://www.eclipse.org']" // See Bug525305_Browser_OpenUrl.java test snippet for testing/verification. // In a child eclipse, this will open the files in a new editor. // This is reached by equinox launcher from eclipseGtk.c. Look for "g_dbus_proxy_call_sync" @@ -799,7 +801,7 @@ private void gdbus_init_methods() { return null; }) }; - GDBus.init(methods); + GDBus.init(methods, getAppName()); } long allChildrenProc (long widget, long recurse) { |