JBR-1278 allow native border and shadow for custom decoration mode
diff --git a/make/lib/Awt2dLibraries.gmk b/make/lib/Awt2dLibraries.gmk
index ee8e26f..27cf717 100644
--- a/make/lib/Awt2dLibraries.gmk
+++ b/make/lib/Awt2dLibraries.gmk
@@ -489,7 +489,7 @@
     LDFLAGS_SUFFIX_windows := kernel32.lib user32.lib gdi32.lib winspool.lib \
         imm32.lib ole32.lib uuid.lib shell32.lib \
         comdlg32.lib winmm.lib comctl32.lib shlwapi.lib \
-        delayimp.lib jvm.lib $(WIN_JAVA_LIB) advapi32.lib \
+        delayimp.lib jvm.lib $(WIN_JAVA_LIB) advapi32.lib dwmapi.lib \
         -DELAYLOAD:user32.dll -DELAYLOAD:gdi32.dll \
         -DELAYLOAD:shell32.dll -DELAYLOAD:winmm.dll \
         -DELAYLOAD:winspool.drv -DELAYLOAD:imm32.dll \
diff --git a/src/windows/native/sun/windows/awt_DesktopProperties.cpp b/src/windows/native/sun/windows/awt_DesktopProperties.cpp
index 3f5bb1e..1df9abd 100644
--- a/src/windows/native/sun/windows/awt_DesktopProperties.cpp
+++ b/src/windows/native/sun/windows/awt_DesktopProperties.cpp
@@ -37,6 +37,7 @@
 #include <shlobj.h>
 
 #include "math.h"
+#include <dwmapi.h>
 
 // WDesktopProperties fields
 jfieldID AwtDesktopProperties::pDataID = 0;
@@ -510,6 +511,16 @@
     SetColorProperty(TEXT("win.frame.activeCaptionColor"), GetSysColor(COLOR_ACTIVECAPTION));
     SetColorProperty(TEXT("win.frame.activeBorderColor"), GetSysColor(COLOR_ACTIVEBORDER));
 
+    BOOL enabled;
+    DwmIsCompositionEnabled(&enabled);
+    if (enabled) {
+        DWORD color;
+        BOOL opaque = FALSE;
+        // [tav] todo: listen WM_DWMCOLORIZATIONCOLORCHANGED
+        DwmGetColorizationColor(&color, &opaque);
+        SetColorProperty(TEXT("win.dwm.colorizationColor"), RGB(GetBValue(color), GetGValue(color), GetRValue(color)));
+    }
+
     // ?? ?? ??
     SetColorProperty(TEXT("win.frame.color"), GetSysColor(COLOR_WINDOWFRAME)); // ?? WHAT THE HECK DOES THIS MEAN ??
     // ?? ?? ??
diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp
index 531abb3..33c93b5 100644
--- a/src/windows/native/sun/windows/awt_Frame.cpp
+++ b/src/windows/native/sun/windows/awt_Frame.cpp
@@ -1782,18 +1782,23 @@
     if (!wParam || !HasCustomDecoration()) {
         return AwtWindow::WmNcCalcSize(wParam, lpncsp, retVal);
     }
-    if (::IsZoomed(GetHWnd())) {
-        RECT insets;
-        GetSysInsets(&insets);
-        static int xBorder = ::GetSystemMetrics(SM_CXBORDER);
-        static int yBorder = ::GetSystemMetrics(SM_CYBORDER);
 
-        // When maximized we should include insets or otherwise the client area edges get out of a screen
-        lpncsp->rgrc[0].left = lpncsp->rgrc[0].left + insets.left - xBorder;
-        lpncsp->rgrc[0].top = lpncsp->rgrc[0].top + insets.bottom - yBorder; // do not count caption
-        lpncsp->rgrc[0].right = lpncsp->rgrc[0].right - insets.right + xBorder;
-        lpncsp->rgrc[0].bottom = lpncsp->rgrc[0].bottom - insets.bottom + yBorder;
+    RECT insets;
+    GetSysInsets(&insets);
+    RECT* rect = &lpncsp->rgrc[0];
+
+    rect->left = rect->left + insets.left;
+    if (::IsZoomed(GetHWnd())) {
+        lpncsp->rgrc[0].top = lpncsp->rgrc[0].top + insets.bottom;
     }
+    else {
+        // this makes the native caption go uncovered
+        // int yBorder = ::GetSystemMetrics(SM_CYBORDER);
+        // lpncsp->rgrc[0].top = lpncsp->rgrc[0].top + yBorder;
+    }
+    rect->right = rect->right - insets.right;
+    rect->bottom = rect->bottom - insets.bottom;
+
     retVal = 0L;
     return mrConsume;
 }