Community
Participate
Working Groups
Created attachment 119263 [details] Sample project to show the problem. This is a self-contained plug-in to reproduce a problem we have observed on our RCP application for SunOS 5.10, RHEL4, and RHEl5. This plug-in was tested on RHEL5 on gtk2-2.10.4-20.el5 (according to rpm -q gtk2). 1. Import the plug-in into your workspace. 2. Launch the second Eclipse. 3. Window > Show View > Other... > Sample Category > Sample View 4. Context menu on 'A', see item, separator, item. 5. Context menu on 'A2', see only one item. 6. Context menu on 'A', CommandOne. 7. The 'Navigator' view is shown and activated. 8. Keep the mouse in the 'Sample View' and bring up the context menu on 'A'. Take note that you should not Alt+Tab around to other applications. 9. Context menu on 'A', see only one item. The contributed handler through the plugin.xml is not present. 10. Try both left-clicking and right-clicking the different items in the table, 'A' always only shows one item. Notice that the view's tab item is not blue. The blue outline is actually still on the 'Navigator' view. 11. Select the view to activate it, granting it the blue outline. 12. Context menu on 'A', see item, separator, item once again. Naturally, if the 'Navigator' view is on the same view stack as the 'Sample View', you would be unable to reproduce this problem.
I forgot to note that our application is built on Eclipse 3.4.1 but I have reproduced the problem with the attached plug-in on I20081127-0900.
This is a regression from 3.3.2 and is broken on 3.4.0 and I20081127-0900. I have simpler steps below that doesn't require the use of my attached plug-in. 1. Open the 'Package Explorer' view. 2. Select a project. 3. Context menu > Show In > History. The 'History' view should appear in another view stack (assuming you didn't move it around). 4. Click on the project again in the 'Package Explorer'. 5. Use Alt+Enter to open the properties, nothing will happen. 6. Click and/or use the keyboard to move to different items. 7. Alt+Enter still fails. 8. Activate the view by clicking on its tab item. 9. Alt+Enter is working again. The plug-in's "missing menu item" is the problem on our product wherein we use the menu contributions to determine whether items are visible or not. As the view is not active, the items are deemed to not be visible...or something.
Punting over to SWT since I can reproduce a similar problem on SWT wherein we're not getting any activation events on a parent Composite, please reproduce the problem with the main method below. This is on I20081127-0900. 1. Run the SWT application. 2. Click on the table on the left hand side, "One activated" is printed. 3. Click on the tab folder on the right, then click on the table on the right. "Two activated" is printed. 4. Bring up the context menu on the table, then click on the "Focus One" menu item. 5. Nothing is printed. Use the keyboard to move up and down, confirm that the keyboard focus is indeed on the left table. 6. Click on the right table again, nothing is printed. Now if you perform the above on 3.3.2, you will get "One activated" printed on step 5 and "Two activated" printed on step 6. I believe this is the reason why the workbench parts are not being activated properly. public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout(SWT.HORIZONTAL)); final CTabFolder folderOne = new CTabFolder(shell, SWT.CLOSE | SWT.BORDER); folderOne.setSimple(false); CTabItem itemOne = new CTabItem(folderOne, SWT.CLOSE); itemOne.setText("One"); //$NON-NLS-1$ Composite compositeOne = new Composite(folderOne, SWT.NONE); compositeOne.setLayout(new FillLayout()); compositeOne.setData("a"); //$NON-NLS-1$ final Table tableOne = new Table(compositeOne, SWT.SINGLE); new TableItem(tableOne, SWT.LEAD).setText("A"); //$NON-NLS-1$ new TableItem(tableOne, SWT.LEAD).setText("A"); //$NON-NLS-1$ itemOne.setControl(compositeOne); final CTabFolder folderTwo = new CTabFolder(shell, SWT.CLOSE | SWT.BORDER); folderTwo.setSimple(false); CTabItem itemTwo = new CTabItem(folderTwo, SWT.CLOSE); itemTwo.setText("Two"); //$NON-NLS-1$ Composite compositeTwo = new Composite(folderTwo, SWT.NONE); compositeTwo.setLayout(new FillLayout()); compositeTwo.setData("b"); //$NON-NLS-1$ final Table tableTwo = new Table(compositeTwo, SWT.SINGLE); new TableItem(tableTwo, SWT.LEAD).setText("A"); //$NON-NLS-1$ new TableItem(tableTwo, SWT.LEAD).setText("A"); //$NON-NLS-1$ itemTwo.setControl(compositeTwo); compositeOne.addListener(SWT.Activate, new Listener() { public void handleEvent(Event event) { System.out.println("One activated"); //$NON-NLS-1$ } }); compositeTwo.addListener(SWT.Activate, new Listener() { public void handleEvent(Event event) { System.out.println("Two activated"); //$NON-NLS-1$ } }); Menu menuOne = new Menu(tableOne); MenuItem menuItemOne = new MenuItem(menuOne, SWT.PUSH); menuItemOne.setText("Focus Two"); //$NON-NLS-1$ menuItemOne.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { tableTwo.setFocus(); } }); tableOne.setMenu(menuOne); Menu menuTwo = new Menu(tableTwo); MenuItem menuItemTwo = new MenuItem(menuTwo, SWT.PUSH); menuItemTwo.setText("Focus One"); //$NON-NLS-1$ menuItemTwo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { tableOne.setFocus(); } }); tableTwo.setMenu(menuTwo); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
Praveen to investigate.
Created attachment 125396 [details] Patch During the focus event processing, when the (context) menu is invoked, it was incorrectly assumed as popup of combo box and thus, the focus is ignored. The code changes introduced in this patch will address this scenario.
Patch released to HEAD > 20090211
We took a second look at this code today as it seemed to be the cause of bug 267038. Praveen: the code that runs in the gtk_event_after() GDK_FOCUS_CHANGE section runs for *all* menus. The comments at the top of the section are a bit confusing in that it seems the code is only meant for combo boxes that have a menu as a drop down when in fact it is meant to run for all menus. The reason that code is there is to prevent a popup menu from sending focus in and focus out events. The code in the patch had the undesired side effect of sending out Focus events for a wide number of controls (including Table, List, Canvas - anything that didn't return gtk_menu_get_attach_widget()) which led to bad behavior. This could have been seen by running the ControlExample, selecting the popup menu option on any control and then enabling the FocusIn/FocusOut listeners. For future reference, we should be sure to always check the ControlExample when working in the events area as it is easy to fix one thing and break another. The real fix is to leave the code in gtk_event_after as is thereby setting the ignoreFocus field to true whenever a popup menu comes up. If the user then decides to call setFocus or forceFocus, we reset the ignoreFocus field to false, so that focus events can be delivered.
Sorry BG. I will make sure to run ControlExample and test everytime after adding code changes.
*** Bug 272448 has been marked as a duplicate of this bug. ***