aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java15
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java46
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java12
3 files changed, 57 insertions, 16 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index f38e7ea2b..e326b65bd 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -28,13 +28,16 @@
package jogamp.nativewindow.awt;
import java.awt.FocusTraversalPolicy;
+import java.awt.Insets;
import java.awt.Window;
import java.awt.Component;
import java.awt.Container;
import java.awt.Frame;
+
+import javax.swing.JComponent;
import javax.swing.JFrame;
+import javax.swing.JRootPane;
import javax.swing.WindowConstants;
-
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.WindowClosingProtocol;
import javax.swing.MenuSelectionManager;
@@ -68,6 +71,16 @@ public class AWTMisc {
}
return (Container) c;
}
+
+ public static Insets getInsets(Component c) {
+ if( c instanceof Window ) {
+ return ((Window)c).getInsets();
+ }
+ if( c instanceof JComponent ) {
+ return ((JComponent)c).getInsets();
+ }
+ return null;
+ }
public static interface ComponentAction {
/**
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 666f895f4..6d08078b6 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -40,6 +40,7 @@
package jogamp.nativewindow.jawt.macosx;
+import java.awt.Component;
import java.nio.Buffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -49,11 +50,11 @@ import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.MutableSurface;
-import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.util.Point;
import com.jogamp.nativewindow.awt.JAWTWindow;
+import jogamp.nativewindow.awt.AWTMisc;
import jogamp.nativewindow.jawt.JAWT;
import jogamp.nativewindow.jawt.JAWTFactory;
import jogamp.nativewindow.jawt.JAWTUtil;
@@ -105,19 +106,42 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
@Override
protected void attachSurfaceLayerImpl(final long layerHandle) {
OSXUtil.RunOnMainThread(false, new Runnable() {
- public void run() {
- OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks());
+ public void run() {
+ // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets.
+ // Determine p0: components location on screen w/o insets.
+ // CALayer position will be determined in native code.
+ final Point p0 = new Point();
+ final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
+ final java.awt.Insets ins = AWTMisc.getInsets(outterComp);
+ if(null != ins) {
+ p0.translate(-ins.left, -ins.top);
+ }
+ if( DEBUG ) {
+ final java.awt.Point wP0 = outterComp.getLocationOnScreen();
+ System.err.println("JAWTWindow.attachSurfaceHandleImpl: "+toHexString(layerHandle) + ", wP0 "+wP0+"[ins "+ins+"], p0 "+p0+", bounds "+bounds);
+ }
+ OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p0.getX(), p0.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks());
} } );
}
@Override
- protected void layoutSurfaceLayerImpl(long layerHandle, int width, int height) {
+ protected void layoutSurfaceLayerImpl(long layerHandle) {
final int caLayerQuirks = JAWTUtil.getOSXCALayerQuirks();
if( 0 != caLayerQuirks ) {
- if(DEBUG) {
- System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", "+width+"x"+height+", caLayerQuirks "+caLayerQuirks+"; "+this);
+ // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets.
+ // Determine p0: components location on screen w/o insets.
+ // CALayer position will be determined in native code.
+ final Point p0 = new Point();
+ final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
+ final java.awt.Insets ins = AWTMisc.getInsets(outterComp);
+ if( null != ins ) {
+ p0.translate(-ins.left, -ins.top);
}
- OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, width, height, caLayerQuirks);
+ if( DEBUG ) {
+ final java.awt.Point wP0 = outterComp.getLocationOnScreen();
+ System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", wP0 "+wP0+"[ins "+ins+"], p0 "+p0+", bounds "+bounds);
+ }
+ OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, p0.getX(), p0.getY(), getWidth(), getHeight(), caLayerQuirks);
}
}
@@ -312,8 +336,12 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
* </p>
*/
@Override
- public Point getLocationOnScreen(Point storage) {
- return getLocationOnScreenNonBlocking(storage, component);
+ public Point getLocationOnScreen(Point storage) {
+ if( null == storage ) {
+ storage = new Point();
+ }
+ getLocationOnScreenNonBlocking(storage, component);
+ return storage;
}
protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index de24a76db..2112131ed 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -163,14 +163,14 @@ public class OSXUtil implements ToolkitProperties {
* @see #CreateCALayer(int, int)
* @see #RemoveCASublayer(long, long, boolean)
*/
- public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int width, final int height, final int caLayerQuirks) {
+ public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int x, final int y, final int width, final int height, final int caLayerQuirks) {
if(0==rootCALayer || 0==subCALayer) {
throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer));
}
if(DEBUG) {
System.err.println("OSXUtil.AttachCALayer: caLayerQuirks "+caLayerQuirks+", 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName());
}
- AddCASublayer0(rootCALayer, subCALayer, width, height, caLayerQuirks);
+ AddCASublayer0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks);
}
/**
@@ -190,11 +190,11 @@ public class OSXUtil implements ToolkitProperties {
* @param height the expected height
* @param caLayerQuirks TODO
*/
- public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int width, final int height, final int caLayerQuirks) {
+ public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int x, final int y, final int width, final int height, final int caLayerQuirks) {
if( 0==rootCALayer && 0==subCALayer ) {
return;
}
- FixCALayerLayout0(rootCALayer, subCALayer, width, height, caLayerQuirks);
+ FixCALayerLayout0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks);
}
/**
@@ -357,8 +357,8 @@ public class OSXUtil implements ToolkitProperties {
private static native long GetNSView0(long nsWindow);
private static native long GetNSWindow0(long nsView);
private static native long CreateCALayer0(int width, int height);
- private static native void AddCASublayer0(long rootCALayer, long subCALayer, int width, int height, int caLayerQuirks);
- private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int width, int height, int caLayerQuirks);
+ private static native void AddCASublayer0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks);
+ private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks);
private static native void RemoveCASublayer0(long rootCALayer, long subCALayer);
private static native void DestroyCALayer0(long caLayer);
private static native void RunOnMainThread0(Runnable runnable);