Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnatoly Spektor2012-08-31 13:24:37 +0000
committerArun Thondapu2012-09-14 18:13:27 +0000
commit0d5ff2d1bd886c3158c6b1ddc492d0be811c0650 (patch)
tree6728244a2da0cbd9f4d13682f6fadd4fa6d67a71
parentfcedd75ab00195e6ab4eff556609d14004db3d8c (diff)
downloadeclipse.platform.swt-0d5ff2d1bd886c3158c6b1ddc492d0be811c0650.tar.gz
eclipse.platform.swt-0d5ff2d1bd886c3158c6b1ddc492d0be811c0650.tar.xz
eclipse.platform.swt-0d5ff2d1bd886c3158c6b1ddc492d0be811c0650.zip
Bug 388461 Use gdk_device_grab() instead of gdk_pointer_grab() in GTK+3 and higher
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c88
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java17
8 files changed, 178 insertions, 4 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 e5d7b05768..4e3b0f2d57 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
@@ -4876,6 +4876,46 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cursor_1unref)
}
#endif
+#ifndef NO__1gdk_1device_1grab
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1device_1grab)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jboolean arg3, jint arg4, jintLong arg5, jint arg6)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gdk_1device_1grab_FUNC);
+/*
+ rc = (jint)gdk_device_grab((GdkDevice *)arg0, (GdkWindow *)arg1, arg2, (gboolean)arg3, (GdkEventMask)arg4, (GdkCursor *)arg5, (guint32)arg6);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_device_grab)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GdkDevice *, GdkWindow *, jint, gboolean, GdkEventMask, GdkCursor *, guint32))fp)((GdkDevice *)arg0, (GdkWindow *)arg1, arg2, (gboolean)arg3, (GdkEventMask)arg4, (GdkCursor *)arg5, (guint32)arg6);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1device_1grab_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1device_1manager_1get_1client_1pointer
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1device_1manager_1get_1client_1pointer)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gdk_1device_1manager_1get_1client_1pointer_FUNC);
+/*
+ rc = (jintLong)gdk_device_manager_get_client_pointer(arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_device_manager_get_client_pointer)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1device_1manager_1get_1client_1pointer_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1display_1get_1default
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1display_1get_1default)
(JNIEnv *env, jclass that)
@@ -4896,6 +4936,26 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1display_1get_1default)
}
#endif
+#ifndef NO__1gdk_1display_1get_1device_1manager
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1display_1get_1device_1manager)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gdk_1display_1get_1device_1manager_FUNC);
+/*
+ rc = (jintLong)gdk_display_get_device_manager((GdkDisplay *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_display_get_device_manager)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkDisplay *))fp)((GdkDisplay *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1display_1get_1device_1manager_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1display_1supports_1cursor_1color
JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1display_1supports_1cursor_1color)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -6109,7 +6169,15 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pointer_1grab)
{
jint rc = 0;
OS_NATIVE_ENTER(env, that, _1gdk_1pointer_1grab_FUNC);
+/*
rc = (jint)gdk_pointer_grab((GdkWindow *)arg0, (gboolean)arg1, (GdkEventMask)arg2, (GdkWindow *)arg3, (GdkCursor *)arg4, (guint32)arg5);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_pointer_grab)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GdkWindow *, gboolean, GdkEventMask, GdkWindow *, GdkCursor *, guint32))fp)((GdkWindow *)arg0, (gboolean)arg1, (GdkEventMask)arg2, (GdkWindow *)arg3, (GdkCursor *)arg4, (guint32)arg5);
+ }
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1pointer_1grab_FUNC);
return rc;
}
@@ -6694,6 +6762,26 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1window_1get_1children)
}
#endif
+#ifndef NO__1gdk_1window_1get_1display
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1window_1get_1display)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1display_FUNC);
+/*
+ rc = (jintLong)gdk_window_get_display((GdkWindow *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_window_get_display)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkWindow *))fp)((GdkWindow *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1display_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1window_1get_1events
JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1get_1events)
(JNIEnv *env, jclass that, jintLong arg0)
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 741eeb657c..08633b994f 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
@@ -165,6 +165,9 @@
#define gtk_entry_set_icon_sensitive_LIB LIB_GTK
#define gtk_tooltips_new_LIB LIB_GTK
#define gdk_cursor_new_from_pixbuf_LIB LIB_GDK
+#define gdk_device_manager_get_client_pointer_LIB LIB_GDK
+#define gdk_device_grab_LIB LIB_GDK
+#define gdk_display_get_device_manager_LIB LIB_GDK
#define gdk_display_get_default_LIB LIB_GDK
#define gdk_display_supports_cursor_color_LIB LIB_GDK
#define gdk_draw_arc_LIB LIB_GDK
@@ -188,6 +191,7 @@
#define gdk_gc_set_values_LIB LIB_GDK
#define gdk_gc_get_values_LIB LIB_GDK
#define gdk_pixbuf_save_to_bufferv_LIB LIB_GDK
+#define gdk_pointer_grab_LIB LIB_GDK
#define gdk_screen_get_default_LIB LIB_GDK
#define gdk_screen_get_monitor_at_point_LIB LIB_GDK
#define gdk_screen_get_monitor_at_window_LIB LIB_GDK
@@ -215,6 +219,7 @@
#define gdk_window_get_height_LIB LIB_GDK
#define gdk_window_get_width_LIB LIB_GDK
#define gdk_pixmap_get_size_LIB LIB_GDK
+#define gdk_window_get_display_LIB LIB_GDK
#define gdk_window_set_keep_above_LIB LIB_GDK
#define gdk_window_set_accept_focus_LIB LIB_GDK
#define gtk_window_set_opacity_LIB LIB_GTK
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 fe80e26f18..c664affb05 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
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1340;
-int OS_nativeFunctionCallCount[1340];
+int OS_nativeFunctionCount = 1344;
+int OS_nativeFunctionCallCount[1344];
char * OS_nativeFunctionNames[] = {
#ifndef JNI64
"Call__IIII",
@@ -420,7 +420,10 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1cursor_1new_1from_1pixbuf",
"_1gdk_1cursor_1new_1from_1pixmap",
"_1gdk_1cursor_1unref",
+ "_1gdk_1device_1grab",
+ "_1gdk_1device_1manager_1get_1client_1pointer",
"_1gdk_1display_1get_1default",
+ "_1gdk_1display_1get_1device_1manager",
"_1gdk_1display_1supports_1cursor_1color",
"_1gdk_1drag_1status",
"_1gdk_1draw_1arc",
@@ -536,6 +539,7 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1window_1end_1paint",
"_1gdk_1window_1focus",
"_1gdk_1window_1get_1children",
+ "_1gdk_1window_1get_1display",
"_1gdk_1window_1get_1events",
"_1gdk_1window_1get_1frame_1extents",
"_1gdk_1window_1get_1height",
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 f336786e61..9276e7f987 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
@@ -428,7 +428,10 @@ typedef enum {
_1gdk_1cursor_1new_1from_1pixbuf_FUNC,
_1gdk_1cursor_1new_1from_1pixmap_FUNC,
_1gdk_1cursor_1unref_FUNC,
+ _1gdk_1device_1grab_FUNC,
+ _1gdk_1device_1manager_1get_1client_1pointer_FUNC,
_1gdk_1display_1get_1default_FUNC,
+ _1gdk_1display_1get_1device_1manager_FUNC,
_1gdk_1display_1supports_1cursor_1color_FUNC,
_1gdk_1drag_1status_FUNC,
_1gdk_1draw_1arc_FUNC,
@@ -544,6 +547,7 @@ typedef enum {
_1gdk_1window_1end_1paint_FUNC,
_1gdk_1window_1focus_FUNC,
_1gdk_1window_1get_1children_FUNC,
+ _1gdk_1window_1get_1display_FUNC,
_1gdk_1window_1get_1events_FUNC,
_1gdk_1window_1get_1frame_1extents_FUNC,
_1gdk_1window_1get_1height_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 2bdb8c00d2..457369a96d 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
@@ -207,6 +207,7 @@ public class OS extends C {
public static final int GDK_NOTIFY_INFERIOR = 2;
public static final int GDK_Num_Lock = 0xFF7F;
public static final int GDK_OVERLAP_RECTANGLE_OUT = 0x1;
+ public static final int GDK_OWNERSHIP_NONE = 0;
public static final int GDK_PIXBUF_ALPHA_BILEVEL = 0x0;
public static final int GDK_POINTER_MOTION_HINT_MASK = 0x8;
public static final int GDK_POINTER_MOTION_MASK = 0x4;
@@ -3658,6 +3659,42 @@ public static final int /*long*/ gdk_display_get_default() {
lock.unlock();
}
}
+/**
+ * @method flags=dynamic
+ * @param window cast=(GdkWindow *)
+ */
+public static final native int /*long*/ _gdk_window_get_display(int /*long*/ window);
+public static final int /*long*/ gdk_window_get_display(int /*long*/ window) {
+ lock.lock();
+ try {
+ return _gdk_window_get_display(window);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param display cast=(GdkDisplay *)
+ */
+public static final native int /*long*/ _gdk_display_get_device_manager(int /*long*/ display);
+public static final int /*long*/ gdk_display_get_device_manager(int /*long*/ display) {
+ lock.lock();
+ try {
+ return _gdk_display_get_device_manager(display);
+ } finally {
+ lock.unlock();
+ }
+}
+/** @method flags=dynamic */
+public static final native int /*long*/ _gdk_device_manager_get_client_pointer(int /*long*/ device_manager);
+public static final int /*long*/ gdk_device_manager_get_client_pointer(int /*long*/ device_manager) {
+ lock.lock();
+ try {
+ return _gdk_device_manager_get_client_pointer(device_manager);
+ } finally {
+ lock.unlock();
+ }
+}
/** @method flags=dynamic */
public static final native boolean _gdk_display_supports_cursor_color(int /*long*/ display);
public static final boolean gdk_display_supports_cursor_color(int /*long*/ display) {
@@ -4593,6 +4630,7 @@ public static final int /*long*/ gdk_pixmap_new(int /*long*/ window, int width,
}
}
/**
+ * @method flags=dynamic
* @param window cast=(GdkWindow *)
* @param owner_events cast=(gboolean)
* @param event_mask cast=(GdkEventMask)
@@ -4609,6 +4647,24 @@ public static final int gdk_pointer_grab(int /*long*/ window, boolean owner_even
lock.unlock();
}
}
+/**
+ * @method flags=dynamic
+ * @param device cast=(GdkDevice *)
+ * @param window cast=(GdkWindow *)
+ * @param owner_events cast=(gboolean)
+ * @param event_mask cast=(GdkEventMask)
+ * @param cursor cast=(GdkCursor *)
+ * @param time_ cast=(guint32)
+ */
+public static final native int _gdk_device_grab(int /*long*/ device, int /*long*/ window, int grab_ownership, boolean owner_events, int event_mask, int /*long*/ cursor, int time_);
+public static final int gdk_device_grab(int /*long*/ device, int /*long*/ window, int grab_ownership, boolean owner_events, int event_mask, int /*long*/ cursor, int time_) {
+ lock.lock();
+ try {
+ return _gdk_device_grab(device, window, grab_ownership, owner_events, event_mask, cursor,time_);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param time cast=(guint32) */
public static final native void _gdk_pointer_ungrab(int time);
public static final void gdk_pointer_ungrab(int time) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index 3dfad2887d..3d36953665 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -298,7 +298,7 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
int /*long*/ window = gtk_widget_get_window (handle);
int grabMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK;
int /*long*/ gdkCursor = cursor != null ? cursor.handle : defaultCursor;
- int ptrGrabResult = OS.gdk_pointer_grab (window, false, grabMask, window, gdkCursor, OS.GDK_CURRENT_TIME);
+ int ptrGrabResult = gdk_pointer_grab(window, OS.GDK_OWNERSHIP_NONE, false, grabMask, window, gdkCursor, OS.GDK_CURRENT_TIME);
/* The event must be sent because its doit flag is used. */
Event event = new Event ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 9d16684e8f..55328b0627 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -368,7 +368,7 @@ public boolean getStippled () {
boolean grab () {
int /*long*/ cursor = this.cursor != null ? this.cursor.handle : 0;
- int result = OS.gdk_pointer_grab (window, false, OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK, window, cursor, OS.GDK_CURRENT_TIME);
+ int result = gdk_pointer_grab(window, OS.GDK_OWNERSHIP_NONE, false, OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK, window, cursor, OS.GDK_CURRENT_TIME);
return result == OS.GDK_GRAB_SUCCESS;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 5161141007..7be5a0e0ee 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -1849,6 +1849,23 @@ int /*long*/ gtk_box_new (int orientation, boolean homogeneous, int spacing) {
return box;
}
+int gdk_pointer_grab (int /*long*/ window, int grab_ownership, boolean owner_events, int event_mask,int /*long*/ confine_to, int /*long*/ cursor, int time_) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ int /*long*/ display = 0;
+ if( window != 0){
+ display = OS.gdk_window_get_display (window);
+ } else {
+ window = OS.gdk_get_default_root_window();
+ display = OS.gdk_window_get_display (window);
+ }
+ int /*long*/ device_manager = OS.gdk_display_get_device_manager (display);
+ int /*long*/ pointer = OS.gdk_device_manager_get_client_pointer (device_manager);
+ return OS.gdk_device_grab(pointer, window, grab_ownership, owner_events, event_mask, cursor, time_);
+ } else {
+ return OS.gdk_pointer_grab(window, owner_events, event_mask, confine_to, cursor, time_);
+ }
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.

Back to the top