--- old/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java 2013-09-12 15:59:47.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java 2013-09-12 15:59:46.000000000 +0400 @@ -34,6 +34,8 @@ import sun.awt.CausedFocusEvent; import sun.awt.LightweightFrame; +import sun.swing.JLightweightFrame; +import sun.swing.SwingAccessor; public class LWLightweightFramePeer extends LWWindowPeer { @@ -91,11 +93,6 @@ } @Override - public void updateCursorImmediately() { - // TODO: tries to switch to the awt/fx toolkit thread and causes a deadlock on macosx - } - - @Override public void addDropTarget(DropTarget dt) { } @@ -112,4 +109,9 @@ public void ungrab() { getLwTarget().ungrabFocus(); } + + @Override + public void updateCursorImmediately() { + SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget()); + } } --- old/src/share/classes/sun/swing/JLightweightFrame.java 2013-09-12 15:59:48.000000000 +0400 +++ new/src/share/classes/sun/swing/JLightweightFrame.java 2013-09-12 15:59:47.000000000 +0400 @@ -33,8 +33,9 @@ import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.MouseInfo; +import java.awt.Point; import java.awt.Rectangle; -import java.awt.event.ComponentListener; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.image.BufferedImage; @@ -48,6 +49,7 @@ import javax.swing.JRootPane; import javax.swing.LayoutFocusTraversalPolicy; import javax.swing.RootPaneContainer; +import javax.swing.SwingUtilities; import sun.awt.LightweightFrame; import sun.security.action.GetPropertyAction; @@ -88,6 +90,15 @@ private PropertyChangeListener layoutSizeListener; + static { + SwingAccessor.setJLightweightFrameAccessor(new SwingAccessor.JLightweightFrameAccessor() { + @Override + public void updateCursor(JLightweightFrame frame) { + frame.updateClientCursor(); + } + }); + } + /** * Constructs a new, initially invisible {@code JLightweightFrame} * instance. @@ -358,4 +369,21 @@ public Component getGlassPane() { return getRootPane().getGlassPane(); } + + + /* + * Notifies client toolkit that it should change a cursor. + * + * Called from the peer via SwingAccessor, because the + * Component.updateCursorImmediately method is final + * and could not be overridden. + */ + private void updateClientCursor() { + Point p = MouseInfo.getPointerInfo().getLocation(); + SwingUtilities.convertPointFromScreen(p, this); + Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y); + if (target != null) { + content.setCursor(target.getCursor()); + } + } } --- old/src/share/classes/sun/swing/LightweightContent.java 2013-09-12 15:59:48.000000000 +0400 +++ new/src/share/classes/sun/swing/LightweightContent.java 2013-09-12 15:59:48.000000000 +0400 @@ -26,6 +26,7 @@ package sun.swing; import javax.swing.JComponent; +import java.awt.Cursor; /** * The interface by means of which the {@link JLightweightFrame} class @@ -179,4 +180,13 @@ * application that the content minimum size has changed. */ public void minimumSizeChanged(int width, int height); + + /** + * {@code JLightweightFrame} calls this method to notify the client + * application that in needs to set a cursor + * @param cursor a cursor to set + */ + default public void setCursor(Cursor cursor) { + throw new UnsupportedOperationException("Wrong client version is used"); + } } --- old/src/share/classes/sun/swing/SwingAccessor.java 2013-09-12 15:59:49.000000000 +0400 +++ new/src/share/classes/sun/swing/SwingAccessor.java 2013-09-12 15:59:49.000000000 +0400 @@ -72,6 +72,16 @@ } /** + * An accessor for the JLightweightFrame class. + */ + public interface JLightweightFrameAccessor { + /** + * Updates the JLightweight frame that it needs to update a cursor + */ + void updateCursor(JLightweightFrame frame); + } + + /** * The javax.swing.text.JTextComponent class accessor object. */ private static JTextComponentAccessor jtextComponentAccessor; @@ -93,4 +103,23 @@ return jtextComponentAccessor; } + + /** + * The JLightweightFrame class accessor object + */ + private static JLightweightFrameAccessor jLightweightFrameAccessor; + + /** + * Set an accessor object for the JLightweightFrame class. + */ + public static void setJLightweightFrameAccessor(JLightweightFrameAccessor accessor) { + jLightweightFrameAccessor = accessor; + } + + /** + * Retrieve the accessor object for the JLightweightFrame class + */ + public static JLightweightFrameAccessor getJLightweightFrameAccessor() { + return jLightweightFrameAccessor; + } } --- old/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java 2013-09-12 15:59:51.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java 2013-09-12 15:59:50.000000000 +0400 @@ -28,6 +28,8 @@ import java.awt.Graphics; import sun.awt.LightweightFrame; +import sun.swing.JLightweightFrame; +import sun.swing.SwingAccessor; public class XLightweightFramePeer extends XFramePeer { @@ -62,4 +64,9 @@ getLwTarget().ungrabFocus(); } } + + @Override + public void updateCursorImmediately() { + SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget()); + } } --- old/src/windows/classes/sun/awt/windows/WComponentPeer.java 2013-09-12 15:59:56.000000000 +0400 +++ new/src/windows/classes/sun/awt/windows/WComponentPeer.java 2013-09-12 15:59:56.000000000 +0400 @@ -656,7 +656,7 @@ _setFont(f); } public synchronized native void _setFont(Font f); - public final void updateCursorImmediately() { + public void updateCursorImmediately() { WGlobalCursorManager.getCursorManager().updateCursorImmediately(); } --- old/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java 2013-09-12 15:59:57.000000000 +0400 +++ new/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java 2013-09-12 15:59:57.000000000 +0400 @@ -31,6 +31,8 @@ import java.awt.event.MouseEvent; import sun.awt.LightweightFrame; +import sun.swing.JLightweightFrame; +import sun.swing.SwingAccessor; public class WLightweightFramePeer extends WFramePeer { @@ -83,4 +85,9 @@ public void ungrab() { getLwTarget().ungrabFocus(); } + + @Override + public void updateCursorImmediately() { + SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget()); + } }