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

Bug 530204

Summary: [GTK] Menu appears at mouse regardless of setLocation()
Product: [Eclipse Project] Platform Reporter: Eric Williams <ericwill>
Component: SWTAssignee: Eric Williams <ericwill>
Status: VERIFIED FIXED QA Contact: Eric Williams <ericwill>
Severity: normal    
Priority: P3 CC: brotenet, loskutov
Version: 4.8   
Target Milestone: 4.8 M7   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=431423
https://bugzilla.gnome.org/show_bug.cgi?id=791845
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532074
https://git.eclipse.org/r/118813
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=9c6346c33b2ceab571983d3f58db7ceed75a22e8
https://git.eclipse.org/r/119826
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=47598b7e6318e7cfae9c33fcf18610194b1c4741
Whiteboard:
Attachments:
Description Flags
Snippet reproducing the issue none

Description Eric Williams CLA 2018-01-23 13:10:06 EST
Created attachment 272379 [details]
Snippet reproducing the issue

This seems to be a general implementation issue in GTK. Using Menu.setLocation() is ineffectual as the menu always pops up where the mouse pointer is. Furthermore, Menu.setLocation() doesn't do anything. It sets some variables in Menu but those variables aren't ever accessed after being set.

Attached is a snippet that reproduces the issue. Steps:
1) Launch the snippet, and click the "Open dialog" button.
2) A modal dialog will popup with a button in it. Click the button.
3) The menu pops up normally. Close it by hitting escape. Now the button has focus.
4) Move the mouse anywhere else on the screen and hit enter (to press the button). The menu will popup either at the pointer, or at incorrect coordinates all together.

This happens on GTK2 and GTK3, X11 and Wayland. I don't think there is much we can do about it on GTK2 but GTK3.22 has API for this case: gtk_menu_popup_at_rect().

There is also API to have a menu be attached to a widget: gtk_menu_popup_at_widget(). This might be useful when Control.setMenu() is invoked.
Comment 1 Andrey Loskutov CLA 2018-01-23 13:16:25 EST
Just wondering about bug 431423, where the menu does NOT appears where the mouse pointer was.
Comment 2 Eric Williams CLA 2018-01-23 13:34:15 EST
(In reply to Andrey Loskutov from comment #1)
> Just wondering about bug 431423, where the menu does NOT appears where the
> mouse pointer was.

Different issue: AFAICT in that case setLocation() isn't being called.
Comment 3 Eric Williams CLA 2018-01-25 17:11:27 EST
Adding an upstream GNOME bug as it might help the situation on Wayland.
Comment 4 Eclipse Genie CLA 2018-03-06 13:59:35 EST
New Gerrit change created: https://git.eclipse.org/r/118813
Comment 6 Eclipse Genie CLA 2018-03-20 17:17:05 EDT
New Gerrit change created: https://git.eclipse.org/r/119826
Comment 8 Eric Williams CLA 2018-03-22 12:03:43 EDT
(In reply to Eclipse Genie from comment #7)
> Gerrit change https://git.eclipse.org/r/119826 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=47598b7e6318e7cfae9c33fcf18610194b1c4741

Fix is in master now.
Comment 9 Eric Williams CLA 2018-05-08 10:20:25 EDT
Verified in I20180507-2205.
Comment 10 Eric Williams CLA 2018-05-17 16:07:26 EDT
*** Bug 534841 has been marked as a duplicate of this bug. ***