Mercurial > dwindows
comparison win/dw.c @ 2212:f903f7576e9d
Win: Use a zeroed out MARGINS struct when not using a "composited" or dark mode title bar Window.
When not composited or using the dark mode titlebar (drawing in the titlebar) with NCCALCSIZE
we should reset the client area to default by using a zeroed MARGINS. This fixes some display
issues introduced by some dark mode titlebar and always composite changes earlier this year.
Also added some debug code to help diagnose dark mode titlebar issues, enabed with DEBUG=Y
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 12 Dec 2020 14:18:46 +0000 |
parents | da33732f182d |
children | c60588f740ec |
comparison
equal
deleted
inserted
replaced
2211:9395c1efa98b | 2212:f903f7576e9d |
---|---|
2128 sprintf( buffer, "_dw_ischecked%d", id ); | 2128 sprintf( buffer, "_dw_ischecked%d", id ); |
2129 is_checked = DW_POINTER_TO_INT(dw_window_get_data(DW_HWND_OBJECT, buffer)); | 2129 is_checked = DW_POINTER_TO_INT(dw_window_get_data(DW_HWND_OBJECT, buffer)); |
2130 is_checked = (is_checked) ? DW_MIS_UNCHECKED : DW_MIS_CHECKED; | 2130 is_checked = (is_checked) ? DW_MIS_UNCHECKED : DW_MIS_CHECKED; |
2131 dw_menu_item_set_state( window, id, is_checked ); | 2131 dw_menu_item_set_state( window, id, is_checked ); |
2132 } | 2132 } |
2133 } | |
2134 | |
2135 void _dw_show_margins(HWND handle, MARGINS mar, int line) | |
2136 { | |
2137 #ifdef DEBUG | |
2138 char *title = dw_window_get_text(handle); | |
2139 dw_debug("_DwmExtendFrameIntoClientArea(\"%s\",%d,%d,%d,%d) line %d\n", title, | |
2140 mar.cxLeftWidth, mar.cxRightWidth, | |
2141 mar.cyTopHeight, mar.cyBottomHeight, line); | |
2142 dw_free(title); | |
2143 #endif | |
2133 } | 2144 } |
2134 | 2145 |
2135 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ | 2146 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ |
2136 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | 2147 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) |
2137 { | 2148 { |
2749 MARGINS mar = {0}; | 2760 MARGINS mar = {0}; |
2750 | 2761 |
2751 SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 255, LWA_ALPHA); | 2762 SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 255, LWA_ALPHA); |
2752 if(_DwmExtendFrameIntoClientArea) | 2763 if(_DwmExtendFrameIntoClientArea) |
2753 _DwmExtendFrameIntoClientArea(hWnd, &mar); | 2764 _DwmExtendFrameIntoClientArea(hWnd, &mar); |
2765 _dw_show_margins(hWnd, mar, __LINE__); | |
2754 } | 2766 } |
2755 /* If we have started compositing... */ | 2767 /* If we have started compositing... */ |
2756 else | 2768 else |
2757 { | 2769 { |
2758 MARGINS mar = {-1}; | 2770 MARGINS mar = {-1,-1,-1,-1}; |
2759 | 2771 |
2760 if(cinfo && (cinfo->style & DW_FCF_COMPOSITED)) | 2772 if(cinfo && (cinfo->style & DW_FCF_COMPOSITED)) |
2761 SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 0, LWA_COLORKEY); | 2773 SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 0, LWA_COLORKEY); |
2762 else | 2774 else |
2763 { | 2775 { |
2776 #ifdef DARK_MODE_TITLEBAR_MENU | |
2764 if(cinfo) | 2777 if(cinfo) |
2765 mar = _dw_rect_to_margins(cinfo->rect); | 2778 mar = _dw_rect_to_margins(cinfo->rect); |
2766 else | 2779 else |
2780 #endif | |
2767 memset(&mar, 0, sizeof(MARGINS)); | 2781 memset(&mar, 0, sizeof(MARGINS)); |
2768 SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 255, LWA_ALPHA); | 2782 SetLayeredWindowAttributes(hWnd, _dw_transparencykey, 255, LWA_ALPHA); |
2769 } | 2783 } |
2770 if(_DwmExtendFrameIntoClientArea) | 2784 if(_DwmExtendFrameIntoClientArea) |
2771 _DwmExtendFrameIntoClientArea(hWnd, &mar); | 2785 _DwmExtendFrameIntoClientArea(hWnd, &mar); |
2786 _dw_show_margins(hWnd, mar, __LINE__); | |
2772 } | 2787 } |
2773 } | 2788 } |
2774 break; | 2789 break; |
2775 case WM_SETTINGCHANGE: | 2790 case WM_SETTINGCHANGE: |
2776 { | 2791 { |
5853 if(hwndOwner) | 5868 if(hwndOwner) |
5854 SetParent(hwndframe, hwndOwner); | 5869 SetParent(hwndframe, hwndOwner); |
5855 | 5870 |
5856 #ifdef AEROGLASS | 5871 #ifdef AEROGLASS |
5857 /* Determine the borders of the default window frame */ | 5872 /* Determine the borders of the default window frame */ |
5858 AdjustWindowRectEx(&(newbox->cinfo.rect), flStyle, FALSE, 0); | 5873 AdjustWindowRectEx(&(newbox->cinfo.rect), flStyle, FALSE, flStyleEx); |
5874 #ifdef DEBUG | |
5875 dw_debug("AdjustWindowRectExt(%d,%d,%d,%d)\n", newbox->cinfo.rect.left, newbox->cinfo.rect.right, | |
5876 newbox->cinfo.rect.top, newbox->cinfo.rect.bottom); | |
5877 #endif | |
5878 newbox->cinfo.rect.top *= -1; | |
5859 newbox->cinfo.rect.left = newbox->cinfo.rect.right = newbox->cinfo.rect.bottom = 1; | 5879 newbox->cinfo.rect.left = newbox->cinfo.rect.right = newbox->cinfo.rect.bottom = 1; |
5860 newbox->cinfo.rect.top *= -1; | |
5861 | 5880 |
5862 if(flStyle & DW_FCF_COMPOSITED) | 5881 if(flStyle & DW_FCF_COMPOSITED) |
5863 { | 5882 { |
5864 /* Attempt to enable Aero glass background on the entire window */ | 5883 /* Attempt to enable Aero glass background on the entire window */ |
5865 if(_DwmExtendFrameIntoClientArea && _dw_composition) | 5884 if(_DwmExtendFrameIntoClientArea && _dw_composition) |
5866 { | 5885 { |
5867 MARGINS fullmar = { -1 }; | 5886 MARGINS fullmar = {-1,-1,-1,-1}; |
5868 | 5887 |
5869 _DwmExtendFrameIntoClientArea(hwndframe, &fullmar); | 5888 _DwmExtendFrameIntoClientArea(hwndframe, &fullmar); |
5889 _dw_show_margins(hwndframe, fullmar, __LINE__); | |
5870 } | 5890 } |
5871 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY); | 5891 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY); |
5872 } | 5892 } |
5873 else | 5893 else |
5874 { | 5894 { |
5875 if(_DwmExtendFrameIntoClientArea && _dw_composition) | 5895 if(_DwmExtendFrameIntoClientArea && _dw_composition) |
5876 { | 5896 { |
5877 MARGINS mar = _dw_rect_to_margins(newbox->cinfo.rect); | 5897 MARGINS mar = {0}; |
5898 | |
5899 #ifdef DARK_MODE_TITLEBAR_MENU | |
5900 mar = _dw_rect_to_margins(newbox->cinfo.rect); | |
5901 #endif | |
5878 | 5902 |
5879 _DwmExtendFrameIntoClientArea(hwndframe, &mar); | 5903 _DwmExtendFrameIntoClientArea(hwndframe, &mar); |
5904 _dw_show_margins(hwndframe, mar, __LINE__); | |
5880 } | 5905 } |
5881 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 255, LWA_ALPHA); | 5906 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 255, LWA_ALPHA); |
5882 } | 5907 } |
5883 #endif | 5908 #endif |
5884 | 5909 |
8504 #ifdef AEROGLASS | 8529 #ifdef AEROGLASS |
8505 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition) | 8530 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition) |
8506 { | 8531 { |
8507 if(style & DW_FCF_COMPOSITED) | 8532 if(style & DW_FCF_COMPOSITED) |
8508 { | 8533 { |
8509 MARGINS mar = {-1}; | 8534 MARGINS mar = {-1,-1,-1,-1}; |
8510 | 8535 |
8511 /* Attempt to enable Aero glass background on the entire window */ | 8536 /* Attempt to enable Aero glass background on the entire window */ |
8512 SetLayeredWindowAttributes(handle, _dw_transparencykey, 0, LWA_COLORKEY); | 8537 SetLayeredWindowAttributes(handle, _dw_transparencykey, 0, LWA_COLORKEY); |
8513 _DwmExtendFrameIntoClientArea(handle, &mar); | 8538 _DwmExtendFrameIntoClientArea(handle, &mar); |
8539 _dw_show_margins(handle, mar, __LINE__); | |
8514 } | 8540 } |
8515 else | 8541 else |
8516 { | 8542 { |
8517 MARGINS mar = {0}; | 8543 MARGINS mar = {0}; |
8518 | 8544 |
8545 #ifdef DARK_MODE_TITLEBAR_MENU | |
8519 if(cinfo) | 8546 if(cinfo) |
8520 mar = _dw_rect_to_margins(cinfo->rect); | 8547 mar = _dw_rect_to_margins(cinfo->rect); |
8548 #endif | |
8521 | 8549 |
8522 /* Remove Aero Glass */ | 8550 /* Remove Aero Glass */ |
8523 SetLayeredWindowAttributes(handle, _dw_transparencykey, 255, LWA_ALPHA); | 8551 SetLayeredWindowAttributes(handle, _dw_transparencykey, 255, LWA_ALPHA); |
8524 _DwmExtendFrameIntoClientArea(handle, &mar); | 8552 _DwmExtendFrameIntoClientArea(handle, &mar); |
8553 _dw_show_margins(handle, mar, __LINE__); | |
8525 } | 8554 } |
8526 } | 8555 } |
8527 #endif | 8556 #endif |
8528 } | 8557 } |
8529 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0) | 8558 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0) |