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

Bug 233450

Summary: Context Menu doesn't show on Linux with menu.setVisible( true )
Product: [Eclipse Project] Platform Reporter: kevin miles <kj_miles>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, gheorghe, gordon.hirsch, semenia
Version: 3.3Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
TestCase RCP and View named 'NICE' with embedded Swing Table none

Description kevin miles CLA 2008-05-22 10:03:46 EDT
Build ID: I20070625-1500

Steps To Reproduce:
1. Receive event where you want to show context menu
2. call menu.setVisible( true ) 
3. menu never shows.


More information:
I have a swing tree where i listen for swing mouse events and then in the display thread show my eclipse context menu.
This works fine on windoze.

I'm using KDE 3.2.1 on SUSE LINUX Enterprise Server 9 (x86_64) 

I found a discussion with the same problem at http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg33991.html
Comment 1 Bogdan Gheorghe CLA 2008-05-26 14:13:52 EDT
Will check...
Comment 2 Bogdan Gheorghe CLA 2008-05-26 15:42:36 EDT
This works for me using the latest 3.4 RC2 build. Please reopen with a snippet of code if you are still having problems. Thanks!
Comment 3 kevin miles CLA 2008-06-02 11:30:38 EDT
Created attachment 103144 [details]
TestCase RCP and View named 'NICE' with embedded Swing Table
Comment 4 kevin miles CLA 2008-06-02 11:31:36 EDT
(In reply to comment #2)
> This works for me using the latest 3.4 RC2 build. Please reopen with a snippet
> of code if you are still having problems. Thanks!
> 

I'm not using Eclipse 3.4... we're using 3.3.0
I am adding a simple rcp plugin and another plugin that contributes a view that has a swing table embedded. This all works on xp but not on the linux mentioned above.
Comment 5 Bogdan Gheorghe CLA 2008-06-02 15:51:51 EDT
FYI, The 3.3.x stream is now dormant. Any fix would have to go into a 3.4.x release.

SSQ, if you import the attached projects as existing projects into your workspace (note you need a 1.5 JRE) and run Eclipse, you will find a view called "Nice!" which contains a JTable. Right click on a row, and you will see that there is no popup menu shown. Note I was able to reproduce this in 3.4 RC3.
Comment 6 Andrew Semeniuk CLA 2008-07-29 19:01:42 EDT
I have the same problem and I tried using the 3.4 release (swt-3.4-gtk-linux-x86.zip) but it doesn't fix the problem -- setting visible an swt menu does not show it.  I found a strange quirk however: if I bring that window out of focus, then right-click inside that window when it's out of focus, the menu will show.

My code scenario is as follows: I have an awt Canvas embedded inside an swt Composite (SWT_AWT.new_Frame(myComposite).add(myCanvas)), and I add an awt mouse listener to the canvas.  When a right-click is received in that listener it tries to open the menu.  It works on Windows XP fine but not on Linux.  Here's the code:

   public Menu(final Composite composite,
         final Canvas canvas) {
      menu = new org.eclipse.swt.widgets.Menu(composite);

      composite.setMenu(menu);

      canvas.addMouseListener(new MouseListener() {

         public void mouseClicked(
               final MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
               try {
                  composite.getDisplay().syncExec(new Runnable() {
                     public void run() {
                        mousePoint.x = e.getX();
                        mousePoint.y = e.getY();
                        Point p2 = composite.getDisplay().map(composite,
                                                              null,
                                                              mousePoint);
                        menu.setLocation(p2);
                        System.out.println("menu: set-location="+p2.x+','+p2.y);
                        composite.getShell().setFocus();
                        menu.setVisible(true);
                        System.out.println("menu: visible="+menu.isVisible());
                     }
                  });
               } catch (Exception x) {
                  Utility.log(x);
               }
            }
...
Comment 7 Gordon Hirsch CLA 2008-07-30 11:35:42 EDT
This is an issue that we encountered and worked around in the Albireo project (http://www.eclipse.org/albireo). You may want to consider downloading and using the current alpha release to see if it solves the problem (and perhaps others) for you. Otherwise, perhaps you could take a look at some of the code to see how the problem was worked around. 

In my experience, SWT popup display needs to be delayed on Gtk until the mouse is released. See this post for more information:

http://dev.eclipse.org/mhonarc/lists/albireo-dev/msg00156.html
Comment 8 Eric Williams CLA 2018-04-09 14:42:04 EDT
Is this bug still reproducible on a 4.8 I-build?
Comment 9 Eric Williams CLA 2018-04-18 16:29:29 EDT
No response in a long time. Please file a new bug against 4.8 if you experience this issue in M6 on GTK3.22.