diff options
author | Sven Gothel <[email protected]> | 2012-12-30 19:40:17 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-12-30 19:40:17 +0100 |
commit | 35236f571a09e1ef21a57693bd2e4d715413f700 (patch) | |
tree | c94faa2747299618acac5d38510182e528ef8cf7 /src | |
parent | fee7dbecbaaa9a65ff8cb0f54531dada413233d1 (diff) |
Bug632: Test NEWT Child Window Translucency (X11/Windows) ..
- Windows: Child window is not translucent at all
- X11: Child window is translucent to parent's background,
however - parents content is _not_ 'composed in'.
- TODO: Find whether there is a solution or not.
- Note: The child window does not change it's rel. position
if parent moves! This is a feature, since we don't
have impl. a layout.
Diffstat (limited to 'src')
6 files changed, 180 insertions, 15 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 70da1137d..651d981ab 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -55,6 +55,7 @@ import com.jogamp.opengl.GLExtensions; import jogamp.nativewindow.windows.DWM_BLURBEHIND; import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIUtil; import jogamp.nativewindow.windows.MARGINS; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; import jogamp.opengl.GLContextImpl; @@ -170,13 +171,13 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio " for device context " + toHexString(hdc) + ": error code " + GDI.GetLastError()); } - if(!caps.isBackgroundOpaque()) { + if( !caps.isBackgroundOpaque() ) { final long hwnd = GDI.WindowFromDC(hdc); DWM_BLURBEHIND bb = DWM_BLURBEHIND.create(); - bb.setDwFlags(GDI.DWM_BB_ENABLE); - bb.setFEnable(1); + bb.setDwFlags(GDI.DWM_BB_ENABLE| GDI.DWM_BB_TRANSITIONONMAXIMIZED); + bb.setFEnable( 1 ); boolean ok = GDI.DwmEnableBlurBehindWindow(hwnd, bb); - if(ok) { + if( ok ) { MARGINS m = MARGINS.create(); m.setCxLeftWidth(-1); m.setCxRightWidth(-1); @@ -185,7 +186,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio ok = GDI.DwmExtendFrameIntoClientArea(hwnd, m); } if(DEBUG) { - System.err.println("translucency enabled on wnd: 0x"+Long.toHexString(hwnd)+" - ok: "+ok); + final boolean isUndecorated = GDIUtil.IsUndecorated(hwnd); + final boolean isChild = GDIUtil.IsChild(hwnd); + System.err.println("translucency enabled on wnd: 0x"+Long.toHexString(hwnd)+" - isUndecorated "+isUndecorated+", isChild "+isChild+", ok: "+ok); } } if (DEBUG) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index 2f4e18359..acb4c84da 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -112,12 +112,22 @@ public class GDIUtil implements ToolkitProperties { return (Point) GetRelativeLocation0(src_win, dest_win, src_x, src_y); } + public static boolean IsUndecorated(long win) { + return IsUndecorated0(win); + } + + public static boolean IsChild(long win) { + return IsChild0(win); + } + public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc); public static native boolean DestroyWindowClass(long hInstance, String className); private static native boolean initIDs0(); private static native long getDummyWndProc0(); private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y); + private static native boolean IsChild0(long win); + private static native boolean IsUndecorated0(long win); static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); } diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index 3ab7f9859..23be47380 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -224,3 +224,29 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDIUtil_GetRelativeLo return (*env)->NewObject(env, pointClz, pointCstr, (jint)dest.x, (jint)dest.y); } +/* + * Class: jogamp_nativewindow_windows_GDIUtil + * Method: IsChild0 + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsChild0 + (JNIEnv *env, jclass unused, jlong jwin) +{ + HWND hwnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hwnd, GWL_STYLE); + BOOL bIsChild = 0 != (style & WS_CHILD) ; + return bIsChild ? JNI_TRUE : JNI_FALSE; +} + +/* + * Class: jogamp_nativewindow_windows_GDIUtil + * Method: IsUndecorated0 + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsUndecorated0 + (JNIEnv *env, jclass unused, jlong jwin) +{ + HWND hwnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hwnd, GWL_STYLE); + BOOL bIsUndecorated = 0 != (style & (WS_CHILD|WS_POPUP)) ; + return bIsUndecorated ? JNI_TRUE : JNI_FALSE; +} + diff --git a/src/nativewindow/native/win32/WindowsDWM.h b/src/nativewindow/native/win32/WindowsDWM.h index 36f82fc94..6e5160fa4 100644 --- a/src/nativewindow/native/win32/WindowsDWM.h +++ b/src/nativewindow/native/win32/WindowsDWM.h @@ -4,6 +4,8 @@ #include <windows.h> #define DWM_BB_ENABLE 0x00000001 // fEnable has been specified + #define DWM_BB_BLURREGION 0x00000002 + #define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 #define DWM_EC_DISABLECOMPOSITION 0 #define DWM_EC_ENABLECOMPOSITION 1 diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentChildWindowBug632NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentChildWindowBug632NEWT.java new file mode 100644 index 000000000..1d186a490 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentChildWindowBug632NEWT.java @@ -0,0 +1,132 @@ +package com.jogamp.opengl.test.junit.newt.parenting; + +import java.io.IOException; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindow; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestTranslucentChildWindowBug632NEWT extends UITestCase { + static long durationPerTest = 2*300; + static GLProfile glp; + static boolean opaque; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getDefault(); + opaque = false; + } + + static GLWindow createParentWindow(GLCapabilitiesImmutable caps, int width, int height) + throws InterruptedException + { + Assert.assertNotNull(caps); + // + // Create native windowing resources .. X11/Win/OSX + // + GLWindow glWindow; + glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + + glWindow.setTitle("NEWT Parenting Window Test"); + + glWindow.addGLEventListener(new GearsES2(1)); + + glWindow.setSize(width, height); + glWindow.setVisible(true); + Assert.assertEquals(true,glWindow.isVisible()); + Assert.assertEquals(true,glWindow.isNativeValid()); + + return glWindow; + } + + static GLWindow createNestedWindow(NativeWindow nativeParentWindow, GLCapabilitiesImmutable caps, int x, int y, int width, int height) + throws InterruptedException { + + Assert.assertNotNull(nativeParentWindow); + Assert.assertNotNull(caps); + // + // Create native windowing resources .. X11/Win/OSX + // + GLWindow glWindow; + glWindow = GLWindow.create(nativeParentWindow, caps); + Assert.assertNotNull(glWindow); + + glWindow.setTitle("NEWT Parenting Window Test"); + + glWindow.addGLEventListener(new GearsES2(1)); + + glWindow.setPosition(x, y); + glWindow.setSize(width, height); + glWindow.setVisible(true); + Assert.assertEquals(true,glWindow.isVisible()); + Assert.assertEquals(true,glWindow.isNativeValid()); + + return glWindow; + } + + static void destroyWindow(GLWindow glWindow) { + if(null!=glWindow) { + glWindow.destroy(); + Assert.assertEquals(false,glWindow.isNativeValid()); + } + } + + @Test + public void testWindow00() throws InterruptedException { + final Animator animator = new Animator(); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + caps.setBackgroundOpaque(opaque); + GLWindow window1 = createParentWindow(caps, 400, 400); + Assert.assertEquals(true,window1.isNativeValid()); + Assert.assertEquals(true,window1.isVisible()); + animator.add(window1); + + GLWindow window2 = createNestedWindow(window1, caps, 400-300, 400-300, 300, 300); + Assert.assertEquals(true,window2.isNativeValid()); + Assert.assertEquals(true,window2.isVisible()); + animator.add(window2); + + animator.start(); + + AbstractGraphicsDevice device1 = window1.getScreen().getDisplay().getGraphicsDevice(); + + System.err.println("GLProfiles window1: "+device1.getConnection()+": "+GLProfile.glAvailabilityToString(device1)); + + Thread.sleep(durationPerTest/2); + + window1.setSize(512, 512); + window2.setPosition(512-300, 512-300); + + Thread.sleep(durationPerTest/2); + + animator.stop(); + + destroyWindow(window2); + destroyWindow(window1); + } + + public static void main(String[] args) throws IOException { + for(int i=0; i<args.length; i++) { + if(args[i].equals("-time")) { + durationPerTest = MiscUtils.atol(args[++i], durationPerTest); + } + } + String testName = TestTranslucentChildWindowBug632NEWT.class.getName(); + org.junit.runner.JUnitCore.main(testName); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java index 373c83fce..280cc7495 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java @@ -174,20 +174,12 @@ public class TestTranslucentParentingAWT extends UITestCase { } } - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - public static void main(String args[]) throws IOException { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { - durationPerTest = atoi(args[++i]); + durationPerTest = MiscUtils.atol(args[++i], durationPerTest); } else if(args[i].equals("-wait")) { - waitAdd2nd = atoi(args[++i]); + waitAdd2nd = MiscUtils.atol(args[++i], waitAdd2nd); } } String tstname = TestTranslucentParentingAWT.class.getName(); |