Bug 493477 - On GTK2, the Tracker constructor that accepts a Shell traps the cursor
Summary: On GTK2, the Tracker constructor that accepts a Shell traps the cursor
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P2 major (vote)
Target Milestone: 4.6 RC2   Edit
Assignee: Stefan Xenos CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 493478 (view as bug list)
Depends on:
Blocks: 406954 493478
  Show dependency tree
 
Reported: 2016-05-11 22:49 EDT by Stefan Xenos CLA
Modified: 2016-05-18 14:45 EDT (History)
9 users (show)

See Also:
sravankumarl: review+
arunkumar.thondapu: review+
eclipse.sprigogin: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2016-05-11 22:49:13 EDT
Reproduced using Snippet23, running on GTK2. Does not occur with GTK3.

Run the following snippet of code. Click the cursor within the resulting window and attempt to drag it off the window.

Observed:

The cursor gets stuck at the boundary of the window and cannot be dragged off the window. This is inconsistent with the behavior of SWT on other platforms including GTK3.

Expected:

The cursor moves off of the window.


public class Snippet23 {

public static void main (String [] args) {
	Display display = new Display ();
	final Shell shell = new Shell (display);
	shell.open ();
	shell.addListener (SWT.MouseDown, e -> {
		Tracker tracker = new Tracker (shell, SWT.NONE);
		tracker.setRectangles (new Rectangle [] {
			new Rectangle (e.x, e.y, 100, 100),
		});
		tracker.open ();
	});
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
}
Comment 1 Stefan Xenos CLA 2016-05-11 22:50:23 EDT
Unable to use the Display constructor as a workaround due to bug 492783.
Comment 2 Eclipse Genie CLA 2016-05-12 00:10:51 EDT
New Gerrit change created: https://git.eclipse.org/r/72590
Comment 3 Stefan Xenos CLA 2016-05-12 00:13:16 EDT
I've attached a rough idea for a fix here but I haven't tested it yet.
Comment 4 Stefan Xenos CLA 2016-05-12 15:28:34 EDT
Possibly related to bug 406954
Comment 5 Eclipse Genie CLA 2016-05-12 15:49:59 EDT
New Gerrit change created: https://git.eclipse.org/r/72659
Comment 6 Stefan Xenos CLA 2016-05-12 15:53:02 EDT
No need for workarounds. I've attached a proper fix.
Comment 7 Stefan Xenos CLA 2016-05-12 15:56:44 EDT
This should really go in for RC2.
Comment 8 Arun Thondapu CLA 2016-05-16 16:51:02 EDT
(In reply to Stefan Xenos from comment #0)
> Reproduced using Snippet23, running on GTK2. Does not occur with GTK3.
> 
> Run the following snippet of code. Click the cursor within the resulting
> window and attempt to drag it off the window.
> 
> Observed:
> 
> The cursor gets stuck at the boundary of the window and cannot be dragged
> off the window. This is inconsistent with the behavior of SWT on other
> platforms including GTK3.
> 
> Expected:
> 
> The cursor moves off of the window.

Stefan, which Linux version are you trying this on? Can you please attach a small video which demonstrates the exact behaviour you're seeing?

I tried the Snippet23 on Ubuntu 15.10 and did notice that the Tracker that is created on mouse down event is stuck at the window boundary, however, the cursor moves freely out of the window. Did you mean the Tracker when you say the cursor gets stuck at the boundary of the window?

Also, I tried the attached patch with the same snippet and it does seem to allow the Tracker to move off of the window. There is another difference in behaviour though between GTK2 and GTK3 after the patch - with GTK2 you can see that the Tracker is no longer trapped inside the window boundaries but it is not visible when dragged outside the window whereas with GTK3 the Tracker is always visible. Did you notice this too?

I'm not sure if that is a different bug with GTK3 as I verified on Windows 7 and found that it matches with the GTK2 behaviour (with your patch).
Comment 9 Arun Thondapu CLA 2016-05-16 16:54:50 EDT
The patch itself looks quite simple and not very risky but I would like to clarify the questions from comment 8 before we decide to go ahead and merge it...
Comment 10 Stefan Xenos CLA 2016-05-17 11:04:07 EDT
> Stefan, which Linux version are you trying this on?

4.2.0-35-generic #40~14.04.1-Ubuntu SMP Fri Mar 18 16:37:35 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

> Can you please attach a small video which demonstrates the exact
> behaviour you're seeing?

I'll need to install and figure out the use of some video capture software first. It may take some time. I'd suggest we don't gate this fix on that.

> Did you mean the Tracker when you say the cursor gets stuck at the
> boundary of the window?

Both. However, it's the cursor that creates problems for Drag & Drop in Eclipse since Eclipse intentionally uses an invisible Tracker. Actually, from my reading of the GTK documentation, this behavior of constraining the cursor seems to be intended behavior when you invoke that method with a non-null argument.

> Did you notice this too?

Yes. On GTK2 the Tracker isn't visible when dragged outside the parent shell, but that seems to be a separate bug from the problem with the cursor.
Comment 11 Arun Thondapu CLA 2016-05-18 08:18:31 EDT
(In reply to Stefan Xenos from comment #10)
> > Did you mean the Tracker when you say the cursor gets stuck at the
> > boundary of the window?
> 
> Both. However, it's the cursor that creates problems for Drag & Drop in
> Eclipse since Eclipse intentionally uses an invisible Tracker. Actually,
> from my reading of the GTK documentation, this behavior of constraining the
> cursor seems to be intended behavior when you invoke that method with a
> non-null argument.

I understand that but its contrary to the behaviour I observed which is why I wanted you to upload a video of what you're seeing. When I run the Snippet23 with GTK2, what I see is that the Tracker gets stuck inside the window but the cursor does not, I'm able to move the cursor anywhere on the screen.

In effect, I'm unable to reproduce the exact problem as reported by the title of the bug but I'm still in favour of merging this patch because:

a) It unblocks the Tracker (and the cursor in case it does get trapped) and helps resolve the DND bug 493478.

b) After applying the patch, the GTK2 behaviour matches with that of GTK3 as well as Windows.

c) And from the code perspective as well, this seems to be the clean and better thing to do than confine the pointer to the Tracker's originating window.


> > Did you notice this too?
> 
> Yes. On GTK2 the Tracker isn't visible when dragged outside the parent
> shell, but that seems to be a separate bug from the problem with the cursor.

Can you please raise a separate bug for this different behaviour with GTK3 so that it can be tracked and if necessary, be fixed at a later point of time? Thanks!
Comment 13 Stefan Xenos CLA 2016-05-18 11:29:59 EDT
Extracted bug 493916.
Comment 14 Dani Megert CLA 2016-05-18 14:45:43 EDT
*** Bug 493478 has been marked as a duplicate of this bug. ***