Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-06-19 11:01:27 +0000
committerXi Yan2018-06-26 13:51:48 +0000
commit3bf5e22438ca9d3c26eb07f25f363fdcf8344257 (patch)
tree003a780cbee9ab4545542ddd787f0e221d9be673
parent913837c562a87a99024b3b1d5c815ed60dea5568 (diff)
downloadeclipse.platform.swt-3bf5e22438ca9d3c26eb07f25f363fdcf8344257.tar.gz
eclipse.platform.swt-3bf5e22438ca9d3c26eb07f25f363fdcf8344257.tar.xz
eclipse.platform.swt-3bf5e22438ca9d3c26eb07f25f363fdcf8344257.zip
Bug 302171 - Characters requiring <Alt Gr> cannot be generated using
Display.post(Event) 1) Added SWT.ALT_GR constant mapping to ISO_Level3_Shift (0xfe03). 2) Replaced OS.XTestFakeKeyEvent in Display.post, which only supported US keyboards, with gdk_test_simulate_key to simulate key event. Added the option to send key modifier together with key character in a single event to Display.post on GTK. Change-Id: I97311e639b612ac1f6aed23beb68034f40d211b1 Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java69
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java4
-rw-r--r--bundles/org.eclipse.swt/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.swt/pom.xml2
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java105
13 files changed, 204 insertions, 91 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
index 9b3c0d4bcd..7a7c8e0f13 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
@@ -61,9 +61,9 @@ CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo
# Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
GTKCFLAGS = `pkg-config --cflags gtk+-$(GTK_VERSION) gtk+-unix-print-$(GTK_VERSION)`
ifeq ($(GTK_VERSION), 3.0)
-GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-3 -lgdk-3 -lcairo -lgthread-2.0 -lXtst
+GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-3 -lgdk-3 -lcairo -lgthread-2.0
else
-GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-x11-$(GTK_VERSION) -lgthread-2.0 -lXtst
+GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-x11-$(GTK_VERSION) -lgthread-2.0
endif
AWT_LFLAGS = -shared ${SWT_LFLAGS}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 404666fc84..66cb86aa46 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -2817,6 +2817,18 @@ JNIEXPORT jboolean JNICALL GDK_NATIVE(_1gdk_1test_1simulate_1button)
}
#endif
+#ifndef NO__1gdk_1test_1simulate_1key
+JNIEXPORT jboolean JNICALL GDK_NATIVE(_1gdk_1test_1simulate_1key)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+ jboolean rc = 0;
+ GDK_NATIVE_ENTER(env, that, _1gdk_1test_1simulate_1key_FUNC);
+ rc = (jboolean)gdk_test_simulate_key((GdkWindow *)arg0, (gint)arg1, (gint)arg2, (guint)arg3, (GdkModifierType)arg4, (GdkEventType)arg5);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1test_1simulate_1key_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1text_1property_1to_1utf8_1list_1for_1display
JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1text_1property_1to_1utf8_1list_1for_1display)
(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jintLong arg3, jint arg4, jintLongArray arg5)
@@ -15674,18 +15686,6 @@ JNIEXPORT void JNICALL OS_NATIVE(_1XFree)
}
#endif
-#ifndef NO__1XKeysymToKeycode
-JNIEXPORT jint JNICALL OS_NATIVE(_1XKeysymToKeycode)
- (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
-{
- jint rc = 0;
- OS_NATIVE_ENTER(env, that, _1XKeysymToKeycode_FUNC);
- rc = (jint)XKeysymToKeycode((Display *)arg0, (KeySym)arg1);
- OS_NATIVE_EXIT(env, that, _1XKeysymToKeycode_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1XQueryPointer
JNIEXPORT jint JNICALL OS_NATIVE(_1XQueryPointer)
(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLongArray arg2, jintLongArray arg3, jintArray arg4, jintArray arg5, jintArray arg6, jintArray arg7, jintArray arg8)
@@ -15780,16 +15780,6 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1XSynchronize)
}
#endif
-#ifndef NO__1XTestFakeKeyEvent
-JNIEXPORT void JNICALL OS_NATIVE(_1XTestFakeKeyEvent)
- (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jboolean arg2, jintLong arg3)
-{
- OS_NATIVE_ENTER(env, that, _1XTestFakeKeyEvent_FUNC);
- XTestFakeKeyEvent((Display *)arg0, arg1, (Bool)arg2, (unsigned long)arg3);
- OS_NATIVE_EXIT(env, that, _1XTestFakeKeyEvent_FUNC);
-}
-#endif
-
#ifndef NO__1access
JNIEXPORT jint JNICALL OS_NATIVE(_1access)
(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index db9ba58217..201a87c792 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -190,6 +190,7 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1selection_1owner_1set",
"_1gdk_1set_1program_1class",
"_1gdk_1test_1simulate_1button",
+ "_1gdk_1test_1simulate_1key",
"_1gdk_1text_1property_1to_1utf8_1list_1for_1display",
"_1gdk_1unicode_1to_1keyval",
"_1gdk_1utf8_1to_1string_1target",
@@ -1282,14 +1283,12 @@ char * OS_nativeFunctionNames[] = {
"_1XDefaultRootWindow",
"_1XDefaultScreen",
"_1XFree",
- "_1XKeysymToKeycode",
"_1XQueryPointer",
"_1XSetErrorHandler",
"_1XSetIOErrorHandler",
"_1XSetInputFocus",
"_1XSetTransientForHint",
"_1XSynchronize",
- "_1XTestFakeKeyEvent",
"_1access",
"_1cachejvmptr",
#ifndef JNI64
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 85f589547b..a6970170dc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -200,6 +200,7 @@ typedef enum {
_1gdk_1selection_1owner_1set_FUNC,
_1gdk_1set_1program_1class_FUNC,
_1gdk_1test_1simulate_1button_FUNC,
+ _1gdk_1test_1simulate_1key_FUNC,
_1gdk_1text_1property_1to_1utf8_1list_1for_1display_FUNC,
_1gdk_1unicode_1to_1keyval_FUNC,
_1gdk_1utf8_1to_1string_1target_FUNC,
@@ -1268,14 +1269,12 @@ typedef enum {
_1XDefaultRootWindow_FUNC,
_1XDefaultScreen_FUNC,
_1XFree_FUNC,
- _1XKeysymToKeycode_FUNC,
_1XQueryPointer_FUNC,
_1XSetErrorHandler_FUNC,
_1XSetIOErrorHandler_FUNC,
_1XSetInputFocus_FUNC,
_1XSetTransientForHint_FUNC,
_1XSynchronize_FUNC,
- _1XTestFakeKeyEvent_FUNC,
_1access_FUNC,
_1cachejvmptr_FUNC,
#ifndef JNI64
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
index 3388cf54f2..15defef1bd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
@@ -126,6 +126,7 @@ public class GDK extends OS {
public static final int GDK_INTERP_BILINEAR = 0x2;
public static final int GDK_Insert = 0xff63;
public static final int GDK_ISO_Left_Tab = 0xfe20;
+ public static final int GDK_ISO_Level3_Shift = 0xfe03;
public static final int GDK_KEY_PRESS = 0x8;
public static final int GDK_KEY_PRESS_MASK = 0x400;
public static final int GDK_KEY_RELEASE = 0x9;
@@ -178,7 +179,8 @@ public class GDK extends OS {
* See also:
* <a href="https://askubuntu.com/questions/19558/what-are-the-meta-super-and-hyper-keys">Stack Overflow post</a>
*/
- public static final int GDK_MOD1_MASK = 0x8,
+ public static final int GDK_MOD1_MASK = 1 << 3,
+ GDK_MOD5_MASK = 1 << 7,
GDK_SUPER_MASK = 0x4000000,
GDK_HYPER_MASK = 0x8000000,
GDK_META_MASK = 0x10000000;
@@ -2297,10 +2299,8 @@ public class GDK extends OS {
* @param modifiers cast=(GdkModifierType)
* @param button_pressrelease cast=(GdkEventType)
*/
- public static final native boolean _gdk_test_simulate_button(long /*int*/ window, int x, int y, int button,
- int modifiers, int button_pressrelease);
- public static final boolean gdk_test_simulate_button(long /*int*/ window, int x, int y, int button, int modifiers,
- int button_pressrelease) {
+ public static final native boolean _gdk_test_simulate_button(long /*int*/ window, int x, int y, int button, int modifiers, int button_pressrelease);
+ public static final boolean gdk_test_simulate_button(long /*int*/ window, int x, int y, int button, int modifiers, int button_pressrelease) {
lock.lock();
try {
return _gdk_test_simulate_button(window, x, y, button, modifiers, button_pressrelease);
@@ -2309,6 +2309,23 @@ public class GDK extends OS {
}
}
/**
+ * @param window cast=(GdkWindow *)
+ * @param x cast=(gint)
+ * @param y cast=(gint)
+ * @param keyval cast=(guint)
+ * @param modifiers cast=(GdkModifierType)
+ * @param key_pressrelease cast=(GdkEventType)
+ */
+ public static final native boolean _gdk_test_simulate_key(long /*int*/ window, int x, int y, int keyval, int modifiers, int key_pressrelease);
+ public static final boolean gdk_test_simulate_key(long /*int*/ window, int x, int y, int keyval, int modifiers, int key_pressrelease) {
+ lock.lock();
+ try {
+ return _gdk_test_simulate_key(window, x, y, keyval, modifiers, key_pressrelease);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
* @param display cast=(GdkDisplay *)
* @param encoding cast=(GdkAtom)
* @param text cast=(guchar *)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 89115227c8..036f78c81b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -980,19 +980,6 @@ public static final int XQueryPointer(long /*int*/ display, long /*int*/ w, long
lock.unlock();
}
}
-/**
- * @param display cast=(Display *)
- * @param keysym cast=(KeySym)
- */
-public static final native int _XKeysymToKeycode(long /*int*/ display, long /*int*/ keysym);
-public static final int XKeysymToKeycode(long /*int*/ display, long /*int*/ keysym) {
- lock.lock();
- try {
- return _XKeysymToKeycode(display, keysym);
- } finally {
- lock.unlock();
- }
-}
/** @param handler cast=(XIOErrorHandler) */
public static final native long /*int*/ _XSetIOErrorHandler(long /*int*/ handler);
public static final long /*int*/ XSetIOErrorHandler(long /*int*/ handler) {
@@ -1051,20 +1038,6 @@ public static final long /*int*/ XSynchronize(long /*int*/ display, boolean onof
}
}
/**
- * @param display cast=(Display *)
- * @param is_press cast=(Bool)
- * @param delay cast=(unsigned long)
- */
-public static final native void _XTestFakeKeyEvent(long /*int*/ display, int keycode, boolean is_press, long /*int*/ delay);
-public static final void XTestFakeKeyEvent(long /*int*/ display, int keycode, boolean is_press, long /*int*/ delay) {
- lock.lock();
- try {
- _XTestFakeKeyEvent(display, keycode, is_press, delay);
- } finally {
- lock.unlock();
- }
-}
-/**
* @param dest cast=(void *)
* @param src cast=(const void *),flags=no_out
* @param size cast=(size_t)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index c5c6b1014b..cbbd5239ff 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -3182,6 +3182,10 @@ boolean isValidThread () {
* <li>(in) character a character that corresponds to a keyboard key</li>
* <li>(in) keyCode the key code of the key that was typed,
* as defined by the key code constants in class <code>SWT</code></li>
+ * <p> Optional (on some platforms): </p>
+ * <li>(in) stateMask the state of the keyboard modifier,
+ * as defined by the key code constants in class <code>SWT</code>
+ * </li>
* </ul>
* <p>MouseDown, MouseUp</p>
* <p>The following fields in the <code>Event</code> apply:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index af926139c0..46495f76f8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -2354,6 +2354,15 @@ public class SWT {
public static final char SPACE = ' ';
/**
+ * keyboard and/or mouse event mask indicating that the ALT_GR key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1 &lt;&lt 15).
+ *
+ * @since 3.108
+ */
+ public static final int ALT_GR = 1 << 15;
+
+ /**
* keyboard and/or mouse event mask indicating that the ALT key
* was pushed on the keyboard when the event was generated
* (value is 1&lt;&lt;16).
@@ -4594,7 +4603,7 @@ static {
* in the declaration to stop the compiler from inlining.
*/
BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5;
- MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND;
+ MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND | ALT_GR;
/*
* These values can be different on different platforms.
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 40e502e8c3..ea07490293 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
@@ -351,6 +351,7 @@ public class Display extends Device {
{GDK.GDK_Shift_R, SWT.SHIFT},
{GDK.GDK_Control_L, SWT.CONTROL},
{GDK.GDK_Control_R, SWT.CONTROL},
+ {GDK.GDK_ISO_Level3_Shift, SWT.ALT_GR},
// {OS.GDK_????, SWT.COMMAND},
// {OS.GDK_????, SWT.COMMAND},
@@ -4306,6 +4307,10 @@ long /*int*/ mouseHoverProc (long /*int*/ handle) {
* <li>(in) character a character that corresponds to a keyboard key</li>
* <li>(in) keyCode the key code of the key that was typed,
* as defined by the key code constants in class <code>SWT</code></li>
+ * <p> Optional (on some platforms): </p>
+ * <li>(in) stateMask the state of the keyboard modifier,
+ * as defined by the key code constants in class <code>SWT</code>
+ * </li>
* </ul>
* <p>MouseDown, MouseUp</p>
* <p>The following fields in the <code>Event</code> apply:
@@ -4359,15 +4364,35 @@ public boolean post (Event event) {
if (!OS.isX11()) {
return false;
}
- long /*int*/ xDisplay = GDK.gdk_x11_display_get_xdisplay(GDK.gdk_display_get_default());
int type = event.type;
+
+ if (type == SWT.MouseMove) {
+ Rectangle loc = DPIUtil.autoScaleUp(event.getBounds ());
+ setCursorLocationInPixels(new Point(loc.x, loc.y));
+ return true;
+ }
+
+ long /*int*/ gdkDisplay = GDK.gdk_display_get_default();
+ long /*int*/ gdkScreen = GDK.gdk_screen_get_default();
+ long /*int*/ gdkWindow = GDK.gdk_screen_get_active_window(gdkScreen);
+ int[] x = new int[1], y = new int[1];
+ if (gdkWindow == 0) {
+ // Under some window managers or wayland gdk can not determine the active window and passing null
+ // to gdk_test_simulate_button leads to crash.
+ return false;
+ }
+ if (GTK.GTK3) {
+ long /*int*/ gdkPointer = GDK.gdk_get_pointer(gdkDisplay);
+ GDK.gdk_window_get_device_position(gdkWindow, gdkPointer, x, y, new int[1]);
+ } else {
+ GDK.gdk_window_get_pointer(gdkWindow, x, y, new int[1]);
+ }
+
switch (type) {
case SWT.KeyDown:
case SWT.KeyUp: {
- int keyCode = 0;
- long /*int*/ keysym = untranslateKey (event.keyCode);
- if (keysym != 0) keyCode = OS.XKeysymToKeycode (xDisplay, keysym);
- if (keyCode == 0) {
+ int keysym = untranslateKey (event.keyCode);
+ if (keysym == 0) {
char key = event.character;
switch (key) {
case SWT.BS: keysym = GDK.GDK_BackSpace; break;
@@ -4379,15 +4404,18 @@ public boolean post (Event event) {
default:
keysym = key;
}
- keyCode = OS.XKeysymToKeycode (xDisplay, keysym);
- if (keyCode == 0) return false;
+ if (keysym == 0) return false;
}
- OS.XTestFakeKeyEvent (xDisplay, keyCode, type == SWT.KeyDown, 0);
- return true;
- }
- case SWT.MouseMove: {
- Rectangle loc = DPIUtil.autoScaleUp(event.getBounds ());
- setCursorLocationInPixels(new Point(loc.x, loc.y));
+ int modifier = 0;
+ switch (event.stateMask) {
+ case SWT.SHIFT: modifier = GDK.GDK_SHIFT_MASK; break;
+ case SWT.ALT: modifier = GDK.GDK_MOD1_MASK; break;
+ case SWT.CONTROL: modifier = GDK.GDK_CONTROL_MASK; break;
+ case SWT.ALT_GR: modifier = GDK.GDK_MOD5_MASK; break;
+ default:
+ modifier = 0;
+ }
+ GDK.gdk_test_simulate_key(gdkWindow, x[0], y[0], keysym, modifier, type == SWT.KeyDown ? GDK.GDK_KEY_PRESS: GDK.GDK_KEY_RELEASE);
return true;
}
case SWT.MouseDown:
@@ -4401,21 +4429,6 @@ public boolean post (Event event) {
case 5: button = 7; break;
default: return false;
}
- long /*int*/ gdkDisplay = GDK.gdk_display_get_default();
- long /*int*/ gdkScreen = GDK.gdk_screen_get_default();
- long /*int*/ gdkWindow = GDK.gdk_screen_get_active_window(gdkScreen);
- int[] x = new int[1], y = new int[1];
- if (gdkWindow == 0) {
- // Under some window managers or wayland gdk can not determine the active window and passing null
- // to gdk_test_simulate_button leads to crash.
- return false;
- }
- if (GTK.GTK3) {
- long /*int*/ gdkPointer = GDK.gdk_get_pointer(gdkDisplay);
- GDK.gdk_window_get_device_position(gdkWindow, gdkPointer, x, y, new int[1]);
- } else {
- GDK.gdk_window_get_pointer(gdkWindow, x, y, new int[1]);
- }
GDK.gdk_test_simulate_button(gdkWindow, x[0], y[0], button, 0, type == SWT.MouseDown ? GDK.GDK_BUTTON_PRESS: GDK.GDK_BUTTON_RELEASE);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index feb9016f3c..3499e184b5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -3317,6 +3317,10 @@ int numpadKey (int key) {
* <li>(in) character a character that corresponds to a keyboard key</li>
* <li>(in) keyCode the key code of the key that was typed,
* as defined by the key code constants in class <code>SWT</code></li>
+ * <p> Optional (on some platforms): </p>
+ * <li>(in) stateMask the state of the keyboard modifier,
+ * as defined by the key code constants in class <code>SWT</code>
+ * </li>
* </ul>
* <p>MouseDown, MouseUp</p>
* <p>The following fields in the <code>Event</code> apply:
diff --git a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
index 631a12b120..9362276bdf 100644
--- a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt; singleton:=true
-Bundle-Version: 3.107.100.qualifier
+Bundle-Version: 3.108.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: plugin
DynamicImport-Package: org.eclipse.swt.accessibility2
diff --git a/bundles/org.eclipse.swt/pom.xml b/bundles/org.eclipse.swt/pom.xml
index 3f4be6f28f..12d0467bd8 100644
--- a/bundles/org.eclipse.swt/pom.xml
+++ b/bundles/org.eclipse.swt/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt</artifactId>
- <version>3.107.100-SNAPSHOT</version>
+ <version>3.108.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<forceContextQualifier>v20180625-1540</forceContextQualifier>
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java
new file mode 100644
index 0000000000..503d14c469
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug302171_AltGr {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ final Text text = new Text(shell, SWT.BORDER);
+ text.setSize(text.computeSize(150, SWT.DEFAULT));
+ shell.pack();
+ shell.open();
+
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+ String string = "q23";
+
+ for (int i = 0; i < string.length(); i++) {
+ char ch = string.charAt(i);
+
+ /* Press the character */
+ Event event = new Event();
+ event.type = SWT.KeyDown;
+ event.character = ch;
+ display.post(event);
+
+ /* Release the character */
+ event.type = SWT.KeyUp;
+ display.post(event);
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+ /* Press SHIFT + ch */
+ event = new Event();
+ event.type = SWT.KeyDown;
+ event.character = ch;
+ event.stateMask = SWT.SHIFT;
+ display.post(event);
+
+ /* Release the character */
+ event.type = SWT.KeyUp;
+ display.post(event);
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+ /* Press ALT_GR + ch */
+ event = new Event();
+ event.type = SWT.KeyDown;
+ event.character = ch;
+ event.stateMask = SWT.ALT_GR;
+ display.post(event);
+
+ /* Release the character */
+ event.type = SWT.KeyUp;
+ display.post(event);
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+
+ }
+ }
+ }.start();
+
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+}

Back to the top