From bec29cf970e6a55eb8f720afdae5a3bdc97c1ba2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 4 Jan 2014 17:18:47 +0100 Subject: Bug 935: NEWT OSX PointerIcon/Pointer-Visibility: Impl. OffscreenLayerSurface (OSX CALayer) w/ JAWTWindow Path Add setCursor(..) and hideCursor() to OffscreenLayerSurface interface, impl. in JAWTWindow w/ AWT. This allows an OSX NEWT Window using CALayer (i.e. NewtCanvasAWT) to have setPointerIcon(..) and setPointerVisible(..) functionality! --- .../jogamp/newt/driver/macosx/WindowDriver.java | 36 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/newt/classes/jogamp') diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 6f3c95570..748604994 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -39,6 +39,8 @@ import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; @@ -403,7 +405,23 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl throw new RuntimeException("Failed: "+pi+", "+WindowDriver.this); } } } ); - } // else may need offscreen solution ? FIXME + } else { + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true); + if( null != ols ) { + try { + setOLSPointer(ols, pi); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + private static void setOLSPointer(final OffscreenLayerSurface ols, final PointerIconImpl pi) throws Exception { + if( null != pi ) { + ols.setCursor(pi.getResource(), pi.getHotspot()); + } else { + ols.setCursor(null, null); // default + } } @Override @@ -417,7 +435,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } } ); return true; // setPointerVisible0 always returns true .. - } // else may need offscreen solution ? FIXME + } else { + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true); + if( null != ols ) { + try { + if( pointerVisible ) { + setOLSPointer(ols, (PointerIconImpl)getPointerIcon()); + } else { + ols.hideCursor(); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + } + } + } return false; } -- cgit v1.2.3