Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 526083

Summary: [GTK3] Menu.getBounds() returns wrong x & y coordinate
Product: [Eclipse Project] Platform Reporter: Michael Seele <mseele>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, loskutov
Version: 4.7.1aKeywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=431423
https://git.eclipse.org/r/110226
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=e399c9b546c0ab82a8a635dabb3449cc0d38afdc
https://git.eclipse.org/r/110253
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=d850566f615e2e8ceaf4c0ad1c77b40e77ccad55
Whiteboard:
Attachments:
Description Flags
Snippet to reproduce the bug
none
screenshot of the executed snippet (shows the problem)
none
Correct snippet to reproduce the bug none

Description Michael Seele CLA 2017-10-16 09:38:34 EDT
Created attachment 271017 [details]
Snippet to reproduce the bug

Method org.eclipse.swt.widgets.Menu.getBounds() returns wrong x & y coordinates. The implementation adds allocation.x & allocation.y, which is wrong.
Please see my attached snippet (you have to run it and do a right-click to open the popup menu).
If you run the snippet with GTK2, it works. Because allocation.x & allocation.y are 0. Under GTK3, allocation.x & allocation.y have positive values and therefore the x and y coordinates of menu are wrong.

We've tested and reproduced this under Ubuntu 16.04 (gtk3.18.9) and CentOS 7 (gtk3.22.10).
Comment 1 Michael Seele CLA 2017-10-16 09:46:50 EDT
Created attachment 271018 [details]
screenshot of the executed snippet (shows the problem)
Comment 2 Andrey Loskutov CLA 2017-10-16 09:52:53 EDT
Related to the bug 431423?
Comment 3 Eric Williams CLA 2017-10-16 10:20:02 EDT
I'm a bit unsure as to how this snippet works. Here is the output I got:

getBounds: Rectangle {216, 319, 102, 32}
-----------------------------------------
210 314 6 5 102 32
allocation: 6 5 102 32
bounds: Rectangle {216, 319, 102, 32}
-----------------------------------------
correct bounds: Rectangle {216, 319, 102, 32}

As you can see, the allocation is being added to the bounds, but the "correct bounds" line prints the same bounds as the previous line. This is contrary to what is posted in your screenshot. AFAICT this is still demonstrating the bug, right?

The menu is still appearing at the pointer. BUT, this might help us debug bug 431423.
Comment 4 Michael Seele CLA 2017-10-16 10:42:28 EDT
Created attachment 271019 [details]
Correct snippet to reproduce the bug

I'm sorry, here is the correct snippet (calculation in line 59 & 60 was wrong).
Comment 5 Eric Williams CLA 2017-10-17 10:23:39 EDT
(In reply to Michael Seele from comment #4)
> Created attachment 271019 [details]
> Correct snippet to reproduce the bug
> 
> I'm sorry, here is the correct snippet (calculation in line 59 & 60 was
> wrong).

Okay, I can reproduce the issue.
Comment 6 Eclipse Genie CLA 2017-10-17 10:26:19 EDT
New Gerrit change created: https://git.eclipse.org/r/110226
Comment 8 Eric Williams CLA 2017-10-17 11:46:08 EDT
(In reply to Eclipse Genie from comment #7)
> Gerrit change https://git.eclipse.org/r/110226 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=e399c9b546c0ab82a8a635dabb3449cc0d38afdc

Merged the snippet to reproduce the issue into the platform specific tests repo.
Comment 9 Eclipse Genie CLA 2017-10-17 15:55:51 EDT
New Gerrit change created: https://git.eclipse.org/r/110253
Comment 11 Eric Williams CLA 2018-02-15 15:35:48 EST
(In reply to Michael Seele from comment #0)
> The implementation adds allocation.x & allocation.y, which is
> wrong.

What makes you say that? I ask because AFAICT the addition of allocation.x and allocation.y has been around for awhile even in GTK2 days.

This is pretty much the crux of the issue, if there is no good reason to be adding it we can probably just remove it.
Comment 12 Michael Seele CLA 2018-02-19 04:36:33 EST
(In reply to Eric Williams from comment #11)
> (In reply to Michael Seele from comment #0)
> > The implementation adds allocation.x & allocation.y, which is
> > wrong.
> 
> What makes you say that? I ask because AFAICT the addition of allocation.x
> and allocation.y has been around for awhile even in GTK2 days.
> 
> This is pretty much the crux of the issue, if there is no good reason to be
> adding it we can probably just remove it.

I just say that the values between GTK2 and GTK3 differs (so for me, allocation.x & allocation.y in GTK3 is "wrong" comparing to the GTK2 implementation).

What we need is a fix, that SWT returns the correct and same coordinates in GTK2 AND GTK3. I'm not into gtk development, so i cannot say which implementation is correct.
Comment 13 Eric Williams CLA 2019-02-21 15:02:48 EST
So GTK2 support has been dropped, does that mean we should close this ticket? There is no more inconsistency since technically there is nothing to compare it to.

Thoughts?
Comment 14 Michael Seele CLA 2019-03-11 02:48:43 EDT
(In reply to Eric Williams from comment #13)
> So GTK2 support has been dropped, does that mean we should close this
> ticket? There is no more inconsistency since technically there is nothing to
> compare it to.
> 
> Thoughts?

ok for me
Comment 15 Eric Williams CLA 2019-03-11 09:47:08 EDT
(In reply to Michael Seele from comment #14)
> (In reply to Eric Williams from comment #13)
> > So GTK2 support has been dropped, does that mean we should close this
> > ticket? There is no more inconsistency since technically there is nothing to
> > compare it to.
> > 
> > Thoughts?
> 
> ok for me

Thanks for the feedback, marking this one as closed.