diff options
author | Sven Gothel <[email protected]> | 2011-02-22 07:44:41 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-02-22 07:44:41 +0100 |
commit | 282b52c1daaef63d65b5c0f4a633061980f6a3f6 (patch) | |
tree | 67cc9917db8efcf9707017ce00e2011e4170964d /src/newt/classes | |
parent | ab1d8180e3a20eeb11df48bed49ca5d28e34df4b (diff) |
Cleanup NEWT MainThread, using new AWTEDTUtil impl. / Sync AWTCanvas with GLCanvas changes
Cleanup NEWT MainThread, using new AWTEDTUtil impl.
- Allow simple singleton AWTEDTUtil to be used for AWTDisplay and more ..
Sync AWTCanvas with GLCanvas changes
- Latest GLCanvas changes around addNotify() had to be synced
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/util/MainThread.java | 86 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 14 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/awt/AWTCanvas.java | 63 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/awt/AWTDisplay.java | 20 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java | 108 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/awt/AWTWindow.java | 188 |
6 files changed, 276 insertions, 203 deletions
diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index 607645052..9f66fefe6 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -37,16 +37,25 @@ package com.jogamp.newt.util; -import java.util.*; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; -import java.security.*; - -import javax.media.nativewindow.*; - -import com.jogamp.common.util.*; -import com.jogamp.newt.*; -import jogamp.newt.*; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; + +import javax.media.nativewindow.NativeWindowFactory; + +import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.common.util.RunnableTask; +import com.jogamp.newt.Display; +import jogamp.newt.Debug; +import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.awt.AWTEDTUtil; /** * NEWT Utility class MainThread<P> @@ -103,16 +112,11 @@ public class MainThread implements EDTUtil { private static Map/*<Display, Runnable>*/ pumpMessageDisplayMap = new HashMap(); private static boolean useMainThread = false; - private static Class cAWTEventQueue=null; - private static Method mAWTInvokeAndWait=null; - private static Method mAWTInvokeLater=null; - private static Method mAWTIsDispatchThread=null; static class MainAction extends Thread { private String mainClassName; private String[] mainClassArgs; - private Class mainClass; private Method mainClassMain; public MainAction(String mainClassName, String[] mainClassArgs) { @@ -237,33 +241,28 @@ public class MainThread implements EDTUtil { } } - private void initAWTReflection() { - if(null == cAWTEventQueue) { - ClassLoader cl = MainThread.class.getClassLoader(); - cAWTEventQueue = ReflectionUtil.getClass("java.awt.EventQueue", true, cl); - mAWTInvokeAndWait = ReflectionUtil.getMethod(cAWTEventQueue, "invokeAndWait", new Class[] { java.lang.Runnable.class }, cl); - mAWTInvokeLater = ReflectionUtil.getMethod(cAWTEventQueue, "invokeLater", new Class[] { java.lang.Runnable.class }, cl); - mAWTIsDispatchThread = ReflectionUtil.getMethod(cAWTEventQueue, "isDispatchThread", new Class[] { }, cl); + final public void reset() { + if(NativeWindowFactory.isAWTAvailable()) { + AWTEDTUtil.getSingleton().reset(); } - } - - public void reset() { // nop } - public void start() { + final public void start() { + if(NativeWindowFactory.isAWTAvailable()) { + AWTEDTUtil.getSingleton().start(); + } // nop } - public boolean isCurrentThreadEDT() { + final public boolean isCurrentThreadEDT() { if(NativeWindowFactory.isAWTAvailable()) { - initAWTReflection(); - return ((Boolean) ReflectionUtil.callMethod(null, mAWTIsDispatchThread, null) ).booleanValue(); + return AWTEDTUtil.getSingleton().isCurrentThreadEDT(); } return isRunning() && mainThread == Thread.currentThread() ; } - public boolean isRunning() { + final public boolean isRunning() { if( useMainThread ) { synchronized(taskWorkerLock) { return isRunning; @@ -284,11 +283,11 @@ public class MainThread implements EDTUtil { } } - public void invokeStop(Runnable r) { + final public void invokeStop(Runnable r) { invokeImpl(true, r, true); } - public void invoke(boolean wait, Runnable r) { + final public void invoke(boolean wait, Runnable r) { invokeImpl(wait, r, false); } @@ -298,22 +297,7 @@ public class MainThread implements EDTUtil { } if(NativeWindowFactory.isAWTAvailable()) { - initAWTReflection(); - - // handover to AWT MainThread .. - try { - if ( ((Boolean) ReflectionUtil.callMethod(null, mAWTIsDispatchThread, null) ).booleanValue() ) { - r.run(); - return; - } - if(wait) { - ReflectionUtil.callMethod(null, mAWTInvokeAndWait, new Object[] { r }); - } else { - ReflectionUtil.callMethod(null, mAWTInvokeLater, new Object[] { r }); - } - } catch (Exception e) { - throw new NativeWindowException(e); - } + AWTEDTUtil.getSingleton().invokeImpl(wait, r, stop); return; } @@ -355,10 +339,16 @@ public class MainThread implements EDTUtil { } } - public void waitUntilIdle() { + final public void waitUntilIdle() { + if(NativeWindowFactory.isAWTAvailable()) { + AWTEDTUtil.getSingleton().waitUntilIdle(); + } } - public void waitUntilStopped() { + final public void waitUntilStopped() { + if(NativeWindowFactory.isAWTAvailable()) { + AWTEDTUtil.getSingleton().waitUntilStopped(); + } } private void waitUntilRunning() { diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 925828175..016906581 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -37,10 +37,10 @@ package jogamp.newt; +import java.util.ArrayList; +import javax.media.nativewindow.NativeWindowException; import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.util.EDTUtil; -import java.util.*; -import javax.media.nativewindow.NativeWindowException; public class DefaultEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); @@ -191,7 +191,7 @@ public class DefaultEDTUtil implements EDTUtil { } } - public void waitUntilIdle() { + final public void waitUntilIdle() { if(edt.isRunning() && edt != Thread.currentThread()) { synchronized(edt.tasks) { while(edt.isRunning() && edt.tasks.size()>0) { @@ -206,7 +206,7 @@ public class DefaultEDTUtil implements EDTUtil { } } - public void waitUntilStopped() { + final public void waitUntilStopped() { if(edt.isRunning() && edt != Thread.currentThread() ) { synchronized(edtLock) { if(edt.isRunning() && edt != Thread.currentThread() ) { @@ -231,11 +231,11 @@ public class DefaultEDTUtil implements EDTUtil { super(tg, name); } - public final boolean isRunning() { + final public boolean isRunning() { return isRunning; } - public void start() throws IllegalThreadStateException { + final public void start() throws IllegalThreadStateException { isRunning = true; super.start(); } @@ -244,7 +244,7 @@ public class DefaultEDTUtil implements EDTUtil { * Utilizing locking only on tasks and its execution, * not for event dispatching. */ - public void run() { + final public void run() { if(DEBUG) { System.err.println(getName()+": EDT run() START "+ getName()); } diff --git a/src/newt/classes/jogamp/newt/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/awt/AWTCanvas.java index 5606ceb01..01e813449 100644 --- a/src/newt/classes/jogamp/newt/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/awt/AWTCanvas.java @@ -33,18 +33,24 @@ package jogamp.newt.awt; -import com.jogamp.newt.Window; - import java.awt.Canvas; import java.awt.GraphicsDevice; import java.awt.GraphicsConfiguration; - -import javax.media.nativewindow.*; -import javax.media.nativewindow.awt.*; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.CapabilitiesChooser; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.awt.AWTGraphicsConfiguration; +import javax.media.nativewindow.awt.AWTGraphicsDevice; +import javax.media.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.newt.Window; + public class AWTCanvas extends Canvas { private GraphicsDevice device; private GraphicsConfiguration chosen; @@ -76,29 +82,37 @@ public class AWTCanvas extends Canvas { } public void addNotify() { - super.addNotify(); - - disableBackgroundErase(); - GraphicsConfiguration gc = super.getGraphicsConfiguration(); - if(null!=gc) { - device = gc.getDevice(); - } - - /* - * Save the chosen capabilities for use in getGraphicsConfiguration(). + /** + * 'super.addNotify()' determines the GraphicsConfiguration, + * while calling this class's overriden 'getGraphicsConfiguration()' method + * after which it creates the native peer. + * Hence we have to set the 'awtConfig' before since it's GraphicsConfiguration + * is being used in getGraphicsConfiguration(). + * This code order also allows recreation, ie re-adding the GLCanvas. */ awtConfig = chooseGraphicsConfiguration(capabilities, capabilities, chooser, device); if(Window.DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Created Config: "+awtConfig); e.printStackTrace(); } - if(null!=awtConfig) { - // update .. - chosen = awtConfig.getGraphicsConfiguration(); - } if(null==awtConfig) { - throw new NativeWindowException("Error: AWTGraphicsConfiguration is null"); + throw new NativeWindowException("Error: NULL AWTGraphicsConfiguration"); + } + chosen = awtConfig.getGraphicsConfiguration(); + + // before native peer is valid: X11 + disableBackgroundErase(); + + // issues getGraphicsConfiguration() and creates the native peer + super.addNotify(); + + // after native peer is valid: Windows + disableBackgroundErase(); + + GraphicsConfiguration gc = super.getGraphicsConfiguration(); + if(null!=gc) { + device = gc.getDevice(); } } @@ -276,13 +290,22 @@ public class AWTCanvas extends Canvas { } catch (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 (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); } } } diff --git a/src/newt/classes/jogamp/newt/awt/AWTDisplay.java b/src/newt/classes/jogamp/newt/awt/AWTDisplay.java index f8a756f60..4c864c111 100644 --- a/src/newt/classes/jogamp/newt/awt/AWTDisplay.java +++ b/src/newt/classes/jogamp/newt/awt/AWTDisplay.java @@ -33,13 +33,10 @@ package jogamp.newt.awt; -import java.awt.event.*; -import com.jogamp.newt.Display; -import com.jogamp.newt.Window; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.newt.NewtFactory; import jogamp.newt.DisplayImpl; -import javax.media.nativewindow.*; -import javax.media.nativewindow.awt.*; -import java.util.*; public class AWTDisplay extends DisplayImpl { public AWTDisplay() { @@ -55,9 +52,16 @@ public class AWTDisplay extends DisplayImpl { protected void closeNativeImpl() { } - protected boolean shallRunOnEDT() { - return false; + @Override + protected void createEDTUtil() { + if(NewtFactory.useEDT()) { + edtUtil = AWTEDTUtil.getSingleton(); + if(DEBUG) { + System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+edtUtil.getClass().getName()); + } + } } + protected void dispatchMessagesNative() { /* nop */ } } diff --git a/src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java new file mode 100644 index 000000000..914a73f4d --- /dev/null +++ b/src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java @@ -0,0 +1,108 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.awt; + +import java.awt.EventQueue; +import javax.media.nativewindow.NativeWindowException; +import com.jogamp.newt.util.EDTUtil; +import jogamp.newt.Debug; + +public class AWTEDTUtil implements EDTUtil { + public static final boolean DEBUG = Debug.debug("EDT"); + + private static AWTEDTUtil singletonMainThread = new AWTEDTUtil(); // one singleton MainThread + + public static final AWTEDTUtil getSingleton() { + return singletonMainThread; + } + + AWTEDTUtil() { + // package private access .. + } + + final public void reset() { + // nop + } + + final public void start() { + // nop + } + + final public boolean isCurrentThreadEDT() { + return EventQueue.isDispatchThread(); + } + + final public boolean isRunning() { + return true; // AWT is always running + } + + final public void invokeStop(Runnable r) { + invokeImpl(true, r, true); + } + + final public void invoke(boolean wait, Runnable r) { + invokeImpl(wait, r, false); + } + + /** + * Public access to provide simple dispatching from other EDTUtil implementations + * @param wait true if invokeLater + * @param r the Runnable action + * @param stop true if EDT shall stop (ignored with AWT) + */ + final public void invokeImpl(boolean wait, Runnable r, boolean stop) { + if(r == null) { + return; + } + + // handover to AWT MainThread .. + try { + if ( isCurrentThreadEDT() ) { + r.run(); + return; + } + if(wait) { + EventQueue.invokeAndWait(r); + } else { + EventQueue.invokeLater(r); + } + } catch (Exception e) { + throw new NativeWindowException(e); + } + } + + final public void waitUntilIdle() { + } + + final public void waitUntilStopped() { + } + +} + + diff --git a/src/newt/classes/jogamp/newt/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/awt/AWTWindow.java index 908b6f2cb..0a6a557f7 100644 --- a/src/newt/classes/jogamp/newt/awt/AWTWindow.java +++ b/src/newt/classes/jogamp/newt/awt/AWTWindow.java @@ -34,19 +34,19 @@ package jogamp.newt.awt; -import com.jogamp.newt.event.awt.*; -import com.jogamp.newt.util.EDTUtil; - import java.awt.BorderLayout; import java.awt.Container; import java.awt.DisplayMode; -import java.awt.EventQueue; import java.awt.Frame; -import jogamp.newt.WindowImpl; import java.awt.Insets; -import javax.media.nativewindow.*; -import javax.media.nativewindow.awt.*; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.awt.AWTGraphicsDevice; +import javax.media.nativewindow.awt.AWTGraphicsScreen; import javax.media.nativewindow.util.Point; +import jogamp.newt.WindowImpl; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTMouseAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; /** An implementation of the Newt Window class built using the AWT. This is provided for convenience of porting to platforms @@ -77,89 +77,67 @@ public class AWTWindow extends WindowImpl { private AWTCanvas canvas; protected void requestFocusImpl(boolean reparented) { - runOnEDT(true, new Runnable() { - public void run() { - container.requestFocus(); - } - }); + container.requestFocus(); } protected void setTitleImpl(final String title) { - runOnEDT(true, new Runnable() { - public void run() { - if (frame != null) { - frame.setTitle(title); - } - } - }); + if (frame != null) { + frame.setTitle(title); + } } protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); } - final AWTWindow awtWindow = this; + if(null==container) { + frame = new Frame(); + container = frame; + owningFrame=true; + } else { + owningFrame=false; + width = container.getWidth(); + height = container.getHeight(); + x = container.getX(); + y = container.getY(); + } + if(null!=frame) { + frame.setTitle(getTitle()); + } + container.setLayout(new BorderLayout()); + canvas = new AWTCanvas(capsRequested, AWTWindow.this.capabilitiesChooser); - runOnEDT(true, new Runnable() { - public void run() { - if(null==container) { - frame = new Frame(); - container = frame; - owningFrame=true; - } else { - owningFrame=false; - width = container.getWidth(); - height = container.getHeight(); - x = container.getX(); - y = container.getY(); - } - if(null!=frame) { - frame.setTitle(getTitle()); - } - container.setLayout(new BorderLayout()); - canvas = new AWTCanvas(capsRequested, AWTWindow.this.capabilitiesChooser); + addWindowListener(new LocalWindowListener()); - addWindowListener(new LocalWindowListener()); + new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here - new AWTMouseAdapter(awtWindow).addTo(canvas); // fwd all AWT Mouse events to here - new AWTKeyAdapter(awtWindow).addTo(canvas); // fwd all AWT Key events to here + // canvas.addComponentListener(listener); + container.add(canvas, BorderLayout.CENTER); + container.setSize(width, height); + container.setLocation(x, y); + new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here - // canvas.addComponentListener(listener); - container.add(canvas, BorderLayout.CENTER); - container.setSize(width, height); - container.setLocation(x, y); - new AWTWindowAdapter(awtWindow).addTo(container); // fwd all AWT Window events to here + if(null!=frame) { + frame.setUndecorated(undecorated||fullscreen); + } - if(null!=frame) { - frame.setUndecorated(undecorated||fullscreen); - } - } - }); setWindowHandle(1); // just a marker .. } protected void closeNativeImpl() { setWindowHandle(0); // just a marker .. if(null!=container) { - runOnEDT(true, new Runnable() { - public void run() { - container.setVisible(false); - container.remove(canvas); - container.setEnabled(false); - canvas.setEnabled(false); - } - }); + container.setVisible(false); + container.remove(canvas); + container.setEnabled(false); + canvas.setEnabled(false); } if(owningFrame && null!=frame) { - runOnEDT(true, new Runnable() { - public void run() { - frame.dispose(); - owningFrame=false; - frame = null; - } - }); + frame.dispose(); + owningFrame=false; + frame = null; } } @@ -176,11 +154,7 @@ public class AWTWindow extends WindowImpl { } protected void setVisibleImpl(final boolean visible, int x, int y, int width, int height) { - runOnEDT(true, new Runnable() { - public void run() { - container.setVisible(visible); - } - }); + container.setVisible(visible); reconfigureWindowImpl(x, y, width, height, false, 0, 0); config = canvas.getAWTGraphicsConfiguration(); @@ -206,42 +180,33 @@ public class AWTWindow extends WindowImpl { public javax.media.nativewindow.util.Insets getInsets() { final int insets[] = new int[] { 0, 0, 0, 0 }; - runOnEDT(true, new Runnable() { - public void run() { - Insets contInsets = container.getInsets(); - insets[0] = contInsets.top; - insets[1] = contInsets.left; - insets[2] = contInsets.bottom; - insets[3] = contInsets.right; - } - }); + Insets contInsets = container.getInsets(); + insets[0] = contInsets.top; + insets[1] = contInsets.left; + insets[2] = contInsets.bottom; + insets[3] = contInsets.right; return new javax.media.nativewindow.util.Insets(insets[0],insets[1],insets[2],insets[3]); } protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final boolean parentChange, final int fullScreenChange, final int decorationChange) { - /** An AWT event on setSize() would bring us in a deadlock situation, hence invokeLater() */ - runOnEDT(false, new Runnable() { - public void run() { - if(decorationChange!=0 && null!=frame) { - if(!container.isDisplayable()) { - frame.setUndecorated(isUndecorated()); - } else { - if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { - System.err.println("AWTWindow can't undecorate already created frame"); - } - } - } - int _x=(x>=0)?x:AWTWindow.this.x; - int _y=(x>=0)?y:AWTWindow.this.y; - int _w=(width>0)?width:AWTWindow.this.width; - int _h=(height>0)?height:AWTWindow.this.height; - - container.setLocation(_x, _y); - Insets insets = container.getInsets(); - container.setSize(_w + insets.left + insets.right, - _h + insets.top + insets.bottom); + if(decorationChange!=0 && null!=frame) { + if(!container.isDisplayable()) { + frame.setUndecorated(isUndecorated()); + } else { + if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { + System.err.println("AWTWindow can't undecorate already created frame"); } - }); + } + } + int _x=(x>=0)?x:AWTWindow.this.x; + int _y=(x>=0)?y:AWTWindow.this.y; + int _w=(width>0)?width:AWTWindow.this.width; + int _h=(height>0)?height:AWTWindow.this.height; + + container.setLocation(_x, _y); + Insets insets = container.getInsets(); + container.setSize(_w + insets.left + insets.right, + _h + insets.top + insets.bottom); return true; } @@ -255,23 +220,6 @@ public class AWTWindow extends WindowImpl { return canvas; } - private void runOnEDT(boolean wait, Runnable r) { - EDTUtil edtUtil = getScreen().getDisplay().getEDTUtil(); - if ( ( null != edtUtil && edtUtil.isCurrentThreadEDT() ) || EventQueue.isDispatchThread() ) { - r.run(); - } else { - try { - if(wait) { - EventQueue.invokeAndWait(r); - } else { - EventQueue.invokeLater(r); - } - } catch (Exception e) { - throw new NativeWindowException(e); - } - } - } - class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter { public void windowMoved(com.jogamp.newt.event.WindowEvent e) { if(null!=container) { |