Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 392774 - [GTK3] Need to implement Table/TreeDraSourceEffect.getDragSourceImage
Summary: [GTK3] Need to implement Table/TreeDraSourceEffect.getDragSourceImage
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 4.3 M7   Edit
Assignee: Arun Thondapu CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2012-10-24 13:27 EDT by Silenio Quarti CLA
Modified: 2013-05-01 09:22 EDT (History)
2 users (show)

See Also:
arunkumar.thondapu: review? (Silenio_Quarti)


Attachments
Patch which uses gtk_drag_set_icon_surface() API for GTK 3 (17.06 KB, patch)
2013-04-30 14:27 EDT, Arun Thondapu CLA
no flags Details | Diff
patch (18.02 KB, patch)
2013-04-30 19:03 EDT, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Silenio Quarti CLA 2012-10-24 13:27:10 EDT
In GTK3, gtk_tree_view_create_row_drag_icon() returns a cairo_surface_t instead of GdkPixmap.

I have released a VERSION check for now so that I can make the GdkGC and GdkPixmap calls dynamic. Need to revisit this later.
Comment 2 Anatoly Spektor CLA 2013-04-19 11:31:37 EDT
(In reply to comment #1)
> Version check commit:
> 
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=3733629abcad894d9d98f45a1d23d1c79ff90dce

Here is that patch I would like to propose that fixes single line drag and drop (I am still working on multiple line solution) :

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=392774

I would appreciate your feedback.

When testing I have using the following widget:

http://pastebin.com/FTLGUsMT ( select table in right and left parts and try drag and dropping with GTK+ 2 and with GTK+ 3)
Comment 3 Anatoly Spektor CLA 2013-04-19 11:39:14 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > Version check commit:
> > 
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > ?id=3733629abcad894d9d98f45a1d23d1c79ff90dce
> 
> Here is that patch I would like to propose that fixes single line drag and
> drop (I am still working on multiple line solution) :
> 
> http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/
> commit/?h=392774
> 
> I would appreciate your feedback.
> 
> When testing I have using the following widget:
> 
> http://pastebin.com/FTLGUsMT ( select table in right and left parts and try
> drag and dropping with GTK+ 2 and with GTK+ 3)

I have found out there are still some JUnit tests failing with this implementation, I will take a closer look at it. Sorry for this inconvenience.
Comment 4 Anatoly Spektor CLA 2013-04-19 11:59:00 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Version check commit:
> > > 
> > > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > > ?id=3733629abcad894d9d98f45a1d23d1c79ff90dce
> > 
> > Here is that patch I would like to propose that fixes single line drag and
> > drop (I am still working on multiple line solution) :
> > 
> > http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/
> > commit/?h=392774
> > 
> > I would appreciate your feedback.
> > 
> > When testing I have using the following widget:
> > 
> > http://pastebin.com/FTLGUsMT ( select table in right and left parts and try
> > drag and dropping with GTK+ 2 and with GTK+ 3)
> 
> I have found out there are still some JUnit tests failing with this
> implementation, I will take a closer look at it. Sorry for this
> inconvenience.

Double checked, should be ok. Please try it and let me know. (link above)
Comment 5 Arun Thondapu CLA 2013-04-22 10:32:48 EDT
Thanks for the patch Anatoly! I have looked at the changes in the patch and also tried it out and it seems to work.

However, I want to propose a slightly different patch for this bug which uses the gtk_drag_set_icon_surface () API directly instead of creating a new Cairo XLib surface and then converting it into a pixbuf. I'm still working on the solution for the multiple item drag too and will upload my patch soon.
Comment 6 Anatoly Spektor CLA 2013-04-30 08:54:22 EDT
(In reply to comment #5)
> Thanks for the patch Anatoly! I have looked at the changes in the patch and
> also tried it out and it seems to work.
> 
> However, I want to propose a slightly different patch for this bug which
> uses the gtk_drag_set_icon_surface () API directly instead of creating a new
> Cairo XLib surface and then converting it into a pixbuf. I'm still working
> on the solution for the multiple item drag too and will upload my patch soon.

Arun can you please show me what you have now, so we don't do two different things,  thus maybe fasten the process.
Comment 7 Arun Thondapu CLA 2013-04-30 14:27:48 EDT
Created attachment 230317 [details]
Patch which uses gtk_drag_set_icon_surface() API for GTK 3

This is the almost final version of my patch for this bug. I have tested it mostly with DNDExample and it seems to work as expected. I verified that the behavior is the same as with GTK 2.

However, there is one minor glitch I still need to resolve and might need some help with. In the case of multiple items drag, the combined image surface has a very small black border along the bottom and the right sides of the image. I think this is because of the way I'm calculating the dimensions of the combined image but I'm not sure how to fix it. One possible way is to set the contents of the image surface upon creation to white/grey pixels instead of the default zero content.

SSQ, kindly review the patch and provide your feedback/suggestions. Thanks!
Comment 8 Silenio Quarti CLA 2013-04-30 19:03:12 EDT
Created attachment 230331 [details]
patch

Arun, please try this patch out. It is basically your patch with two modifications. 

1) the image format is always Cairo.CAIRO_FORMAT_ARGB32. This is necessary to make wholes transparent instead of black. Try dragging with item0 and item2 selected. 

2) I added +2 offset to the source surface to fix the black border problem you mentioned.  I do not understand why it has to be +2, but it seems to work.  It is probably related to the fact that the image height is two pixels bigger them the cell area height.

If you do not see any problems with the patch. Please go ahead and release it. This is definitely a improvement.
Comment 9 Arun Thondapu CLA 2013-05-01 09:22:59 EDT
(In reply to comment #8)
> If you do not see any problems with the patch. Please go ahead and release
> it. This is definitely a improvement.

Thanks a lot for the review and suggestions Silenio! I have incorporated these changes and pushed the patch to master - http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=aa3c6d8a75ecd3aa62e9b9ee7768d59f601718ad

I happened to push another commit (DateTime on top of GtkSpinButton from Anatoly which I haven't fully reviewed yet) by mistake along with this one and have also reverted it. Sorry for the inconvenience!

I'm marking this as fixed in M7 for now but I'm not sure which is the candidate I-build for M7 yet.