changeset 2137:e780c68cf5b1

Win: Added a function to create the MARGINS struct from RECT... Also call DwmExtendFrameIntoClientArea() so the frame controls still get drawn.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 09 Jul 2020 05:18:47 +0000
parents bbd81ee0ca9a
children 55263d21b399
files win/dw.c
diffstat 1 files changed, 51 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Thu Jul 09 01:33:12 2020 +0000
+++ b/win/dw.c	Thu Jul 09 05:18:47 2020 +0000
@@ -815,6 +815,13 @@
    }
 }
 
+MARGINS _dw_rect_to_margins(RECT rect)
+{
+   MARGINS mar = { rect.left, rect.right, rect.top, rect.bottom };
+   
+   return mar;
+}
+
 BOOL _CanThemeWindow(HWND window)
 {
    TCHAR tmpbuf[100] = {0};
@@ -2025,14 +2032,22 @@
 
       if(cinfo)
       {
-         /*NCCALCSIZE_PARAMS* sz = (NCCALCSIZE_PARAMS*)mp2;
+         NCCALCSIZE_PARAMS* sz = (NCCALCSIZE_PARAMS*)mp2;
 
          sz->rgrc[0].left += cinfo->rect.left;
          sz->rgrc[0].right -= cinfo->rect.right;
-         sz->rgrc[0].bottom -= cinfo->rect.bottom;;*/
+         sz->rgrc[0].bottom -= cinfo->rect.bottom;
          return 0;
       }
    }
+   else if(msg == WM_NCPAINT && _DW_DARK_MODE_ENABLED && _DW_DARK_MODE_ALLOWED > DW_DARK_MODE_BASIC)
+   {
+      /* Handle close/minimize/maximize/help button */
+      LRESULT lResult;
+
+      if(_DwmDefWindowProc && _DwmDefWindowProc(hWnd, msg, mp1, mp2, &lResult))
+         return lResult;
+   }
    else if(msg == WM_NCHITTEST && _DW_DARK_MODE_ENABLED && _DW_DARK_MODE_ALLOWED > DW_DARK_MODE_BASIC)
    {
       /* Handle close/minimize/maximize/help button */
@@ -2570,26 +2585,32 @@
          if(_DwmIsCompositionEnabled)
             _DwmIsCompositionEnabled(&_dw_composition);
          
-         if(cinfo && (cinfo->style & DW_FCF_COMPOSITED))
-         {
-            /* If we are no longer compositing... */
-            if(!_dw_composition)
-            {
-               MARGINS mar = {0};
-
-               SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 255, LWA_ALPHA);
-               if(_DwmExtendFrameIntoClientArea)
-                  _DwmExtendFrameIntoClientArea(hWnd, &mar);
-            }
-            /* If we have started compositing... */
+         /* If we are no longer compositing... */
+         if(!_dw_composition)
+         {
+            MARGINS mar = {0};
+
+            SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 255, LWA_ALPHA);
+            if(_DwmExtendFrameIntoClientArea)
+               _DwmExtendFrameIntoClientArea(hWnd, &mar);
+         }
+         /* If we have started compositing... */
+         else
+         {
+            MARGINS mar = {-1};
+
+            if(cinfo && (cinfo->style & DW_FCF_COMPOSITED))
+               SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 0, LWA_COLORKEY);
             else
             {
-               MARGINS mar = {-1};
-
-               SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 0, LWA_COLORKEY);
-               if(_DwmExtendFrameIntoClientArea)
-                  _DwmExtendFrameIntoClientArea(hWnd, &mar);
+               if(cinfo)
+                  mar = _dw_rect_to_margins(cinfo->rect);
+               else
+                  memset(&mar, 0, sizeof(MARGINS));
+               SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 255, LWA_ALPHA);
             }
+            if(_DwmExtendFrameIntoClientArea)
+               _DwmExtendFrameIntoClientArea(hWnd, &mar);
          }
       }
       break;
@@ -5702,7 +5723,15 @@
       SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY);
    }
    else
+   {
+      if(_DwmExtendFrameIntoClientArea && _dw_composition)
+      {
+         MARGINS mar = _dw_rect_to_margins(newbox->cinfo.rect);
+
+         _DwmExtendFrameIntoClientArea(hwndframe, &mar);
+      }
       SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 255, LWA_ALPHA);
+   }
 #endif
 
    return hwndframe;
@@ -8282,6 +8311,9 @@
          {
             MARGINS mar = {0};
 
+            if(cinfo)
+               mar = _dw_rect_to_margins(cinfo->rect);
+
             /* Remove Aero Glass */
             SetLayeredWindowAttributes(handle, _dw_transparencykey, 255, LWA_ALPHA);
             _DwmExtendFrameIntoClientArea(handle, &mar);