Community
Participate
Working Groups
Create an SWT control and implement a DragSource for it (using SWT API), then create an embedded AWT frame and implement a DropTarget for AWT component (using AWT API). Drag and drop from SWT to AWT does not work: the AWT DropTarget does not receive any events. It's a regression: SWT 4.6 and 4.6.3 work fine, versions 4.7-4.12 are broken. Snippet to reproduce is below. Run the app and DND the 1st button onto the 3rd one public static void main(String[] args) { Shell shell = new Shell(SWT.DIALOG_TRIM); shell.setLayout(new GridLayout(3, true)); Button sourceButton = new Button(shell, SWT.PUSH); sourceButton.setText("Source"); Button targetButton = new Button(shell, SWT.PUSH); targetButton.setText("SWT Target"); Composite swingContainer = new Composite(shell, SWT.EMBEDDED); Frame frame = SWT_AWT.new_Frame(swingContainer); JButton swingButton = new JButton("Swing target"); frame.add(swingButton); shell.open(); shell.pack(); DragSource ds = new DragSource(sourceButton, DND.DROP_MOVE); ds.setTransfer(new Transfer[] { TextTransfer.getInstance() }); ds.addDragListener(new DragSourceAdapter() { @Override public void dragSetData(DragSourceEvent event) { event.data = "Hello"; } }); DropTarget dt = new DropTarget(targetButton, DND.DROP_MOVE); dt.setTransfer(new Transfer[] { TextTransfer.getInstance() }); dt.addDropListener(new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { System.err.println("Drop success: " + event.data); } }); java.awt.dnd.DropTarget awtdt = new java.awt.dnd.DropTarget(swingButton, new DropTargetListener() { @Override public void dropActionChanged(DropTargetDragEvent dtde) { } @Override public void drop(DropTargetDropEvent dtde) { dtde.acceptDrop(DnDConstants.ACTION_MOVE); System.err.println("drop " + dtde.getTransferable()); } @Override public void dragOver(DropTargetDragEvent dtde) { System.err.println("Drap over"); } @Override public void dragExit(java.awt.dnd.DropTargetEvent dte) { } @Override public void dragEnter(DropTargetDragEvent dtde) { System.err.println("Drag enter"); } }); Display display = shell.getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
Bug introduced with this commit https://github.com/eclipse/eclipse.platform.swt/commit/2214fda883b89bb4f8ad39483d2e3f9ae1a89294#diff-ab3368475e42eefccd01a40e9f83bb54
(In reply to Oleksandr Zakusylo from comment #1) > Bug introduced with this commit > https://github.com/eclipse/eclipse.platform.swt/commit/ > 2214fda883b89bb4f8ad39483d2e3f9ae1a89294#diff- > ab3368475e42eefccd01a40e9f83bb54 Oleksandr, thanks for reporting/bisecting; do you want to provide a patch?
Great bug report, with a snippet and broken commit. I have a patch. Old code called XEmbeddedFrame(handle, supportsXEmbed=true). New code calls XEmbeddedFrame(handle), with supportsXEmbed being false by default.
New Gerrit change created: https://git.eclipse.org/r/144922
*** Bug 551303 has been marked as a duplicate of this bug. ***
Gerrit change https://git.eclipse.org/r/144922 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=12688564aa61bc1acdbefae82b591a84767f8dca
(In reply to Eclipse Genie from comment #6) > Gerrit change https://git.eclipse.org/r/144922 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=12688564aa61bc1acdbefae82b591a84767f8dca Merged the patch to master as it also fixes bug 550517. I'll keep this ticket open (for now) to look at the warning when dragExit is sent.
The main bug here is fixed so we don't need to target this for 4.14. The warnings can be investigated for 4.15.
What is left here ?
(In reply to Alexander Kurtakov from comment #9) > What is left here ? There are at least two issues with dragging (from my comments on Gerrit): 1) When dragging out of the AWT frame: (SWT:587): Gtk-CRITICAL **: 16:24:35.696: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed 2) Drag exit event is triggered with a delay (need to move the mouse a bit) and the error coincides with drag exit firing. I was testing with WSL+VcXsrv, maybe native Linux won't have those issues. I guess we can close this and open new bugs for the above problems, when/if they are confirmed.
Please re-target as required.