diff options
author | Sven Gothel <[email protected]> | 2013-04-04 06:06:50 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-04-04 06:06:50 +0200 |
commit | 57bf60b789d89d70a58583a9cc0119317f179c3a (patch) | |
tree | 0ec6856de43671851a51951dbc14b3d9fe0507cc /src/newt | |
parent | 68526d3f9432ea9c80e444146fc99b4ae1352d50 (diff) |
OSX CALayer/NewtCanvasAWT: Force relayout of component (size +1, size -1) when attaching NEWT Child to avoid false CALayer position.
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 3d907a86f..d0a4b7e98 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -54,6 +54,8 @@ import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Display; @@ -561,7 +563,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { // if ( isShowing() == false ) -> Container was not visible yet. // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+ + System.err.println("NewtCanvasAWT.attachNewtChild.0 @ "+Thread.currentThread().getName()+": win "+newtWinHandleToHexString(newtChild)+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ ", cont "+AWTMisc.getContainer(this)); @@ -575,9 +577,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final int w = getWidth(); final int h = getHeight(); System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); + newtChild.setVisible(false); newtChild.setSize(w, h); newtChild.reparentWindow(jawtWindow); newtChild.addSurfaceUpdatedListener(jawtWindow); + if( Platform.OSType.MACOS == Platform.getOSType() && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + AWTEDTExecutor.singleton.invoke(false, forceRelayout); + } newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener @@ -589,6 +595,21 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } } + private final Runnable forceRelayout = new Runnable() { + public void run() { + if(DEBUG) { + System.err.println("NewtCanvasAWT.forceRelayout.0"); + } + // Hack to force proper native AWT layout incl. CALayer components on OSX + final java.awt.Component component = NewtCanvasAWT.this; + final int cW = component.getWidth(); + final int cH = component.getHeight(); + component.setSize(cW+1, cH+1); + component.setSize(cW, cH); + if(DEBUG) { + System.err.println("NewtCanvasAWT.forceRelayout.X"); + } + } }; private final void detachNewtChild(java.awt.Container cont) { if( null == newtChild || null == jawtWindow || !newtChildAttached ) { |