From a9b3f6d13b45284e81b91a1e1e31b35c31dd3670 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Thu, 1 Oct 2015 23:36:54 +0200
Subject: Bug 1232 - NEWT Translucent Decorated Windows Not Working On Windows
 >= 8 (Lack of Aero / Blur )

Adopting new undocumented user32.dll Windows >= 8 API:
  - SetWindowCompositionAttribute / AccentState

See:
  - <https://github.com/riverar/sample-win10-aeroglass/blob/master/MainWindow.xaml.cs>
  - <http://withinrafael.com/adding-the-aero-glass-blur-to-your-windows-10-apps/>
  - <http://undoc.airesoft.co.uk/user32.dll/SetWindowCompositionAttribute.php>
  - <http://undoc.airesoft.co.uk/user32.dll/GetWindowCompositionAttribute.php>

+++

Cleaning up WindowsDWM.h, use on header file (in stub_includes)
for GlueGen and implementation.

+++

Merge java implementation within GDIUtil.DwmSetupTranslucency(..),
to be utilized by NEWT and JOGL.

NEWT issues GDIUtil.DwmSetupTranslucency(..) at creation
and when toggling decoration.

Toggling decoration on Win >= 8 leads to lost of translucency
when returning to decorated window.
On Win 7, this may work .. but is also buggy.

+++

Followup patch is needed for NEWT to _not_ clear the background!
---
 .../classes/jogamp/newt/driver/windows/WindowDriver.java   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

(limited to 'src/newt/classes')

diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index c1aa4cb90..af5dad3ac 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -157,6 +157,10 @@ public class WindowDriver extends WindowImpl {
         if ( 0 == _windowHandle ) {
             throw new NativeWindowException("Error creating window");
         }
+        if( !cfg.getChosenCapabilities().isBackgroundOpaque() ) {
+            GDIUtil.DwmSetupTranslucency(_windowHandle, true);
+        }
+        InitWindow0(_windowHandle, flags);
         setWindowHandle(_windowHandle);
         windowHandleClose = _windowHandle;
 
@@ -235,7 +239,16 @@ public class WindowDriver extends WindowImpl {
             width = posSize[2];
             height = posSize[3];
         }
+
+        final boolean changeDecoration = 0 != ( CHANGE_MASK_DECORATION & flags);
+        final boolean isTranslucent = !getChosenCapabilities().isBackgroundOpaque();
+        if( changeDecoration && isTranslucent ) {
+            GDIUtil.DwmSetupTranslucency(getWindowHandle(), false);
+        }
         reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags);
+        if( changeDecoration && isTranslucent ) {
+            GDIUtil.DwmSetupTranslucency(getWindowHandle(), true);
+        }
 
         if( 0 != ( CHANGE_MASK_VISIBILITY & flags) ) {
             visibleChanged(false, 0 != ( STATE_MASK_VISIBLE & flags));
@@ -396,6 +409,7 @@ public class WindowDriver extends WindowImpl {
 
     private native long CreateWindow0(long hInstance, String wndClassName, String wndName, int winMajor, int winMinor,
                                       long parentWindowHandle, int x, int y, int width, int height, int flags);
+    private native void InitWindow0(long windowHandle, int flags);
     private native long MonitorFromWindow0(long windowHandle);
     private native void reconfigureWindow0(long parentWindowHandle, long windowHandle,
                                            int x, int y, int width, int height, int flags);
-- 
cgit v1.2.3