Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 503431 - [wayland] Mouse button release event not triggering from gdk_event_get() causing DND timeout
Summary: [wayland] Mouse button release event not triggering from gdk_event_get() caus...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.7 M7   Edit
Assignee: Ian Pun CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 513829 (view as bug list)
Depends on: 514419
Blocks: 513938 514531 swtWaylandImproveDnD
  Show dependency tree
 
Reported: 2016-10-04 11:45 EDT by Ian Pun CLA
Modified: 2017-04-20 14:01 EDT (History)
12 users (show)

See Also:


Attachments
Patch to get tree multiselection Dnd (not working currently) (39.31 KB, patch)
2016-12-19 14:26 EST, Ian Pun CLA
no flags Details | Diff
Patch to get tree multiselection Dnd (not working currently) (40.04 KB, patch)
2016-12-19 14:43 EST, Ian Pun CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Pun CLA 2016-10-04 11:45:42 EDT
Run snippet 82 in eclipse.swt.snippets. Try switching around tabs; you will notice that there is a noticeable delay in between the switch.
Comment 1 Ian Pun CLA 2016-10-05 17:42:11 EDT
Additional findings: switching between a hidden tab (selected through the chevron list) does not cause any sort of delay at all. There must be something that selection through the chevron list is not doing that selecting directly through the tab is.
Comment 2 Eclipse Genie CLA 2016-10-20 17:16:32 EDT
New Gerrit change created: https://git.eclipse.org/r/83639
Comment 3 Leo Ufimtsev CLA 2016-11-02 10:06:01 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/83639

This bug was discussed on the SWT call. Feedback:

1) We should take extra care with using context_iteration. It can change the order of events and potentially lead to crashes/NPEs. Ex:
https://git.eclipse.org/r/#/c/83904/

Can you verify that event ordering has not changed?
Ex, 
- In ControlExample, you can add mouse listeners. Ensure that things like double-click, defaultSelection, Mouse-up, motion events occur in the same order as before.

Is there a way we can get this to work without using context_iteration btw? If we check mouse state, do we still need context iteration?


For both X11 and Wayland:
2) Does Double click + Drag still work?

3) Does DnD still work in CStyled text? I.e, can you drag bits of code around?

4) Does tripple click work in Styled text? (select whole line?)

5) The comment in the bug didn't get updated in patch set 2?
Comment 4 Dani Megert CLA 2016-11-02 12:15:59 EDT
(In reply to Leo Ufimtsev from comment #3)

One also needs to test the DnD in the editors not just StyledText.
Comment 5 Ian Pun CLA 2016-11-03 16:18:50 EDT
(In reply to Leo Ufimtsev from comment #3)
> (In reply to Eclipse Genie from comment #2)
> > New Gerrit change created: https://git.eclipse.org/r/83639
> 
> This bug was discussed on the SWT call. Feedback:
> 
> 1) We should take extra care with using context_iteration. It can change the
> order of events and potentially lead to crashes/NPEs. Ex:
> https://git.eclipse.org/r/#/c/83904/
> 
> Can you verify that event ordering has not changed?
> Ex, 
> - In ControlExample, you can add mouse listeners. Ensure that things like
> double-click, defaultSelection, Mouse-up, motion events occur in the same
> order as before.
> 
> Is there a way we can get this to work without using context_iteration btw?
> If we check mouse state, do we still need context iteration?
> 
> 
> For both X11 and Wayland:
> 2) Does Double click + Drag still work?
> 
> 3) Does DnD still work in CStyled text? I.e, can you drag bits of code
> around?
> 
> 4) Does tripple click work in Styled text? (select whole line?)
> 
> 5) The comment in the bug didn't get updated in patch set 2?

Everything has been tested and been working with the patch that I have made, thankfully. The patch is working as intended.
Comment 7 Leo Ufimtsev CLA 2016-11-08 15:23:43 EST
Also tested on Gtk2/Gtk3. jUnit tests and DnDExample as well as child Eclipse seem to function well.

Thank you for fix.

If no major issues are reported, we should probably backport in a few weeks time.
Comment 8 Eclipse Genie CLA 2016-11-10 11:54:48 EST
New Gerrit change created: https://git.eclipse.org/r/84825
Comment 9 Leo Ufimtsev CLA 2016-11-10 11:55:16 EST
Reverted patch for now due to report of DnD issue from Alex
Comment 10 Eclipse Genie CLA 2016-11-10 12:17:02 EST
New Gerrit change created: https://git.eclipse.org/r/84826
Comment 11 Ian Pun CLA 2016-11-10 12:34:46 EST
I've added a small patch that adds the additional gdk_threads_leave() call which seems to be used before every g_main_context_iteration() call. Tests seem to run fine on my machine, but I will leave it to Alex to see if it fixes his issue.
Comment 13 Sravan Kumar Lakkimsetti CLA 2016-11-25 04:32:55 EST
Please retarget to M4 if there is a chance to complete in M4 time frame
Comment 14 Alexander Kurtakov CLA 2016-12-02 01:55:07 EST
Retarget for M5 as there is patch for review in M4.
Comment 15 Eclipse Genie CLA 2016-12-09 12:49:22 EST
New Gerrit change created: https://git.eclipse.org/r/86861
Comment 17 Alexander Kurtakov CLA 2016-12-14 05:09:16 EST
Ian, this broke Table/Tree MULTI selection DnD cause the mouse click on drag start is processed and selects single element only. Please let me know whether we should revert or you can come up with a patch for that fast.
Comment 18 Alexander Kurtakov CLA 2016-12-14 06:21:03 EST
So multi selection DnD is broken on both X11 and wayland. If you test on wayland though you must work with http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=d0fe4cf655fd77c7ae6184a4713c38c4ee88f04f or later commit as wayland uses cairo image surface not xlib.
Comment 19 Ian Pun CLA 2016-12-14 09:35:55 EST
(In reply to Alexander Kurtakov from comment #17)
> Ian, this broke Table/Tree MULTI selection DnD cause the mouse click on drag
> start is processed and selects single element only. Please let me know
> whether we should revert or you can come up with a patch for that fast.

Ill get to it now, Ill see if i can fix it ASAP without the need to revert
Comment 20 Eclipse Genie CLA 2016-12-14 11:10:31 EST
New Gerrit change created: https://git.eclipse.org/r/87142
Comment 22 Ian Pun CLA 2016-12-19 14:26:23 EST
Created attachment 265954 [details]
Patch to get tree multiselection Dnd (not working currently)
Comment 23 Ian Pun CLA 2016-12-19 14:29:14 EST
Alex, I have attached a patch that should give an outline to what I am trying to do. Currently, there is an issue with the compiler not seeing the selectionProc() method inside Display, even though I have put one there explicitly. The use of gtk_tree_selection_set_select_function() would be to set a function that just returns false, as we need it to decline any selections. Once we are on release event, it will check to see if it is in a condition to clear the other selections or not. 

THe logic seems sound, but the main thing is the implementation of GtkTreeSelectionFunc as one of the parameters. 

This is all seen within the release_event() and click_event() of Tree for a Proof of Concept.
Comment 24 Ian Pun CLA 2016-12-19 14:43:20 EST
Comment on attachment 265954 [details]
Patch to get tree multiselection Dnd (not working currently)

forgot to push the widget changes that make this semi-work
Comment 25 Ian Pun CLA 2016-12-19 14:43:47 EST
Created attachment 265955 [details]
Patch to get tree multiselection Dnd (not working currently)
Comment 26 Eclipse Genie CLA 2016-12-19 15:47:34 EST
New Gerrit change created: https://git.eclipse.org/r/87440
Comment 27 Eclipse Genie CLA 2016-12-23 16:41:27 EST
New Gerrit change created: https://git.eclipse.org/r/87713
Comment 28 Eclipse Genie CLA 2017-01-03 16:03:04 EST
New Gerrit change created: https://git.eclipse.org/r/87967
Comment 30 Leo Ufimtsev CLA 2017-01-04 14:40:46 EST
(In reply to Eclipse Genie from comment #28)
> New Gerrit change created: https://git.eclipse.org/r/87967

> Gerrit change https://git.eclipse.org/r/87967 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=a6ef223e37fdd4a902c9d9880134483238275ef7

Accidentally linked to wrong bug. This was is related to another bug:
Bug 505591 - Add test cases for Browser.evaluate() to browser test suite. (In reply to Eclipse Genie from comment #29)
Comment 31 Eclipse Genie CLA 2017-01-13 10:47:23 EST
New Gerrit change created: https://git.eclipse.org/r/88650
Comment 32 Lakshmi P Shanmugam CLA 2017-03-08 07:17:06 EST
Moving to M7 as we are in M6 milestone week.
Comment 34 Leo Ufimtsev CLA 2017-03-16 11:07:12 EDT
The recent patch is generating a build warning:
860641a84d915424de3c6c214008ed5fc87c3a6f
https://git.eclipse.org/r/#/c/88650/

The warning is printed in Gtk2 and Gtk3:
> os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS__1gtk_1tree_1selection_1set_1select_1function’:
> os.c:14786:67: warning: passing argument 2 of ‘gtk_tree_selection_set_select_function’ from incompatible pointer type [-Wincompatible-pointer-types]
>  gtk_tree_selection_set_select_function((GtkTreeSelection *)arg0, (GtkTreeSelectionFunc *)arg1, (gpointer)arg2, (GDestroyNotify)arg3);
>                                                                   ^
> In file included from /usr/include/gtk-2.0/gtk/gtk.h:201:0,
>                  from os.h:30,
>                 from os_structs.h:19,
>                  from os.c:20:
> /usr/include/gtk-2.0/gtk/gtktreeselection.h:81:18: note: expected ‘GtkTreeSelectionFunc {aka int (*)(struct _GtkTreeSelection *, struct _GtkTreeModel *, struct _GtkTreePath *, int,  void *)}’ but > argument is of type ‘gboolean (**)(GtkTreeSelection *, GtkTreeModel *, GtkTreePath *, gboolean,  void *) {aka int (**)(struct _GtkTreeSelection *, struct _GtkTreeModel *, struct _GtkTreePath *, 
> int,  void *)}’
> void             gtk_tree_selection_set_select_function (GtkTreeSelection            *selection,
>                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The reason is that in OS.java:gtk_tree_selection_set_select_function
The cast is wrong:
 * @param func cast=(GtkTreeSelectionFunc *)   should be:  * @param func cast=(GtkTreeSelectionFunc)     # (no * at the end)

As per gtk_tree_selection_set_select_function documentation.

This removes the build warning.

@Ian, can you test everything still works with the fixed cast and submit a relevant patch?

Thank you.
Comment 35 Markus Keller CLA 2017-03-20 13:49:20 EDT
This caused may test failures due to "SWTError: No more callbacks", see bug 513938.
Comment 36 Leo Ufimtsev CLA 2017-03-20 14:18:09 EDT
(In reply to Markus Keller from comment #35)
> This caused may test failures due to "SWTError: No more callbacks", see bug
> 513938.

Thank you for pointing this out. I've got a fix lined up for this, will submit today/tomorrow latest.
Comment 37 Eclipse Genie CLA 2017-03-20 18:15:46 EDT
New Gerrit change created: https://git.eclipse.org/r/93465
Comment 39 Eclipse Genie CLA 2017-03-21 15:04:25 EDT
New Gerrit change created: https://git.eclipse.org/r/93568
Comment 41 Leo Ufimtsev CLA 2017-03-21 15:15:07 EDT
All known memory leaks fixed.
Comment 42 Ian Pun CLA 2017-03-24 12:59:35 EDT
*** Bug 513829 has been marked as a duplicate of this bug. ***
Comment 43 Eclipse Genie CLA 2017-03-29 10:35:25 EDT
New Gerrit change created: https://git.eclipse.org/r/94069
Comment 44 Leo Ufimtsev CLA 2017-03-29 10:37:08 EDT
(In reply to Eclipse Genie from comment #43)
> New Gerrit change created: https://git.eclipse.org/r/94069

There seems to be some delays/trouble with gerrit atm. Will followup/review tomorrow.
Comment 46 Ian Pun CLA 2017-03-30 09:32:26 EDT
closing as patch has been merged to master, removing the warnings from comment 34
Comment 47 Leo Ufimtsev CLA 2017-03-31 11:12:12 EDT
This guy:
https://git.eclipse.org/r/#/c/88650/

Caused a regression:
Bug 514531 – [GTK3][regression] Launch config is not opened after creation 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=514531
Comment 48 Leo Ufimtsev CLA 2017-04-20 14:01:58 EDT
!x11 guards added to code and known regressions addressed on wayland. Closing for now.