diff options
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 59 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java | 62 |
2 files changed, 6 insertions, 115 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index a0083b4ea..66f50781f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -31,7 +31,6 @@ package com.jogamp.newt.awt; import java.applet.Applet; import java.awt.AWTKeyStroke; -import java.awt.Canvas; import java.awt.Component; import java.awt.EventQueue; import java.awt.Graphics; @@ -43,9 +42,6 @@ import java.awt.geom.NoninvertibleTransformException; import java.beans.Beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Set; import com.jogamp.nativewindow.CapabilitiesImmutable; @@ -593,7 +589,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder * This code order also allows recreation, ie re-adding the GLCanvas. */ // before native peer is valid: X11 - disableBackgroundErase(); + JAWTUtil.disableBackgroundErase(this); // Query AWT GraphicsDevice from parent tree, default final GraphicsConfiguration gc = super.getGraphicsConfiguration(); @@ -611,7 +607,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder super.addNotify(); // after native peer is valid: Windows - disableBackgroundErase(); + JAWTUtil.disableBackgroundErase(this); synchronized(sync) { determineIfApplet(); @@ -1119,57 +1115,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder } } - // Disables the AWT's erasing of this Canvas's background on Windows - // in Java SE 6. This internal API is not available in previous - // releases, but the system property - // -Dsun.awt.noerasebackground=true can be specified to get similar - // results globally in previous releases. - private static boolean disableBackgroundEraseInitialized; - private static Method disableBackgroundEraseMethod; - private void disableBackgroundErase() { - if (!disableBackgroundEraseInitialized) { - try { - AccessController.doPrivileged(new PrivilegedAction<Object>() { - @Override - public Object run() { - try { - Class<?> clazz = getToolkit().getClass(); - while (clazz != null && disableBackgroundEraseMethod == null) { - try { - disableBackgroundEraseMethod = - clazz.getDeclaredMethod("disableBackgroundErase", - new Class[] { Canvas.class }); - disableBackgroundEraseMethod.setAccessible(true); - } catch (final Exception e) { - clazz = clazz.getSuperclass(); - } - } - } catch (final Exception e) { - } - return null; - } - }); - } catch (final Exception e) { - } - disableBackgroundEraseInitialized = true; - if(DEBUG) { - System.err.println("NewtCanvasAWT: TK disableBackgroundErase method found: "+ - (null!=disableBackgroundEraseMethod)); - } - } - if (disableBackgroundEraseMethod != null) { - Throwable t=null; - try { - disableBackgroundEraseMethod.invoke(getToolkit(), new Object[] { this }); - } catch (final Exception e) { - t = e; - } - if(DEBUG) { - System.err.println("NewtCanvasAWT: TK disableBackgroundErase error: "+t); - } - } - } - protected static String currentThreadName() { return "["+Thread.currentThread().getName()+", isAWT-EDT "+EventQueue.isDispatchThread()+"]"; } static String newtWinHandleToHexString(final Window w) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index bdf78386a..b81bd7544 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -38,9 +38,6 @@ import java.awt.Canvas; import java.awt.Graphics; import java.awt.GraphicsDevice; import java.awt.GraphicsConfiguration; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; import com.jogamp.nativewindow.AbstractGraphicsDevice; import com.jogamp.nativewindow.AbstractGraphicsScreen; @@ -58,6 +55,8 @@ import com.jogamp.nativewindow.awt.AWTGraphicsScreen; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Window; +import jogamp.nativewindow.jawt.JAWTUtil; + @SuppressWarnings("serial") public class AWTCanvas extends Canvas { private final WindowDriver driver; @@ -122,7 +121,7 @@ public class AWTCanvas extends Canvas { public void addNotify() { // before native peer is valid: X11 - disableBackgroundErase(); + JAWTUtil.disableBackgroundErase(this); /** * 'super.addNotify()' determines the GraphicsConfiguration, @@ -147,7 +146,7 @@ public class AWTCanvas extends Canvas { super.addNotify(); // after native peer is valid: Windows - disableBackgroundErase(); + JAWTUtil.disableBackgroundErase(this); { jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); @@ -347,57 +346,4 @@ public class AWTCanvas extends Canvas { return config; } - - // Disables the AWT's erasing of this Canvas's background on Windows - // in Java SE 6. This internal API is not available in previous - // releases, but the system property - // -Dsun.awt.noerasebackground=true can be specified to get similar - // results globally in previous releases. - private static boolean disableBackgroundEraseInitialized; - private static Method disableBackgroundEraseMethod; - private void disableBackgroundErase() { - if (!disableBackgroundEraseInitialized) { - try { - AccessController.doPrivileged(new PrivilegedAction<Object>() { - @Override - public Object run() { - try { - Class<?> clazz = getToolkit().getClass(); - while (clazz != null && disableBackgroundEraseMethod == null) { - try { - disableBackgroundEraseMethod = - clazz.getDeclaredMethod("disableBackgroundErase", - new Class[] { Canvas.class }); - disableBackgroundEraseMethod.setAccessible(true); - } catch (final Exception e) { - clazz = clazz.getSuperclass(); - } - } - } catch (final Exception e) { - } - return null; - } - }); - } catch (final Exception e) { - } - disableBackgroundEraseInitialized = true; - if(Window.DEBUG_IMPLEMENTATION) { - System.err.println("AWTCanvas: TK disableBackgroundErase method found: "+ - (null!=disableBackgroundEraseMethod)); - } - } - if (disableBackgroundEraseMethod != null) { - Throwable t=null; - try { - disableBackgroundEraseMethod.invoke(getToolkit(), new Object[] { this }); - } catch (final Exception e) { - // FIXME: workaround for 6504460 (incorrect backport of 6333613 in 5.0u10) - // throw new GLException(e); - t = e; - } - if(Window.DEBUG_IMPLEMENTATION) { - System.err.println("AWTCanvas: TK disableBackgroundErase error: "+t); - } - } - } } |