diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-09-24 15:11:33 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-09-24 15:11:33 -0400 |
commit | e327596d62ce7aa1d14363ea26b71360f006bbbe (patch) | |
tree | 2598f5fdcebdc3e936845f22d34031c7cf8e43a9 | |
parent | a754695634bbf4177c903eb76191590677bc9067 (diff) | |
download | eclipse.platform.swt-gtk3_device_at_pointer.tar.gz eclipse.platform.swt-gtk3_device_at_pointer.tar.xz eclipse.platform.swt-gtk3_device_at_pointer.zip |
Use gdk_device_get_window_at_position instead of gdk_window_at_pointergtk3_device_at_pointer
This patch replaces gdk_window_at_pointer with
gdk_device_get_window_at_position for GTK+3 and higher.
7 files changed, 79 insertions, 5 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 4e3b0f2d57..7693b53998 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,33 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cursor_1unref) } #endif +#ifndef NO__1gdk_1device_1get_1window_1at_1position +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1device_1get_1window_1at_1position) + (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1device_1get_1window_1at_1position_FUNC); + if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; +/* + rc = (jintLong)gdk_device_get_window_at_position(arg0, (gint *)lparg1, (gint *)lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_device_get_window_at_position) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, gint *, gint *))fp)(arg0, (gint *)lparg1, (gint *)lparg2); + } + } +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, _1gdk_1device_1get_1window_1at_1position_FUNC); + return rc; +} +#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) @@ -6678,7 +6705,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1window_1at_1pointer) OS_NATIVE_ENTER(env, that, _1gdk_1window_1at_1pointer_FUNC); if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail; if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; +/* rc = (jintLong)gdk_window_at_pointer((gint *)lparg0, (gint *)lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_window_at_pointer) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(gint *, gint *))fp)((gint *)lparg0, (gint *)lparg1); + } + } fail: if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); 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 08633b994f..0ab5d76c66 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 @@ -166,6 +166,7 @@ #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_get_window_at_position_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 @@ -218,6 +219,7 @@ #define gdk_window_restack_LIB LIB_GDK #define gdk_window_get_height_LIB LIB_GDK #define gdk_window_get_width_LIB LIB_GDK +#define gdk_window_at_pointer_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 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 3a8fbd3211..7fd244e736 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,6 +18,8 @@ #ifdef NATIVE_STATS +int OS_nativeFunctionCount = 1346; +int OS_nativeFunctionCallCount[1346]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -419,6 +421,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1cursor_1new_1from_1pixbuf", "_1gdk_1cursor_1new_1from_1pixmap", "_1gdk_1cursor_1unref", + "_1gdk_1device_1get_1window_1at_1position", "_1gdk_1device_1grab", "_1gdk_1device_1manager_1get_1client_1pointer", "_1gdk_1display_1get_1default", @@ -1725,9 +1728,6 @@ char * OS_nativeFunctionNames[] = { "realpath", "strcmp", }; -#define NATIVE_FUNCTION_COUNT sizeof(OS_nativeFunctionNames) / sizeof(char*) -int OS_nativeFunctionCount = NATIVE_FUNCTION_COUNT; -int OS_nativeFunctionCallCount[NATIVE_FUNCTION_COUNT]; #define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func 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 607863df6f..5a0a8084fe 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 @@ -429,6 +429,7 @@ typedef enum { _1gdk_1cursor_1new_1from_1pixbuf_FUNC, _1gdk_1cursor_1new_1from_1pixmap_FUNC, _1gdk_1cursor_1unref_FUNC, + _1gdk_1device_1get_1window_1at_1position_FUNC, _1gdk_1device_1grab_FUNC, _1gdk_1device_1manager_1get_1client_1pointer_FUNC, _1gdk_1display_1get_1default_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 421703038c..4824a57990 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 @@ -3705,6 +3705,20 @@ public static final int /*long*/ gdk_device_manager_get_client_pointer(int /*lon lock.unlock(); } } +/** + * @method flags=dynamic + * @param win_x cast=(gint *) + * @param win_y cast=(gint *) + * */ +public static final native int /*long*/ _gdk_device_get_window_at_position(int /*long*/ device, int[] win_x, int[] win_y); +public static final int /*long*/ gdk_device_get_window_at_position(int /*long*/ device, int[] win_x, int[] win_y) { + lock.lock(); + try { + return _gdk_device_get_window_at_position(device, win_x, win_y); + } 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) { @@ -5068,6 +5082,7 @@ public static final int /*long*/ gdk_visual_get_system() { } } /** + * @method flags=dynamic * @param win_x cast=(gint *) * @param win_y cast=(gint *) */ 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 d478017676..4a53d049b3 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 @@ -1414,7 +1414,7 @@ public Control getCursorControl () { int[] x = new int[1], y = new int[1]; int /*long*/ handle = 0; int /*long*/ [] user_data = new int /*long*/ [1]; - int /*long*/ window = OS.gdk_window_at_pointer (x,y); + int /*long*/ window = gdk_device_get_window_at_position (x,y); if (window != 0) { OS.gdk_window_get_user_data (window, user_data); handle = user_data [0]; @@ -4397,4 +4397,14 @@ int /*long*/ windowTimerProc (int /*long*/ handle) { return widget.timerProc (handle); } +int /*long*/ gdk_device_get_window_at_position (int[] win_x, int[] win_y) { + if (OS.GTK_VERSION >= OS.VERSION(3,0,0)) { + int /*long*/ display = OS.gdk_display_get_default (); + int /*long*/ device_manager = OS.gdk_display_get_device_manager (display); + int /*long*/ device = OS.gdk_device_manager_get_client_pointer (device_manager); + return OS.gdk_device_get_window_at_position (device, win_x, win_y); + } else { + return OS.gdk_window_at_pointer (win_x, win_y); + } +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 5f1a5416bc..8d626e2ceb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -2438,7 +2438,7 @@ void setToolTipText (int /*long*/ rootWidget, int /*long*/ tipWidget, String str int /*long*/ tipWindow = gtk_widget_get_window (rootWidget); if (tipWindow != 0) { int [] x = new int [1], y = new int [1]; - int /*long*/ window = OS.gdk_window_at_pointer (x, y); + int /*long*/ window = gdk_device_get_window_at_position (x, y); int /*long*/ [] user_data = new int /*long*/ [1]; if (window != 0) OS.gdk_window_get_user_data (window, user_data); if (tipWidget == user_data [0]) { @@ -2540,4 +2540,15 @@ void setToolTipText (int /*long*/ rootWidget, int /*long*/ tipWidget, String str } } + +int /*long*/ gdk_device_get_window_at_position (int[] win_x, int[] win_y) { + if (OS.GTK_VERSION >= OS.VERSION(3,0,0)) { + int /*long*/ display = OS.gdk_display_get_default (); + int /*long*/ device_manager = OS.gdk_display_get_device_manager (display); + int /*long*/ device = OS.gdk_device_manager_get_client_pointer (device_manager); + return OS.gdk_device_get_window_at_position (device, win_x, win_y); + } else { + return OS.gdk_window_at_pointer (win_x, win_y); + } +} } |