Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Ufimtsev2018-01-12 22:15:35 +0000
committerAlexander Kurtakov2018-01-16 09:29:33 +0000
commitd20833d611fabe3f4a3379e7f84c5548311c7aa2 (patch)
tree12d213d3441977727e9f59d27aca7d7e535ed4d9
parentb9cd894e2e65adb61527215cc8bcf4b1bb76b2b3 (diff)
downloadeclipse.platform.swt-d20833d611fabe3f4a3379e7f84c5548311c7aa2.tar.gz
eclipse.platform.swt-d20833d611fabe3f4a3379e7f84c5548311c7aa2.tar.xz
eclipse.platform.swt-d20833d611fabe3f4a3379e7f84c5548311c7aa2.zip
Bug 528414 (swtWaylandLauncher) Part 1.1 Only load GDBus with flag.
GDBus should only be initiated if the relevant property is set by launcher or by system property. The reason is that without this, a snippet or any generic SWT application can steal the gdbus session bus. I've got the launcher to work with this property (set -Dswt.dbus.init jvm arg), I will update my launcher patch. Also removing warning about session name being stolen to reduce console noise. Change-Id: Id441f0604e2b202b8cf9ac45cc3fc3362cddcc74 Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java16
2 files changed, 23 insertions, 7 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 21bbf2f99c..9a85c87327 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
@@ -81,6 +81,13 @@ public class GDBus {
}
}
+ /**
+ * Instantiate GDBus for use by SWT.
+ * Note, a new SWT instance that runs this "Steals" org.eclipse.swt session bus,
+ * but upon termination it returns the session back to the previous owner.
+ *
+ * @param methods GDBus methods that we should handle.
+ */
public static void init (GDBusMethod[] methods) {
if (!initialized)
initialized = true;
@@ -133,9 +140,9 @@ public class GDBus {
handleMethod = new Callback (GDBus.class, "handleMethod", 8); //$NON-NLS-1$
if (handleMethod.getAddress () == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
- String swt_lib_versions = OS.getEnvironmentalVariable (OS.SWT_LIB_VERSIONS); // Note, this is read in multiple places. //leotask move string to a constant in OS.java
+ String swt_lib_versions = OS.getEnvironmentalVariable (OS.SWT_LIB_VERSIONS); // Note, this is read in multiple places.
if (swt_lib_versions != null && swt_lib_versions.equals("1")) {
- System.out.println("SWT_LIB GDbus implementation v1.");
+ System.out.println("SWT_LIB GDbus firing up. Implementation v1.1");
}
}
@@ -209,7 +216,8 @@ public class GDBus {
@SuppressWarnings("unused") // Callback Only called directly by JNI.
private static long /*int*/ onNameLost (long /*int*/ connection, long /*int*/ name, long /*int*/ user_data) {
- System.err.println("SWT GDBus.java: Lost GDBus name. Maybe stolen?");
+ // Currently not used, but can be used if losing the gdbus name should trigger something.
+ // As a note, if another instance steals the name, upon it's terminate the session is returned to it's former owner.
return 0;
}
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 4a1c936285..b3339705e3 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
@@ -1106,16 +1106,24 @@ void createDisplay (DeviceData data) {
OS.g_signal_connect (OS.gdk_keymap_get_default (), OS.keys_changed, keysChangedProc, 0);
- { // GDBus
- // Handle files passed to Eclipse via GDBus. (e.g from Equinox launcher).
- // For example, this call can be reached via:
+ // Handle gdbus on 'org.eclipse.swt' DBus session.
+ // E.g equinox launcher passes files to SWT via gdbus. "./eclipse myFile".
+ //
+ // 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.
+ // We only initiate GDBus if system property is set.
+ //
+ // To force enable this, in a run-configuration, under arguments, append to the "VM arguments" : -Dswt.dbus.init.
+ // For equinox launcher, See eclipseGtk.c:argVM_JAVA
+ if (System.getProperty("swt.dbus.init") != null) {
+ // For example, fileOpenMethod call can be reached via:
// gdbus call --session --dest org.eclipse.swt --object-path /org/eclipse/swt --method org.eclipse.swt.FileOpen "['/tmp/hi','/tmp/there']"
// 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"
GDBusMethod fileOpenMethod = new GDBusMethod(
"FileOpen",
- new String [][] {{OS.DBUS_TYPE_STRING_ARRAY,"FileNameArray"}},
+ new String [][] {{OS.DBUS_TYPE_STRING_ARRAY,"FileNameArray"}}, // 'FileNameArray' is only descriptive name for arg for human use from gdbus cmdline.
new String [0][0],
(args) -> {
String[] fileNames = (String[]) args[0]; // Arg 1 is an arraay of strings.

Back to the top