| Summary: | [DND] On Linux-gtk, the SWT.Activate event is not fired to the popup shell during a dragging operation | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Mei Thom <mei_thom> | ||||
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> | ||||
| Status: | CLOSED WORKSFORME | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | cbeth, cchiang, cocoakevin, duongn, ericwill, snorthov | ||||
| Version: | 3.2.2 | Keywords: | triaged | ||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux-GTK | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Mei Thom
Created attachment 66364 [details]
Sinppet to demo the missing of SWT.Activate event fired to the dropdown shell during a draggin operation on Linux
Here are the println statements from running the snippet on Windows:
(When drag over on to the "Drop target" button:)
dropDownShell gets Activate event!
(When release mouse as a drop on the "Drop target" button:)
Drag source
(When mouse click outside the dropdown shell:)
dropDownShell entering Deactivate event handler and will hide the dropdown shell
dropDownShell entering Deactivate event handler and will hide the dropdown shell
Here are the println statements from running the snippet on Linux (SLED10):
(When drag over on to the "Drop target" button, only see the dropdown shell displayed and no output)
(When release mouse as a drop on the "Drop target" button:)
Drag source
(When mouse click outside the dropdown shell, no output and the dropdown shell stays opened.)
Duong, please investigate and determine whether the missing activate event is happening when drag and drop is removed. If so, give this report to Bogdan and CC Kevin. Duong, see comment in this bug report. I don't think this has anything to do with drag-and-drop. I removed all the dnd code (removed DragSource and DropTarget completely) and re-ran the example.
Press the first button ("Drop target") and the drop down shell appears. Click anywhere outside of the drop down shell and it's still visible.
Reassigning to Bogdan. The ON_TOP shell never went away for Duong because of bug 186557. With the very latest from HEAD, the shell sends the deactivate event properly. I just commented out all the drag and drop codes and ran it again: 1. Click on the "Drop target" button. The dropdown shell pops up and see this on the console: "dropDwonShell gets Activate event!" 2. Click outside the dropdown shell (not the "Drop target" button though) and the dropdonw shell is closed. On the console, I see this: "dropDownShell entering Deactivate event handler and will hide the dropdown shell" If you click on the "Drop target" button to try to close the dropdown shell, the dropdown shell will be closed and pops up again. Please see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=184974 [SWT] Extra mouseDown event on second press on Button object I got the latest code from Kevin and the problem only happens during DND.
During the drag-and-drop, the drop-down-shell does not receive any focus events to activate it. The main shell always has focus. Currently, I don't have a fix for this problem.
I have some work arounds for you that may work:
1) Remove the SW.ON_TOP style from the drop-down-shell.
OR
2) Hide the drop-down-shell when you leave the drop target
eg.
public void dragLeave(DropTargetEvent event) {
if (dropDownShell.isVisible()) {
hideDropDown(dropDownShell);
}
}
OR
3) Activate the drop-down-shell when the drag-and-drop is complated
eg.
public void dragFinished(DragSourceEvent event) {
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
dropDownShell.setActive();
}
});
}
Hopefully one of these work arounds can be used to solve your problem.
Thank you for finding workarounds. However, 1) and 2) won't work for us and maybe 3) stands a chance: 1) We need the SWT.ON_TOP style bit for the dropdown menu because on RHEL4, when navigate down some submenu levels, the application crashes due to X Window error. Please see the error message on the Comment #4 of https://bugs.eclipse.org/bugs/show_bug.cgi?id=173335. 2) After the drop, we need to update the UI on the dropdown menu to reflect the change, so need to keep the menu opened. 3) The drag source is from other contribution components, so we cannot call dropDownShell.setActive() from dragFinished(). I did try adding to call dropDownShell.setActive() or dropDownShell.forceFocus() at the end of drop(), but still did not work. However, I did not use display.asyncExec() and don't know if this will make a difference. I'll try this way and let you know if this helps. The workaround #3 works. I put the codes in the workaround #3 to the end of drop() and the dropDownShell could get the Activate event. Hence the dropDownShell could get the Deactivate event later when we click on outside the dropDownShell. However, if I just call dropDownShell.setActive() directly instead of using Display.getCurrent().asyncExec(), the dropDownShell still did not get the Activate event. Can you tell me why only asyncExec() worked? Thanks! During the drag, any activate events are consumed somewhere and are ignored. The drop event is still within the scope of a drag-and-drop. When you wrapper the activate call inside the asyncExec(), the call will be deferred until after the dnd has completed. I can no longer reproduce this issue, closing. Please re-open with details if the issue persists. |