diff options
8 files changed, 179 insertions, 10 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 3e2a3b7c68..6b555eaee3 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 @@ -329,13 +329,22 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){ int operation = DND.DROP_NONE; if (context != 0) { - GdkDragContext gdkDragContext = new GdkDragContext (); - OS.memmove(gdkDragContext, context, GdkDragContext.sizeof); - if (gdkDragContext.dest_window != 0) { //NOTE: if dest_window is 0, drag was aborted + long /*int*/ dest_window = 0; + int action = 0; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + dest_window = OS.gdk_drag_context_get_dest_window(context); + action = OS.gdk_drag_context_get_selected_action(context); + } else { + GdkDragContext gdkDragContext = new GdkDragContext (); + OS.memmove(gdkDragContext, context, GdkDragContext.sizeof); + dest_window = gdkDragContext.dest_window; + action = gdkDragContext.action; + } + if (dest_window != 0) { //NOTE: if dest_window is 0, drag was aborted if (moveData) { operation = DND.DROP_MOVE; } else { - operation = osOpToOp(gdkDragContext.action); + operation = osOpToOp(action); if (operation == DND.DROP_MOVE) operation = DND.DROP_NONE; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java index cc8a14e7ac..cae866331b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java @@ -745,13 +745,22 @@ public void setDropTargetEffect(DropTargetEffect effect) { boolean setEventData(long /*int*/ context, int x, int y, int time, DNDEvent event) { if (context == 0) return false; - GdkDragContext dragContext = new GdkDragContext(); - OS.memmove(dragContext, context, GdkDragContext.sizeof); - if (dragContext.targets == 0) return false; + long /*int*/ targets = 0; + int actions = 0; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + targets = OS.gdk_drag_context_list_targets(context); + actions = OS.gdk_drag_context_get_actions(context); + } else { + GdkDragContext dragContext = new GdkDragContext(); + OS.memmove(dragContext, context, GdkDragContext.sizeof); + targets = dragContext.targets; + actions = dragContext.actions; + } + if (targets == 0) return false; // get allowed operations int style = getStyle(); - int operations = osOpToOp(dragContext.actions) & style; + int operations = osOpToOp(actions) & style; if (operations == DND.DROP_NONE) return false; // get current operation @@ -766,10 +775,10 @@ boolean setEventData(long /*int*/ context, int x, int y, int time, DNDEvent even } // Get allowed transfer types - int length = OS.g_list_length(dragContext.targets); + int length = OS.g_list_length(targets); TransferData[] dataTypes = new TransferData[0]; for (int i = 0; i < length; i++) { - long /*int*/ pData = OS.g_list_nth(dragContext.targets, i); + long /*int*/ pData = OS.g_list_nth(targets, i); GtkTargetPair gtkTargetPair = new GtkTargetPair(); OS.memmove(gtkTargetPair, pData, GtkTargetPair.sizeof); TransferData data = new TransferData(); 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 275a4cf24b..aeab8e68b7 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 @@ -5013,6 +5013,86 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1display_1supports_1cursor_1color) } #endif +#ifndef NO__1gdk_1drag_1context_1get_1actions +JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1drag_1context_1get_1actions) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1drag_1context_1get_1actions_FUNC); +/* + rc = (jint)gdk_drag_context_get_actions((GdkDragContext *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_drag_context_get_actions) + if (fp) { + rc = (jint)((jint (CALLING_CONVENTION*)(GdkDragContext *))fp)((GdkDragContext *)arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1drag_1context_1get_1actions_FUNC); + return rc; +} +#endif + +#ifndef NO__1gdk_1drag_1context_1get_1dest_1window +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1drag_1context_1get_1dest_1window) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1drag_1context_1get_1dest_1window_FUNC); +/* + rc = (jintLong)gdk_drag_context_get_dest_window((GdkDragContext *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_drag_context_get_dest_window) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkDragContext *))fp)((GdkDragContext *)arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1drag_1context_1get_1dest_1window_FUNC); + return rc; +} +#endif + +#ifndef NO__1gdk_1drag_1context_1get_1selected_1action +JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1drag_1context_1get_1selected_1action) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1drag_1context_1get_1selected_1action_FUNC); +/* + rc = (jint)gdk_drag_context_get_selected_action((GdkDragContext *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_drag_context_get_selected_action) + if (fp) { + rc = (jint)((jint (CALLING_CONVENTION*)(GdkDragContext *))fp)((GdkDragContext *)arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1drag_1context_1get_1selected_1action_FUNC); + return rc; +} +#endif + +#ifndef NO__1gdk_1drag_1context_1list_1targets +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1drag_1context_1list_1targets) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1drag_1context_1list_1targets_FUNC); +/* + rc = (jintLong)gdk_drag_context_list_targets((GdkDragContext *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_drag_context_list_targets) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkDragContext *))fp)((GdkDragContext *)arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1drag_1context_1list_1targets_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1drag_1status JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1drag_1status) (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h index 6cee2a9cd8..b4bab83dd0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h @@ -94,6 +94,13 @@ #include <X11/extensions/Xrender.h> #endif +/* Disable memmove/sizeof for sealed structs in GTK3 */ +#if GTK_CHECK_VERSION(3,0,0) +#define NO_GdkDragContext +#define NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2II +#define NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2JJ +#endif + #include "os_custom.h" #endif /* INC_os_H */ 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 53abd9c7be..b4b96bc1ab 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 @@ -181,6 +181,10 @@ #define gdk_device_get_associated_device_LIB LIB_GDK #define gdk_display_get_default_LIB LIB_GDK #define gdk_display_supports_cursor_color_LIB LIB_GDK +#define gdk_drag_context_get_actions_LIB LIB_GDK +#define gdk_drag_context_get_dest_window_LIB LIB_GDK +#define gdk_drag_context_get_selected_action_LIB LIB_GDK +#define gdk_drag_context_list_targets_LIB LIB_GDK #define gdk_draw_arc_LIB LIB_GDK #define gdk_draw_layout_LIB LIB_GDK #define gdk_draw_layout_with_colors_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 c1d3dd5e29..2e93db0168 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 @@ -424,6 +424,10 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1display_1get_1default", "_1gdk_1display_1get_1device_1manager", "_1gdk_1display_1supports_1cursor_1color", + "_1gdk_1drag_1context_1get_1actions", + "_1gdk_1drag_1context_1get_1dest_1window", + "_1gdk_1drag_1context_1get_1selected_1action", + "_1gdk_1drag_1context_1list_1targets", "_1gdk_1drag_1status", "_1gdk_1draw_1arc", "_1gdk_1draw_1drawable", 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 64fcadf690..64c93e3041 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 @@ -434,6 +434,10 @@ typedef enum { _1gdk_1display_1get_1default_FUNC, _1gdk_1display_1get_1device_1manager_FUNC, _1gdk_1display_1supports_1cursor_1color_FUNC, + _1gdk_1drag_1context_1get_1actions_FUNC, + _1gdk_1drag_1context_1get_1dest_1window_FUNC, + _1gdk_1drag_1context_1get_1selected_1action_FUNC, + _1gdk_1drag_1context_1list_1targets_FUNC, _1gdk_1drag_1status_FUNC, _1gdk_1draw_1arc_FUNC, _1gdk_1draw_1drawable_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 6c1525fe64..a8edc1713b 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 @@ -3740,6 +3740,58 @@ public static final boolean gdk_display_supports_cursor_color(long /*int*/ displ } } /** + * @method flags=dynamic + * @param context cast=(GdkDragContext *) + */ +public static final native int _gdk_drag_context_get_actions(long /*int*/ context); +public static final int gdk_drag_context_get_actions(long /*int*/ context) { + lock.lock(); + try { + return _gdk_drag_context_get_actions(context); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + * @param context cast=(GdkDragContext *) + */ +public static final native long /*int*/ _gdk_drag_context_get_dest_window(long /*int*/ context); +public static final long /*int*/ gdk_drag_context_get_dest_window(long /*int*/ context) { + lock.lock(); + try { + return _gdk_drag_context_get_dest_window(context); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + * @param context cast=(GdkDragContext *) + */ +public static final native int _gdk_drag_context_get_selected_action(long /*int*/ context); +public static final int gdk_drag_context_get_selected_action(long /*int*/ context) { + lock.lock(); + try { + return _gdk_drag_context_get_selected_action(context); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + * @param context cast=(GdkDragContext *) + */ +public static final native long /*int*/ _gdk_drag_context_list_targets(long /*int*/ context); +public static final long /*int*/ gdk_drag_context_list_targets(long /*int*/ context) { + lock.lock(); + try { + return _gdk_drag_context_list_targets(context); + } finally { + lock.unlock(); + } +} +/** * @param context cast=(GdkDragContext *) * @param action cast=(GdkDragAction) * @param time cast=(guint32) |