summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop
diff options
context:
space:
mode:
authorAlexander Kurtakov <akurtako@redhat.com>2012-10-09 18:53:58 +0300
committerAlexander Kurtakov <akurtako@redhat.com>2012-10-09 18:53:58 +0300
commitd035d311c7d866b11a51f8d6a8606684f71437d5 (patch)
tree26f7d29f80f8ceb7d3bae3b06739d5e15fd6bddb /bundles/org.eclipse.swt/Eclipse SWT Drag and Drop
parent6ac63603920d3df0b4f4be8ddd3df920bd8537e0 (diff)
downloadeclipse.platform.swt-d035d311c7d866b11a51f8d6a8606684f71437d5.tar.gz
eclipse.platform.swt-d035d311c7d866b11a51f8d6a8606684f71437d5.tar.xz
eclipse.platform.swt-d035d311c7d866b11a51f8d6a8606684f71437d5.zip
GdkDragContext replaced by function calls.
When struct is sealed we don't have access to the members directly so they have to be accessed via function calls.
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Drag and Drop')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java21
2 files changed, 28 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();