diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-08-30 15:04:37 -0400 |
---|---|---|
committer | Arun Thondapu <arunkumar.thondapu@in.ibm.com> | 2012-09-28 18:12:11 +0530 |
commit | d09696dd083310684def500d9edb9cfc5d6dd4ab (patch) | |
tree | 8b1196f49286e1660de2fa84ec5347dfc9306d63 | |
parent | 7a617d8b29a0a612c98003cb9099decc03b18770 (diff) | |
download | eclipse.platform.swt-d09696dd083310684def500d9edb9cfc5d6dd4ab.tar.gz eclipse.platform.swt-d09696dd083310684def500d9edb9cfc5d6dd4ab.tar.xz eclipse.platform.swt-d09696dd083310684def500d9edb9cfc5d6dd4ab.zip |
Bug 388528 Use gdk_device_ungrab() instead of gdk_pointer_ungrab() in GTK3+
10 files changed, 70 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java index f2c713ec68..d955029fd6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java @@ -315,7 +315,14 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){ * NOTE: We believe that it is never an error to ungrab when * a drag is finished. */ - OS.gdk_pointer_ungrab(OS.GDK_CURRENT_TIME); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + long /*int*/ display = OS.gdk_window_get_display (OS.gtk_widget_get_window(widget)); + long /*int*/ device_manager = OS.gdk_display_get_device_manager (display); + long /*int*/ pointer = OS.gdk_device_manager_get_client_pointer (device_manager); + OS.gdk_device_ungrab(pointer, OS.GDK_CURRENT_TIME); + } else { + OS.gdk_pointer_ungrab(OS.GDK_CURRENT_TIME); + } OS.gdk_keyboard_ungrab(OS.GDK_CURRENT_TIME); int operation = DND.DROP_NONE; 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..38befce4d4 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 @@ -4916,6 +4916,24 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1device_1manager_1get_1client_1pointe } #endif +#ifndef NO__1gdk_1device_1ungrab +JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1device_1ungrab) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1) +{ + OS_NATIVE_ENTER(env, that, _1gdk_1device_1ungrab_FUNC); +/* + gdk_device_ungrab((GdkDevice *)arg0, (guint32)arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_device_ungrab) + if (fp) { + ((void (CALLING_CONVENTION*)(GdkDevice *, guint32))fp)((GdkDevice *)arg0, (guint32)arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1device_1ungrab_FUNC); +} +#endif + #ifndef NO__1gdk_1display_1get_1default JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1display_1get_1default) (JNIEnv *env, jclass that) @@ -6188,7 +6206,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pointer_1ungrab) (JNIEnv *env, jclass that, jint arg0) { OS_NATIVE_ENTER(env, that, _1gdk_1pointer_1ungrab_FUNC); +/* gdk_pointer_ungrab((guint32)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_pointer_ungrab) + if (fp) { + ((void (CALLING_CONVENTION*)(guint32))fp)((guint32)arg0); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1pointer_1ungrab_FUNC); } #endif 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 c1d1a65035..29f2d1a74c 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 @@ -167,6 +167,7 @@ #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_device_ungrab_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 @@ -192,6 +193,7 @@ #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_pointer_ungrab_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 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..fcd9ef1fc4 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 @@ -421,6 +421,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1cursor_1unref", "_1gdk_1device_1grab", "_1gdk_1device_1manager_1get_1client_1pointer", + "_1gdk_1device_1ungrab", "_1gdk_1display_1get_1default", "_1gdk_1display_1get_1device_1manager", "_1gdk_1display_1supports_1cursor_1color", 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..af924c2634 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 @@ -431,6 +431,7 @@ typedef enum { _1gdk_1cursor_1unref_FUNC, _1gdk_1device_1grab_FUNC, _1gdk_1device_1manager_1get_1client_1pointer_FUNC, + _1gdk_1device_1ungrab_FUNC, _1gdk_1display_1get_1default_FUNC, _1gdk_1display_1get_1device_1manager_FUNC, _1gdk_1display_1supports_1cursor_1color_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 1baf52b0ca..59314ebd05 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 @@ -4675,7 +4675,10 @@ public static final int gdk_device_grab(long /*int*/ device, long /*int*/ window lock.unlock(); } } -/** @param time cast=(guint32) */ +/** + * @method flags=dynamic + * @param time cast=(guint32) + */ public static final native void _gdk_pointer_ungrab(int time); public static final void gdk_pointer_ungrab(int time) { lock.lock(); @@ -4686,6 +4689,20 @@ public static final void gdk_pointer_ungrab(int time) { } } /** + * @method flags=dynamic + * @param device cast=(GdkDevice *) + * @param time_ cast=(guint32) + */ +public static final native void _gdk_device_ungrab(long /*int*/ device, int time_); +public static final void gdk_device_ungrab(long /*int*/ device, int time_) { + lock.lock(); + try { + _gdk_device_ungrab(device, time_); + } finally { + lock.unlock(); + } +} +/** * @param window cast=(GdkWindow *) * @param property cast=(GdkAtom) * @param type cast=(GdkAtom) 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 dd76101d62..08439027ae 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 @@ -311,7 +311,7 @@ long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ eventPtr) { event.height = height; if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width - event.x; sendSelectionEvent (SWT.Selection, event, true); - if (ptrGrabResult == OS.GDK_GRAB_SUCCESS) OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME); + if (ptrGrabResult == OS.GDK_GRAB_SUCCESS) gdk_pointer_ungrab (window, OS.GDK_CURRENT_TIME); if (isDisposed ()) break; if (event.doit) { 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 fe81d14776..628c2bbd45 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 @@ -2100,7 +2100,7 @@ public void setVisible (boolean visible) { mapped = true; if ((style & mask) != 0) { - OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME); + gdk_pointer_ungrab(shellHandle,OS.GDK_CURRENT_TIME); } opened = true; if (!moved) { 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 8ecf5d5815..1c67b98671 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 @@ -988,7 +988,7 @@ public void setStippled (boolean stippled) { } void ungrab () { - if (grabbed) OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME); + if (grabbed) gdk_pointer_ungrab(window, OS.GDK_CURRENT_TIME); } void update () { 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 8d86e07d3a..3be94d91d4 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 @@ -1866,6 +1866,17 @@ int gdk_pointer_grab (long /*int*/ window, int grab_ownership, boolean owner_eve } } +void gdk_pointer_ungrab (long /*int*/ window, int time_) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + long /*int*/ display = OS.gdk_window_get_display (window); + long /*int*/ device_manager = OS.gdk_display_get_device_manager (display); + long /*int*/ pointer = OS.gdk_device_manager_get_client_pointer (device_manager); + OS.gdk_device_ungrab(pointer, time_); + } else { + OS.gdk_pointer_ungrab(time_); + } +} + /** * Returns a string containing a concise, human-readable * description of the receiver. |