Bug 393868 - [DND] DND with event.image causes redraw problems when Control#update is used
Summary: [DND] DND with event.image causes redraw problems when Control#update is used
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.8   Edit
Hardware: All Windows All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 393514
  Show dependency tree
 
Reported: 2012-11-08 08:02 EST by Peter Severin CLA
Modified: 2020-04-13 08:09 EDT (History)
1 user (show)

See Also:


Attachments
SWT test case that shows the issue. (5.75 KB, text/x-java)
2012-11-08 08:02 EST, Peter Severin CLA
no flags Details
The screenshot that shows the redraw issue (8.61 KB, image/png)
2012-11-08 08:02 EST, Peter Severin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Severin CLA 2012-11-08 08:02:16 EST
Created attachment 223348 [details]
SWT test case that shows the issue.

I am trying to implement drag & drop of resource files from Project Explorer into a GEF editor. When the file is dragged over I want to show some feedback under the mouse cursor. This results in a bad repaint issue on Windows only. Specifically the area under the dragged image is not repainted correctly.

After looking into it I narrowed it down to SWT. GEF uses a specific way of repainting the canvas, specifically it calls Control#redraw() that is immediately followed by Control#update(). This call to update is the one that causes the issue.

After looking more into it I narrowed my search to the following code in DropTarget class:

DropTarget#DragOver {
...
	notifyListeners(event.type, event);
	refresh();
...
}

Refresh method is the one that normally forces the repaint:

void refresh() {
	if (control == null || control.isDisposed()) return;
	int /*long*/ handle = control.handle;
	RECT lpRect = new RECT();
	if (OS.GetUpdateRect(handle, lpRect, false)) {
		OS.ImageList_DragShowNolock(false);
		OS.RedrawWindow(handle, lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE);
		OS.ImageList_DragShowNolock(true);
	}
}

However if Control#update is called by one of the drop listeners then refresh() method does nothing. This means that the image under the cursor is not updated properly as OS.ImageList methods are never called.

I created a pure SWT test case that reproduces this issue.

Bug 218823 looks similar to this but I am not sure this is the same problem.

Bug 393514 in GEF is the one blocked by this issue.
Comment 1 Peter Severin CLA 2012-11-08 08:02:51 EST
Created attachment 223349 [details]
The screenshot that shows the redraw issue
Comment 2 Christian Kütbach CLA 2013-05-22 05:03:22 EDT
There is a workarround for this Bug, but I would prefer a solution. 

One possible workarround is to call

OS.ImageList_DragShowNolock(true);

in the dragOver(DropTargetEvent e). This will remove the image from the mousepointer. I had to use this workarround within a LotusNotes Client.
Comment 3 Eclipse Genie CLA 2020-04-13 08:09:10 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.