diff options
author | Ian Pun | 2017-04-11 19:03:51 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-04-18 07:20:10 +0000 |
commit | 70514a80262b38f5ef57c53d18cc3f840bdd8c9d (patch) | |
tree | c984e893f62b92f007e33a1734d4679dfbf1bd7c /bundles/org.eclipse.swt/Eclipse SWT Drag and Drop | |
parent | 1efd0242e92f0b837bc0bfc5bcc80085d15d9d8d (diff) | |
download | eclipse.platform.swt-70514a80262b38f5ef57c53d18cc3f840bdd8c9d.tar.gz eclipse.platform.swt-70514a80262b38f5ef57c53d18cc3f840bdd8c9d.tar.xz eclipse.platform.swt-70514a80262b38f5ef57c53d18cc3f840bdd8c9d.zip |
Bug 515035 - [Wayland] DnD on text causes null pointer exception
Fixed issue that causes a null pointer exception called on GTKText (SWT
Text) widget. Reasoning behind the changes is that in GTK3.14 there was
a change to how GTK handles DnD automatically for GTKText, causing drag
detection from SWT to fight over GTK. In the case that GTK were to win
the DnD, SWT was not signaled about that event, thus causing a null
pointer when the target item is copied/moved as the target item was
never instantiated.
From my investigation, the Text field was broken way before my patch,
and seem to have been caused by GTK3.14 unnoticed.
Change-Id: I23d102d49c97f9c8b138d355cd01ee49f3cfc19a
Signed-off-by: Ian Pun <ipun@redhat.com>
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.java | 31 |
1 files changed, 31 insertions, 0 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 f4299e2ee9..6826e7a8d6 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 @@ -114,10 +114,13 @@ public class DragSource extends Widget { static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ + static Callback DragBegin; static Callback DragGetData; static Callback DragEnd; static Callback DragDataDelete; static { + DragBegin = new Callback(DragSource.class, "DragBegin", 2); + if (DragBegin.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS); //$NON-NLS-1$ DragGetData = new Callback(DragSource.class, "DragGetData", 5); //$NON-NLS-1$ if (DragGetData.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS); DragEnd = new Callback(DragSource.class, "DragEnd", 2); //$NON-NLS-1$ @@ -166,6 +169,7 @@ public DragSource(Control control, int style) { } control.setData(DND.DRAG_SOURCE_KEY, this); + OS.g_signal_connect(control.handle, OS.drag_begin, DragBegin.getAddress(), 0); OS.g_signal_connect(control.handle, OS.drag_data_get, DragGetData.getAddress(), 0); OS.g_signal_connect(control.handle, OS.drag_end, DragEnd.getAddress(), 0); OS.g_signal_connect(control.handle, OS.drag_data_delete, DragDataDelete.getAddress(), 0); @@ -204,6 +208,13 @@ static int checkStyle (int style) { return style; } +static long /*int*/ DragBegin(long /*int*/ widget, long /*int*/ context){ + DragSource source = FindDragSource(widget); + if (source == null) return 0; + source.dragBegin(widget, context); + return 0; +} + static long /*int*/ DragDataDelete(long /*int*/ widget, long /*int*/ context){ DragSource source = FindDragSource(widget); if (source == null) return 0; @@ -312,6 +323,26 @@ void drag(Event dragEvent) { } } +void dragBegin(long /*int*/ widget, long /*int*/ context) { + /* + * Bug 515035: GTK DnD hijacks the D&D logic we have in SWT. + * When we recieve the signal from GTK of DragBegin, we will + * notify SWT that a drag has occurred. + */ + if (OS.GTK_VERSION >= OS.VERSION(3, 14, 0) && this.control instanceof Text) { + DNDEvent event = new DNDEvent(); + event.widget = this; + event.doit = true; + notifyListeners(DND.DragStart, event); + if (!event.doit || transferAgents == null || transferAgents.length == 0) return; + if (targetList == 0) return; + Image image = event.image; + if (context != 0 && image != null) { + OS.gtk_drag_set_icon_surface(context, image.surface); + } + } +} + void dragEnd(long /*int*/ widget, long /*int*/ context){ /* * Bug in GTK. If a drag is initiated using gtk_drag_begin and the |