Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-10-01 19:29:02 +0000
committerXi Yan2018-10-01 19:35:56 +0000
commit028d960d9c99ab99462a4dd2cc0df1f45585ff59 (patch)
tree9a63ad738ea85248f98778317f4cb3582901e885
parent20156cba2b80d1130301fdadecc971045039d990 (diff)
downloadeclipse.platform.swt-028d960d9c99ab99462a4dd2cc0df1f45585ff59.tar.gz
eclipse.platform.swt-028d960d9c99ab99462a4dd2cc0df1f45585ff59.tar.xz
eclipse.platform.swt-028d960d9c99ab99462a4dd2cc0df1f45585ff59.zip
Bug 539582 - [GTK3] Replace deprecated gdk_device_grab/ungrab()
Replace gdk_device_grab/ungrab with gdk_seat_grab/ungrab for GTK3.20+. Change-Id: Icf3f2900e0d9ed5768f9a887c7975f75970117c2 Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java32
6 files changed, 72 insertions, 6 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 54513a122c..50b0659b0a 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
@@ -360,8 +360,15 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){
long /*int*/ display = GDK.gdk_window_get_display(GTK.gtk_widget_get_window(widget));
long /*int*/ pointer = GDK.gdk_get_pointer(display);
long /*int*/ keyboard = GDK.gdk_device_get_associated_device(pointer);
- GDK.gdk_device_ungrab(pointer, GDK.GDK_CURRENT_TIME);
- GDK.gdk_device_ungrab(keyboard, GDK.GDK_CURRENT_TIME);
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
+ long /*int*/ pointer_seat = GDK.gdk_device_get_seat(pointer);
+ long /*int*/ keyboard_seat = GDK.gdk_device_get_seat(keyboard);
+ GDK.gdk_seat_ungrab(pointer_seat);
+ GDK.gdk_seat_ungrab(keyboard_seat);
+ } else {
+ GDK.gdk_device_ungrab(pointer, GDK.GDK_CURRENT_TIME);
+ GDK.gdk_device_ungrab(keyboard, GDK.GDK_CURRENT_TIME);
+ }
int operation = DND.DROP_NONE;
if (context != 0) {
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 4e57a25aff..2917bdc75d 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
@@ -500,6 +500,26 @@ JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1device_1get_1associated_1device)
}
#endif
+#ifndef NO__1gdk_1device_1get_1seat
+JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1device_1get_1seat)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ GDK_NATIVE_ENTER(env, that, _1gdk_1device_1get_1seat_FUNC);
+/*
+ rc = (jintLong)gdk_device_get_seat((GdkDevice *)arg0);
+*/
+ {
+ GDK_LOAD_FUNCTION(fp, gdk_device_get_seat)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkDevice *))fp)((GdkDevice *)arg0);
+ }
+ }
+ GDK_NATIVE_EXIT(env, that, _1gdk_1device_1get_1seat_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1device_1get_1window_1at_1position
JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1device_1get_1window_1at_1position)
(JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2)
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 beb67bed6f..1e94999866 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
@@ -55,6 +55,7 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1cursor_1new_1from_1name",
"_1gdk_1cursor_1new_1from_1pixbuf",
"_1gdk_1device_1get_1associated_1device",
+ "_1gdk_1device_1get_1seat",
"_1gdk_1device_1get_1window_1at_1position",
"_1gdk_1device_1grab",
"_1gdk_1device_1manager_1get_1client_1pointer",
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 80e5d1bb5f..f2de4f1f22 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
@@ -65,6 +65,7 @@ typedef enum {
_1gdk_1cursor_1new_1from_1name_FUNC,
_1gdk_1cursor_1new_1from_1pixbuf_FUNC,
_1gdk_1device_1get_1associated_1device_FUNC,
+ _1gdk_1device_1get_1seat_FUNC,
_1gdk_1device_1get_1window_1at_1position_FUNC,
_1gdk_1device_1grab_FUNC,
_1gdk_1device_1manager_1get_1client_1pointer_FUNC,
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 9831ac7b94..3db77050ba 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
@@ -1275,6 +1275,19 @@ public class GDK extends OS {
}
}
/**
+ * @method flags=dynamic
+ * @param device cast=(GdkDevice *)
+ */
+ public static final native long /*int*/ _gdk_device_get_seat(long /*int*/ device);
+ public static final long /*int*/ gdk_device_get_seat(long /*int*/ device) {
+ lock.lock();
+ try {
+ return _gdk_device_get_seat(device);
+ } 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/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 172dde0fde..ede68dba9d 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
@@ -224,6 +224,8 @@ public abstract class Widget {
static final String KEY_CHECK_SUBWINDOW = "org.eclipse.swt.internal.control.checksubwindow"; //$NON-NLS-1$
static final String KEY_GTK_CSS = "org.eclipse.swt.internal.gtk.css"; //$NON-NLS-1$
+ static Callback gdkSeatGrabPrepareFunc;
+
/**
* Prevents uninitialized instances from being created outside the package.
*/
@@ -1803,14 +1805,36 @@ int gdk_pointer_grab (long /*int*/ window, int grab_ownership, boolean owner_eve
window = GDK.gdk_get_default_root_window ();
display = GDK.gdk_window_get_display (window);
}
- long /*int*/ pointer = GDK.gdk_get_pointer(display);
- return GDK.gdk_device_grab (pointer, window, grab_ownership, owner_events, event_mask, cursor, time_);
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
+ long /*int*/ seat = GDK.gdk_display_get_default_seat(display);
+ if (gdkSeatGrabPrepareFunc == null) {
+ gdkSeatGrabPrepareFunc = new Callback(Widget.class, "GdkSeatGrabPrepareFunc", 3); //$NON-NLS-1$
+ }
+ long /*int*/ gdkSeatGrabPrepareFuncAddress = gdkSeatGrabPrepareFunc.getAddress();
+ if (gdkSeatGrabPrepareFuncAddress == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ return GDK.gdk_seat_grab(seat, window, GDK.GDK_SEAT_CAPABILITY_ALL_POINTING, owner_events, cursor, 0, gdkSeatGrabPrepareFuncAddress, window);
+ } else {
+ long /*int*/ pointer = GDK.gdk_get_pointer(display);
+ return GDK.gdk_device_grab (pointer, window, grab_ownership, owner_events, event_mask, cursor, time_);
+ }
}
void gdk_pointer_ungrab (long /*int*/ window, int time_) {
long /*int*/ display = GDK.gdk_window_get_display (window);
- long /*int*/ pointer = GDK.gdk_get_pointer(display);
- GDK.gdk_device_ungrab (pointer, time_);
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
+ long /*int*/ seat = GDK.gdk_display_get_default_seat(display);
+ GDK.gdk_seat_ungrab(seat);
+ } else {
+ long /*int*/ pointer = GDK.gdk_get_pointer(display);
+ GDK.gdk_device_ungrab (pointer, time_);
+ }
+}
+
+static long /*int*/ GdkSeatGrabPrepareFunc (long /*int*/ gdkSeat, long /*int*/ gdkWindow, long /*int*/ userData_gdkWindow) {
+ if (userData_gdkWindow != 0) {
+ GDK.gdk_window_show(userData_gdkWindow);
+ }
+ return 0;
}
/**

Back to the top