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

Bug 362582

Summary: Focus is lost after switching perspectives on OS X 10.6.8
Product: [Eclipse Project] Platform Reporter: DJ Houghton <dj.houghton>
Component: UIAssignee: Remy Suen <remy.suen>
Status: RESOLVED FIXED QA Contact: Eric Moffatt <emoffatt>
Severity: major    
Priority: P3 CC: pwebster, remy.suen
Version: 4.2   
Target Milestone: 4.2 M4   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description DJ Houghton CLA 2011-11-01 13:56:38 EDT
OSX 10.6.8
Eclipse SDK 4.2.0.I20111028-1100

- open Java Perspective
- give focus to a view (e.g. Error Log view)
- switch to Debug view
- give Variables view focus
- command-shift-R to Open Type dialog
- cancel it
- switch to the Java perspective

Now when I try and do a command-shift-R to Open Resource, nothing happens.

If I give focus to the editor, then the key binding works ok.

Also works ok if I switch to another app and then back to Eclipse.
Comment 1 DJ Houghton CLA 2011-11-01 14:04:46 EDT
Remy actually just noticed that if you have focus in the editor in the Java perspective then switch to Debug, and then back to Java, non of the key bindings work. (including up/down arrow, etc)
Comment 2 Remy Suen CLA 2011-11-01 14:14:50 EDT
It seems our display filter for SWT.KeyDown stops receiving events for whatever reasons.
Comment 3 Remy Suen CLA 2011-11-01 14:57:53 EDT
When changing perspectives, two calls to the @Focus method seems to occur. Not sure why this is happening yet.
Comment 4 Paul Webster CLA 2011-11-01 14:59:45 EDT
(In reply to comment #3)
> When changing perspectives, two calls to the @Focus method seems to occur. Not
> sure why this is happening yet.

we don't have the why yet, but bug 362563

PW
Comment 5 Remy Suen CLA 2011-11-01 15:05:23 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > When changing perspectives, two calls to the @Focus method seems to occur. Not
> > sure why this is happening yet.
> 
> we don't have the why yet, but bug 362563

Believe that to be a different problem. Certainly the second call seems to be from PerspectiveStackRenderer's showTab(*) method.
Comment 6 Remy Suen CLA 2011-11-02 10:29:49 EDT
Here are the two traces.

java.lang.Throwable
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:157)
	at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:228)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:234)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:205)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:101)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:564)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.switchPerspective(PartServiceImpl.java:506)
	at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:114)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:66)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4614)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:184)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:81)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:55)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:135)
	at org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:1)
	at org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher$11.widgetSelected(PerspectiveSwitcher.java:409)

java.lang.Throwable
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:157)
	at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:228)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:234)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:205)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:101)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$2.setFocus(ContributedPartRenderer.java:101)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1030)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1030)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1030)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1030)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1030)
	at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1342)
	at org.eclipse.swt.widgets.Control.setVisible(Control.java:4192)
	at org.eclipse.swt.custom.StackLayout.layout(StackLayout.java:121)
	at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1194)
	at org.eclipse.swt.widgets.Composite.layout(Composite.java:703)
	at org.eclipse.swt.widgets.Composite.layout(Composite.java:661)
	at org.eclipse.swt.widgets.Composite.layout(Composite.java:624)
	at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:120)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:66)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4614)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:184)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:81)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:55)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:135)
	at org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:1)
	at org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher$11.widgetSelected(PerspectiveSwitcher.java:409)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4129)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1270)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3975)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3614)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:972)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:888)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:90)
Comment 7 Remy Suen CLA 2011-11-02 10:34:45 EDT
I'm also seeing cases where only one @Focus is called.
Comment 8 Remy Suen CLA 2011-11-02 10:49:28 EDT
When @Focus is called on the 'Navigator' in the perspective that is being switched to, SWT's setFocus() is returning false because isVisible() returns false.
Comment 9 Remy Suen CLA 2011-11-02 12:03:25 EDT
Fix pushed to master. Thanks for the bug report, DJ!
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=38a9f4e85e44bdcd4cd788359d05be8b28f28514