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

Bug 449942

Summary: Call to java.awt.MouseInfo.getPointerInfo() needs to be removed from FXHoverBehavior
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF MVCAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: matthias.wienand
Version: unspecified   
Target Milestone: 3.10.0 (Mars) M3   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Alexander Nyßen CLA 2014-11-04 08:55:54 EST
It seems FXHoverBehavior makes use of AWT functionality (which does at least not work in standalone FX application on MacOS). In any case, this functionality needs to be replaced with proper JavaFX mechanisms.
Comment 1 Alexander Nyßen CLA 2014-11-04 08:58:31 EST
Glass detected outstanding Java exception at -[GlassViewDelegate sendJavaMouseEvent:]:src/com/sun/mat/ui/GlassViewDelegate.m:543
Exception in thread "JavaFX Application Thread" java.awt.HeadlessException
	at java.awt.MouseInfo.getPointerInfo(MouseInfo.java:74)
	at org.eclipse.gef4.mvc.fx.behaviors.FXHoverBehavior.onHoverChange(FXHoverBehavior.java:159)
	at org.eclipse.gef4.mvc.behaviors.HoverBehavior.propertyChange(HoverBehavior.java:82)
	at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
	at org.eclipse.gef4.mvc.models.HoverModel.setHover(HoverModel.java:84)
	at org.eclipse.gef4.mvc.policies.HoverPolicy.hover(HoverPolicy.java:20)
	at org.eclipse.gef4.mvc.fx.policies.FXHoverOnHoverPolicy.hover(FXHoverOnHoverPolicy.java:30)
	at org.eclipse.gef4.mvc.fx.tools.FXHoverTool$1.handle(FXHoverTool.java:86)
	at org.eclipse.gef4.mvc.fx.tools.FXHoverTool$1.handle(FXHoverTool.java:1)
	at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:78)
	at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:202)
	at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:159)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:22)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:31)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
	at javafx.event.Event.fireEvent(Event.java:171)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3311)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3151)
	at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3106)
	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563)
	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2248)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
	at com.sun.glass.ui.View.handleMouseEvent(View.java:530)
	at com.sun.glass.ui.View.notifyMouse(View.java:924)
Comment 2 Alexander Nyßen CLA 2014-11-04 10:30:27 EST
Up to now, added a platform specific workaround for Mac:

// FIXME: platform specific workaround for Mac
String osName = System.getProperty("os.name").toLowerCase();
  if (osName.startsWith("mac os x")) {
    com.sun.glass.ui.Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
    initialPointerLocation = new Point(robot.getMouseX(),						robot.getMouseY());
} else {
  initialPointerLocation = java.awt.MouseInfo.getPointerInfo()						.getLocation();
}
Comment 3 Alexander Nyßen CLA 2014-11-04 10:42:15 EST
I further ensured the workaround is only used if the bundle is not activated (i.e. we run in standalone mode), because otherwise it does not work properly within eclipse.
Comment 4 Matthias Wienand CLA 2014-11-06 09:54:17 EST
I replaced the code to get the initial (current) mouse pointer location using AWT by using the first location reported by JavaFX when the mouse moves as the initial pointer location. The code is published on the master branch, therefore I resolve this ticket as fixed for target milestone 3.10.0M3, sorry for the inconvenience.