aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjosh2014-07-02 22:32:37 (EDT)
committerAlexander Kurtakov2014-07-08 08:23:24 (EDT)
commitd20acf6bc5bf02e3ebe32d6b46b87685581f358f (patch)
treec319c94003023b8c024577a58a0abbb254551acc
parent910df7b7d5ce7ece90221d5b3519098e287de2db (diff)
downloadeclipse.platform.swt-d20acf6bc5bf02e3ebe32d6b46b87685581f358f.zip
eclipse.platform.swt-d20acf6bc5bf02e3ebe32d6b46b87685581f358f.tar.gz
eclipse.platform.swt-d20acf6bc5bf02e3ebe32d6b46b87685581f358f.tar.bz2
"Bug 436504 - [WIP] Wayland support is missing"refs/changes/71/29371/3
Initial Wayland support and new pointer warp function in OS Contains new check for the existence of Wayland. The display server if statements logic has been revised since the checks for Wayland and X11 can both return true on the same system at runtime. Also, gdk_device_warp has been added to OS and is used when GTK >= 3.0 It appears that Wayland will not support pointer warping. Change-Id: Ifaa223d80f8182685042aac31c2337ce7dac2fec Signed-off-by: josh <joshbarkovic@gmail.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java42
8 files changed, 77 insertions, 17 deletions
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 009fa72..1bd4486 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
@@ -5656,6 +5656,21 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cursor_1unref)
}
#endif
+#ifndef NO__1gdk_1device_1warp
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1device_1warp)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jint arg3)
+{
+ OS_NATIVE_ENTER(env, that, _1gdk_1device_1warp_FUNC);
+ {
+ OS_LOAD_FUNCTION(fp, gdk_device_warp)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GdkDevice *, GdkScreen *, gint, gint))fp)((GdkDevice *)arg0, (GdkScreen *)arg1, (gint)arg2, (gint)arg3);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1device_1warp_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1device_1get_1associated_1device
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1device_1get_1associated_1device)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
index a17f47f..6f135b1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
@@ -68,6 +68,22 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(GDK_1WINDOWING_1X11)
}
#endif
+#ifndef NO_GDK_1WINDOWING_1WAYLAND
+JNIEXPORT jboolean JNICALL OS_NATIVE(GDK_1WINDOWING_1WAYLAND)
+ (JNIEnv *env, jclass that)
+{
+ jboolean rc;
+ OS_NATIVE_ENTER(env, that, GDK_1WINDOWING_1WAYLAND_FUNC)
+#ifdef GDK_WINDOWING_WAYLAND
+ rc = (jboolean)1;
+#else
+ rc = (jboolean)0;
+#endif
+ OS_NATIVE_EXIT(env, that, GDK_1WINDOWING_1WAYLAND_FUNC)
+ return rc;
+}
+#endif
+
#ifndef NO_imContextNewProc_1CALLBACK
static jintLong superIMContextNewProc;
static GtkIMContext* lastIMContext;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 6a80f20..87fa4c8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -247,6 +247,7 @@
#define gtk_tooltips_new_LIB LIB_GTK
#define gdk_cursor_new_from_pixbuf_LIB LIB_GDK
#define gdk_cursor_unref_LIB LIB_GDK
+#define gdk_device_warp_LIB LIB_GDK
#define gdk_device_manager_get_client_pointer_LIB LIB_GDK
#define gdk_device_get_window_at_position_LIB LIB_GDK
#define gdk_device_grab_LIB LIB_GDK
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 6d23a55..3300037 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
@@ -32,6 +32,7 @@ char * OS_nativeFunctionNames[] = {
"GDK_1EVENT_1TYPE",
"GDK_1EVENT_1WINDOW",
"GDK_1WINDOWING_1X11",
+ "GDK_1WINDOWING_1WAYLAND",
"GInterfaceInfo_1sizeof",
"GPollFD_1sizeof",
"GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING",
@@ -463,6 +464,7 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1cursor_1unref",
"_1gdk_1device_1get_1associated_1device",
"_1gdk_1device_1get_1window_1at_1position",
+ "_1gdk_1device_1warp",
"_1gdk_1device_1grab",
"_1gdk_1device_1manager_1get_1client_1pointer",
"_1gdk_1device_1ungrab",
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 fd88a9b..77a38e9 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
@@ -42,6 +42,7 @@ typedef enum {
GDK_1EVENT_1TYPE_FUNC,
GDK_1EVENT_1WINDOW_FUNC,
GDK_1WINDOWING_1X11_FUNC,
+ GDK_1WINDOWING_1WAYLAND_FUNC,
GInterfaceInfo_1sizeof_FUNC,
GPollFD_1sizeof_FUNC,
GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING_FUNC,
@@ -473,6 +474,7 @@ typedef enum {
_1gdk_1cursor_1unref_FUNC,
_1gdk_1device_1get_1associated_1device_FUNC,
_1gdk_1device_1get_1window_1at_1position_FUNC,
+ _1gdk_1device_1warp_FUNC,
_1gdk_1device_1grab_FUNC,
_1gdk_1device_1manager_1get_1client_1pointer_FUNC,
_1gdk_1device_1ungrab_FUNC,
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 2e7d77d..9f33dd0 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
@@ -887,6 +887,8 @@ public static final void call_get_size (long /*int*/ function, long /*int*/ arg0
}
/** @method flags=no_gen */
public static final native boolean GDK_WINDOWING_X11();
+/** @method flags=no_gen */
+public static final native boolean GDK_WINDOWING_WAYLAND();
/** @param pixmap cast=(GdkPixmap *) */
public static final native long /*int*/ _GDK_PIXMAP_XID(long /*int*/ pixmap);
public static final long /*int*/ GDK_PIXMAP_XID(long /*int*/ pixmap) {
@@ -4124,6 +4126,18 @@ public static final long /*int*/ gdk_cursor_new_from_pixbuf(long /*int*/ display
lock.unlock();
}
}
+
+/** @method flags=dynamic */
+public static final native void _gdk_device_warp(long /*int*/ device, long /*int*/ screen, int x, int y);
+public static final void gdk_device_warp(long /*int*/ device, long /*int*/ screen, int x, int y) {
+ lock.lock();
+ try {
+ _gdk_device_warp(device, screen, x, y);
+ } finally {
+ lock.unlock();
+ }
+ }
+
/** @method flags=dynamic */
public static final native long /*int*/ _gdk_display_get_default();
public static final long /*int*/ gdk_display_get_default() {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index d0028aa..89f9f74 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -4223,7 +4223,7 @@ void setCursor (long /*int*/ cursor) {
long /*int*/ window = eventWindow ();
if (window != 0) {
OS.gdk_window_set_cursor (window, cursor);
- if (!OS.GDK_WINDOWING_X11 ()) {
+ if (OS.GDK_WINDOWING_WAYLAND() || !OS.GDK_WINDOWING_X11 ()) {
OS.gdk_flush ();
} else {
long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
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 a3cfacf..24d2d34 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
@@ -747,7 +747,7 @@ public void asyncExec (Runnable runnable) {
public void beep () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
OS.gdk_beep();
- if (!OS.GDK_WINDOWING_X11 ()) {
+ if (OS.GDK_WINDOWING_WAYLAND () || !OS.GDK_WINDOWING_X11()) {
OS.gdk_flush ();
} else {
long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
@@ -933,7 +933,7 @@ void createDisplay (DeviceData data) {
if (!OS.gtk_init_check (new long /*int*/ [] {0}, null)) {
SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]"); //$NON-NLS-1$
}
- if (OS.GDK_WINDOWING_X11 ()) xDisplay = OS.gdk_x11_get_default_xdisplay();
+ if (!OS.GDK_WINDOWING_WAYLAND () && OS.GDK_WINDOWING_X11()) xDisplay = OS.gdk_x11_get_default_xdisplay();
int major = OS.gtk_major_version ();
long /*int*/ ptr;
if (major == GTK3_MAJOR) {
@@ -1055,7 +1055,7 @@ void createDisplay (DeviceData data) {
if (filterProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
OS.gdk_window_add_filter (0, filterProc, 0);
- if (OS.GDK_WINDOWING_X11 ()) {
+ if (!OS.GDK_WINDOWING_WAYLAND () && OS.GDK_WINDOWING_X11 ()) {
long /*int*/ xWindow;
if (OS.GTK3) {
xWindow = OS.gdk_x11_window_get_xid (OS.gtk_widget_get_window (shellHandle));
@@ -1401,7 +1401,7 @@ static long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window,
void flushExposes (long /*int*/ window, boolean all) {
OS.gdk_flush ();
OS.gdk_flush ();
- if (OS.GDK_WINDOWING_X11 ()) {
+ if (!OS.GDK_WINDOWING_WAYLAND() && OS.GDK_WINDOWING_X11 ()) {
this.flushWindow = window;
this.flushAll = all;
long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
@@ -1512,7 +1512,7 @@ public Control getCursorControl () {
* if the pointer is over a foreign embedded window. The fix is to use
* XQueryPointer to find the containing GDK window.
*/
- if (!OS.GDK_WINDOWING_X11 ()) return null;
+ if (!OS.GDK_WINDOWING_X11 () || OS.GDK_WINDOWING_WAYLAND()) return null;
OS.gdk_error_trap_push ();
int[] unusedInt = new int[1];
long /*int*/[] unusedPtr = new long /*int*/[1], buffer = new long /*int*/[1];
@@ -2866,15 +2866,17 @@ void initializeWidgetTable () {
void initializeWindowManager () {
/* Get the window manager name */
windowManager = ""; //$NON-NLS-1$
- long /*int*/ screen = OS.gdk_screen_get_default ();
- if (screen != 0) {
- long /*int*/ ptr2 = OS.gdk_x11_screen_get_window_manager_name (screen);
- if (ptr2 != 0) {
- int length = OS.strlen (ptr2);
- if (length > 0) {
- byte [] buffer2 = new byte [length];
- OS.memmove (buffer2, ptr2, length);
- windowManager = new String (Converter.mbcsToWcs (null, buffer2));
+ if (!OS.GDK_WINDOWING_WAYLAND () && OS.GDK_WINDOWING_X11 ()) {
+ long /*int*/ screen = OS.gdk_screen_get_default ();
+ if (screen != 0) {
+ long /*int*/ ptr2 = OS.gdk_x11_screen_get_window_manager_name (screen);
+ if (ptr2 != 0) {
+ int length = OS.strlen (ptr2);
+ if (length > 0) {
+ byte [] buffer2 = new byte [length];
+ OS.memmove (buffer2, ptr2, length);
+ windowManager = new String (Converter.mbcsToWcs (null, buffer2));
+ }
}
}
}
@@ -3296,7 +3298,9 @@ public boolean post (Event event) {
synchronized (Device.class) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (!OS.GDK_WINDOWING_X11()) return false;
+ if (!OS.GDK_WINDOWING_X11() || OS.GDK_WINDOWING_WAYLAND()) {
+ return false;
+ }
long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
int type = event.type;
switch (type) {
@@ -3993,10 +3997,16 @@ public static void setAppVersion (String version) {
*/
public void setCursorLocation (int x, int y) {
checkDevice ();
- if (OS.GDK_WINDOWING_X11 ()) {
+ if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
long /*int*/ xWindow = OS.XDefaultRootWindow (xDisplay);
OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, x, y);
+ } else {
+ long /*int*/ gdkDisplay = OS.gdk_display_get_default();
+ long /*int*/ gdkDeviceManager = OS.gdk_display_get_device_manager(gdkDisplay);
+ long /*int*/ gdkScreen = OS.gdk_screen_get_default();
+ long /*int*/ gdkPointer = OS.gdk_device_manager_get_client_pointer(gdkDeviceManager);
+ OS.gdk_device_warp(gdkPointer,gdkScreen,x,y);
}
}