From f51e3dad6c4bd1f6d0001cecf6a0f692400ed602 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Nov 2011 01:17:23 +0100 Subject: OS X Layered View: Part4 NEWT OffscreenWindow/WindowImpl fix WindowImpl: - Impl. NativeSurfaceHolder/NativeWindowHolder 'hooks' - setScreen() utilize proper screen reference count/destruction: - set 'screenReferenceAdded=true' and incr. ref-count, hence next destroy() properly decr. ref-count (may destuct screen). OffscreenWindow: - Allow parent window handle (simply ignore it) Otherwise we could not use OffscreenWindow for parenting tests. - Fix setSize() propaget if !isNativeValid() instead of !isVisible(), otherwise lazy initialization doesn't work. - Allow reconfigureWindowImpl() to pass flags other than visible, simply ignore them. --- src/newt/classes/jogamp/newt/OffscreenWindow.java | 23 ++++++++++++++--------- src/newt/classes/jogamp/newt/WindowImpl.java | 10 ++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index fa7bafe5b..a7a930691 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -48,9 +48,6 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { static long nextWindowHandle = 0x100; // start here - a marker protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new NativeWindowException("OffscreenWindow does not support window parenting"); - } if(capsRequested.isOnscreen()) { throw new NativeWindowException("Capabilities is onscreen"); } @@ -90,28 +87,36 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { @Override public void setSize(int width, int height) { - if(!isVisible()) { - sizeChanged(false, width, height, false); + if(!isNativeValid()) { + super.setSize(width, height); } } + @Override public void setPosition(int x, int y) { // nop } + @Override public boolean setFullscreen(boolean fullscreen) { // nop return false; } - + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { sizeChanged(false, width, height, false); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } else { - shouldNotCallThis(); + /** + * silently ignore: + FLAG_CHANGE_PARENTING + FLAG_CHANGE_DECORATION + FLAG_CHANGE_FULLSCREEN + FLAG_CHANGE_ALWAYSONTOP + */ } - return false; + return true; } @Override diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index aadb89679..919c32f13 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -538,6 +538,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // NativeSurface // + public NativeSurface getNativeSurface() { + return this; + } + public final int lockSurface() { windowLock.lock(); surfaceLock.lock(); @@ -630,6 +634,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // NativeWindow // + public NativeWindow getNativeWindow() { + return this; + } + // public final void destroy() - see below public final NativeWindow getParent() { @@ -930,6 +938,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private void setScreen(ScreenImpl newScreen) { // never null ! WindowImpl.this.removeScreenReference(); screen = newScreen; + screen.addReference(); + screenReferenceAdded = false; } public final void run() { -- cgit v1.2.3