Bug 548661 - [GTK] DND from SWT to embbedded AWT frame (SWT_AWT) is broken on Linux
Summary: [GTK] DND from SWT to embbedded AWT frame (SWT_AWT) is broken on Linux
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.7   Edit
Hardware: PC Linux
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Nikita Nemkin CLA
QA Contact: Eric Williams CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-06-26 04:59 EDT by Alexander Zakusylo CLA
Modified: 2020-03-09 02:25 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Zakusylo CLA 2019-06-26 04:59:01 EDT
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();
    }
  }
}
Comment 2 Andrey Loskutov CLA 2019-06-26 07:17:55 EDT
(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?
Comment 3 Nikita Nemkin CLA 2019-06-26 07:26:42 EDT
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.
Comment 4 Eclipse Genie CLA 2019-06-26 07:31:14 EDT
New Gerrit change created: https://git.eclipse.org/r/144922
Comment 5 Eric Williams CLA 2019-09-20 11:35:47 EDT
*** Bug 551303 has been marked as a duplicate of this bug. ***
Comment 7 Eric Williams CLA 2019-11-06 14:32:39 EST
(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.
Comment 8 Eric Williams CLA 2019-11-13 10:56:34 EST
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.
Comment 9 Alexander Kurtakov CLA 2020-02-27 09:41:32 EST
What is left here ?
Comment 10 Nikita Nemkin CLA 2020-02-27 09:56:13 EST
(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.
Comment 11 Lakshmi P Shanmugam CLA 2020-03-09 02:25:09 EDT
Please re-target as required.