MacOS: further limit CALayer to only be used when running as an Applet

This commit is contained in:
kappa1 2011-11-12 20:45:35 +00:00
parent d58bcf2ee0
commit e500d8e500
2 changed files with 22 additions and 2 deletions

View File

@ -32,6 +32,8 @@
package org.lwjgl.opengl;
import java.awt.Canvas;
import java.awt.Component;
import java.applet.Applet;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@ -81,7 +83,7 @@ final class AWTSurfaceLock {
// due to performance..
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
final boolean allowCALayer = ((Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas) && isApplet(component);
if (firstLockSucceeded)
return lockAndInitHandle(lock_buffer, component, allowCALayer);
@ -105,4 +107,22 @@ final class AWTSurfaceLock {
}
private static native void nUnlock(ByteBuffer lock_buffer) throws LWJGLException;
/**
* This method will return true if the component is running in an applet
*/
public boolean isApplet(Canvas component) {
Component parent = component.getParent();
while (parent != null) {
if (parent instanceof Applet) {
return true;
}
parent = parent.getParent();
}
// not an applet
return false;
}
}

View File

@ -51,7 +51,7 @@ abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo {
protected void initHandle(Canvas component) throws LWJGLException {
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
final boolean allowCALayer = ((Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas) && awt_surface.isApplet(component);
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), allowCALayer);
}