diff options
author | Sven Gothel <sgothel@jausoft.com> | 2014-01-05 18:23:06 +0100 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2014-01-05 18:23:06 +0100 |
commit | dd527308f9129c705d82e6421e4822ba1a48abb9 (patch) | |
tree | 9e90d4079dabec79b1e9e46b100e4a09e47a9195 /src/nativewindow | |
parent | 58756bbd1d1fd63bb84dbfe2d6419d63de2da7ba (diff) |
Bug 935: NEWT PointerIcon/Visibility: Perform JAWTWindow's OffscreenLayerSurface PointerIcon/Visibility tasks async on AWT-EDT
setCursor(..) and hideCursor(..) must happen on the AWT-EDT w/o blocking,
otherwise we may deadlock the NEWT-EDT.
Diffstat (limited to 'src/nativewindow')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java | 40 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java | 4 |
2 files changed, 26 insertions, 18 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 46bdc4d1f..b947505cb 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -39,6 +39,7 @@ package com.jogamp.nativewindow.awt; import com.jogamp.common.os.Platform; import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.MutableGraphicsConfiguration; @@ -432,26 +433,33 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public final boolean setCursor(IOUtil.ClassResources resources, PointImmutable hotSpot) throws IOException { - final Cursor c; - if( null == resources || null == hotSpot ) { - c = Cursor.getDefaultCursor(); - } else { - final java.awt.Point awtHotspot = new java.awt.Point(hotSpot.getX(), hotSpot.getY()); - c = AWTMisc.getCursor(resources, awtHotspot); - } - if( null != c ) { - component.setCursor(c); - return true; - } else { - return false; - } + public final boolean setCursor(final IOUtil.ClassResources resources, final PointImmutable hotSpot) throws IOException { + AWTEDTExecutor.singleton.invoke(false, new Runnable() { + public void run() { + Cursor c = null; + if( null == resources || null == hotSpot ) { + c = Cursor.getDefaultCursor(); + } else { + final java.awt.Point awtHotspot = new java.awt.Point(hotSpot.getX(), hotSpot.getY()); + try { + c = AWTMisc.getCursor(resources, awtHotspot); + } catch (IOException e) { + e.printStackTrace(); + } + } + if( null != c ) { + component.setCursor(c); + } + } } ); + return true; } @Override public boolean hideCursor() { - final Cursor c = AWTMisc.getNullCursor(); - component.setCursor(c); + AWTEDTExecutor.singleton.invoke(false, new Runnable() { + public void run() { + component.setCursor(AWTMisc.getNullCursor()); + } } ); return true; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index 31de84137..b690aff4d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -177,7 +177,7 @@ public class AWTMisc { static final Cursor nulCursor; static { final Toolkit toolkit = Toolkit.getDefaultToolkit(); - BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); + final BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); nulCursor = toolkit.createCustomCursor(img, new Point(0,0), "nullCursor"); } @@ -194,7 +194,7 @@ public class AWTMisc { } private static synchronized Cursor createAWTCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException { final URLConnection urlConn = resources.resolve(0); - BufferedImage img = ImageIO.read(urlConn.getInputStream()); + final BufferedImage img = ImageIO.read(urlConn.getInputStream()); final Toolkit toolkit = Toolkit.getDefaultToolkit(); return toolkit.createCustomCursor(img, hotSpot, resources.resourcePaths[0]); |