Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-06-11 11:34:36 -0400
committerEric Williams2019-06-11 14:41:57 -0400
commitaedb93fcdacf0c965a697676566985de1ac16f45 (patch)
treeb466757241336eb8ac37b21760755ccf47b1f992
parentc4446b5e7d895c1bbe3231a1b6440910c7c14932 (diff)
downloadeclipse.platform.swt-aedb93fcdacf0c965a697676566985de1ac16f45.tar.gz
eclipse.platform.swt-aedb93fcdacf0c965a697676566985de1ac16f45.tar.xz
eclipse.platform.swt-aedb93fcdacf0c965a697676566985de1ac16f45.zip
Bug 546349: [Wayland] Prevent GtkIMContext crashes/warnings
Enforce ibus as the input method on GNOME, since this is the only thing GNOME honors anyways. Prevents crashes on flatpak, and AllNonBrowser tests running on GTK3.24+. Change-Id: I3d9abf4cb7a4ad40acfdbc95ea949142bff50aeb Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java17
2 files changed, 16 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index fa288104ba..fc15134ac6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -205,6 +205,7 @@ public class GTK extends OS {
public static final byte[] gtk_menu_bar_accel = OS.ascii("gtk-menu-bar-accel");
public static final byte[] gtk_menu_images = OS.ascii("gtk-menu-images");
public static final byte[] gtk_theme_name = OS.ascii("gtk-theme-name");
+ public static final byte[] gtk_im_module = OS.ascii("gtk-im-module");
/** Misc **/
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 103bde2ebc..7b6f1a4323 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
@@ -199,12 +199,14 @@ public class Display extends Device {
this.parent = parent;
}
+ @Override
public boolean isReadyToExit() {
Event event = new Event ();
parent.sendEvent(SWT.Close, event);
return event.doit;
}
+ @Override
public void stop() {
parent.dispose();
}
@@ -1047,20 +1049,31 @@ protected void create (DeviceData data) {
/**
* Check if the XIM module is present and generates a warning for potential graphical issues
* if GTK_IM_MODULE=xim is detected. See Bug 517671.
+ *
+ * Additionally, this method enforces IBus as the input method for SWT-GTK on GNOME.
+ * This is because GNOME forces IBus by default, so any discrepancy can cause crashes on newer
+ * versions of GTK3.
*/
-void checkXimModule () {
+void checkIMModule () {
Map<String, String> env = System.getenv();
String module = env.get("GTK_IM_MODULE");
if (module != null && module.equals("xim")) {
System.err.println("***WARNING: Detected: GTK_IM_MODULE=xim. This input method is unsupported and can cause graphical issues.");
System.err.println("***WARNING: Unset GTK_IM_MODULE or set GTK_IM_MODULE=ibus if flicking is experienced. ");
}
+ // Enforce ibus as the input module on GNOME
+ String desktopEnvironment = env.get("XDG_CURRENT_DESKTOP");
+ if ("GNOME".equals(desktopEnvironment)) {
+ long settings = GTK.gtk_settings_get_default ();
+ byte[] ibus = Converter.wcsToMbcs ("ibus", true);
+ if (settings != 0) OS.g_object_set (settings, GTK.gtk_im_module, ibus, 0);
+ }
}
void createDisplay (DeviceData data) {
boolean init = GTK.GTK4 ? GTK.gtk_init_check () : GTK.gtk_init_check (new long [] {0}, null);
if (!init) SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]"); //$NON-NLS-1$
- checkXimModule();
+ checkIMModule();
//set GTK+ Theme name as property for introspection purposes
if (OS.GTK_THEME_SET) {
String themeName = OS.GTK_THEME_NAME + (OS.GTK_THEME_DARK ? ":dark" : "");

Back to the top