Bug 453827 - [GTK3] DND does not work on Group composite
Summary: [GTK3] DND does not work on Group composite
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.4.2   Edit
Assignee: Leo Ufimtsev CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 428852
  Show dependency tree
 
Reported: 2014-12-01 17:12 EST by Leo Ufimtsev CLA
Modified: 2016-03-31 08:29 EDT (History)
3 users (show)

See Also:
arunkumar.thondapu: review+


Attachments
. (3.65 KB, text/plain)
2014-12-01 17:18 EST, Leo Ufimtsev CLA
no flags Details
. (3.70 KB, text/plain)
2014-12-01 17:20 EST, Leo Ufimtsev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Ufimtsev CLA 2014-12-01 17:12:56 EST
This blocks:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=428852

Gtk3-specific:

If you have widgets inside an SWT Group widget, then a DND 'drop/motion' event doesn't reach those child widgets. As a result DND (drop) doesn't work for widgets that are children of Group.
Instead, drop/motion events are swallowed by the group Widget itself.

I discovered that Group's child widgets are added as 'siblings' rather than 'children' to the gtkFrame. Thus events didn't make it all the way through to the children. 

i.e, When rendered, group's hierarchy looks as following: 
 SwtFixed  (fixedHandle)
 +-- GtkFrame (handle) 
 |   +-- SwtFixed (clientHandle)
 +-- Child1   
 +-- Child2
And then input_shape_region captures events for the clientHandle.
(Observe, children are added to 'fixedHandle' as siblings to GtkFrame instead of being GtkFrame's children). 


I'm working on a fix to have children nested under the client handle:
 SwtFixed  (fixeldHandle)
 +-- GtkFrame (handle) 
     +--SwtFixed (clientHandle)
        +-- Child1   
        +- -Child2
& remove the input_shape_region code.
(I will post link to gerrit review in a minute). 

This fixes DND for Group. 

However, it breaks the positioning of children if the Group's label is set to something. I.e, children are added ~10pix or so lower than expected and you 
get funky behavior upon window-resizing**1. It appears to be an issue in some compute* function somewhere.

There are also a lot of sibling_link errors in console when you fire up ControlExample.


I will post further comments in a bit:

**1 child controls keep expanding, never getting smaller upon resize.
Comment 1 Leo Ufimtsev CLA 2014-12-01 17:18:43 EST
Created attachment 249079 [details]
.

Preview of patch to fix group-hierarchy issue:
https://git.eclipse.org/r/#/c/37430/

With both fixes applied: 

- The attached test illustrates that if a group doesn't have a label, positioning is ok.
- If it has a label, or if one is set later, positioning is messed up.
Comment 2 Leo Ufimtsev CLA 2014-12-01 17:20:25 EST
Created attachment 249080 [details]
.

Attached is a simple test to illustrate that DND works for controls inside a group. 
In fact, with the patch applied, DNDExample's DND works, (but child widget's position is broken).
Comment 3 Leo Ufimtsev CLA 2014-12-01 17:22:16 EST
While I'm still working on the patch, please let me know your thoughts about fixing/changing how group gets it's children. 

Also, let me know if you have tips on how to fix the child-position issue.
Comment 4 Leo Ufimtsev CLA 2014-12-01 17:23:24 EST
(sorry about attachements description typo).
Comment 5 Leo Ufimtsev CLA 2014-12-04 18:45:06 EST
The child positioning is broken because clientHandle's x/y position are altered by native gtk calls:
- gtk_widget_size_allocate  and
- gtk_widget_set_allocation.
(e.g when called from shell).  

Previously it didn't matter that clientHandle  had broken x/y coordinates because children were nested under fixedHandle and not clientHandle, but now with children being added under clientHandle, the broken x/y coords affects us.

At the moment we can't get away from using *_allocate calls, so I overrode the getClientArea function to fix the x/y position. This puts children into the right position. 

However, there are still warnings in the console that I have to work on.
Comment 6 Leo Ufimtsev CLA 2014-12-11 14:18:11 EST
Ok, the fix for group is complete. 
Now DND works for widgets inside a group. 
(This also fixes an absolute position bug in group that caused absolute widgets to be drawn on top of the label instead of inside the frame).


Could somebody please 
 - test
 - let me know feedback
 - merge if all ok:
https://git.eclipse.org/r/#/c/37430/


With this patch, DNDExample.java works fully and DND for widgets inside group work well. 

In addition, I also tested everything that touched 'clientHandle' afaik:
 - Layouts (row/grid/fill/Form/Absolute)
 - Drag and Drop 
 - Drag and Drop between groups 
 - Drag and Drop in nested groups 
 - Group with various mouse events (tooltip/clicking/motion)
 - Group with Background 

fyi, these were my personal tests for the widget:
https://github.com/LeoUfimtsev/swtTesting/blob/master/src/junit/tests/GroupManualUITest.java
Comment 7 Leo Ufimtsev CLA 2014-12-15 16:58:02 EST
With the fixed hierarchy, manual fixes like this:
if (OS.GTK3) {
    OS.gtk_widget_override_background_color (clientHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA ());
}
Are no longer needed. -> Removing.  (tested background works still on gtk2/3).
Comment 8 Arun Thondapu CLA 2014-12-19 09:12:05 EST
Pushed the patch to master - http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=846f013efc3b1566f8c1a545a6c06380f66b2d0c

Thanks Leo! Good to see DNDExample working now on all GTK+ versions :)
Comment 9 Arun Thondapu CLA 2014-12-19 09:13:04 EST
We should probably port this and other DND fixes to 4.4.2 as well...
Comment 10 Sravan Kumar Lakkimsetti CLA 2015-01-28 07:11:47 EST
Verified in build I20150127-0900 on Ubuntu 14.04 GTK3 X86_64