Mercurial > dwindows
comparison win/dw.c @ 1970:8cf330e1e331
Win: Basic dark mode support functioning and enabled, the title bar and menus and file dialogs now obey the system dark mode setting for Apps.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 02 Aug 2019 13:32:38 +0000 |
parents | 2322769acf88 |
children | 8e650172d8cf |
comparison
equal
deleted
inserted
replaced
1969:2322769acf88 | 1970:8cf330e1e331 |
---|---|
671 return NULL; | 671 return NULL; |
672 } | 672 } |
673 #endif | 673 #endif |
674 | 674 |
675 #ifdef AEROGLASS | 675 #ifdef AEROGLASS |
676 int _DW_DARK_MODE_ALLOWED = FALSE; | 676 int _DW_DARK_MODE_ALLOWED = TRUE; |
677 int _DW_DARK_MODE_SUPPORTED = FALSE; | 677 int _DW_DARK_MODE_SUPPORTED = FALSE; |
678 int _DW_DARK_MODE_ENABLED = FALSE; | 678 int _DW_DARK_MODE_ENABLED = FALSE; |
679 | 679 |
680 typedef enum IMMERSIVE_HC_CACHE_MODE | 680 typedef enum IMMERSIVE_HC_CACHE_MODE |
681 { | 681 { |
724 /* Make sure we were able to load all the Dark Mode functions */ | 724 /* Make sure we were able to load all the Dark Mode functions */ |
725 if(_OpenNcThemeData && _RefreshImmersiveColorPolicyState && _ShouldAppsUseDarkMode && _AllowDarkModeForWindow && | 725 if(_OpenNcThemeData && _RefreshImmersiveColorPolicyState && _ShouldAppsUseDarkMode && _AllowDarkModeForWindow && |
726 (_AllowDarkModeForApp || _SetPreferredAppMode) && _IsDarkModeAllowedForWindow && _DwmSetWindowAttribute) | 726 (_AllowDarkModeForApp || _SetPreferredAppMode) && _IsDarkModeAllowedForWindow && _DwmSetWindowAttribute) |
727 { | 727 { |
728 _DW_DARK_MODE_SUPPORTED = TRUE; | 728 _DW_DARK_MODE_SUPPORTED = TRUE; |
729 _AllowDarkModeForApp(TRUE); | 729 if(_AllowDarkModeForApp) |
730 _AllowDarkModeForApp(TRUE); | |
731 else | |
732 _SetPreferredAppMode(_AllowDark); | |
730 _RefreshImmersiveColorPolicyState(); | 733 _RefreshImmersiveColorPolicyState(); |
734 _DW_DARK_MODE_ENABLED = _ShouldAppsUseDarkMode() && !IsHighContrast(); | |
731 } | 735 } |
732 } | 736 } |
733 } | 737 } |
734 | 738 |
735 BOOL AllowDarkModeForWindow(HWND window, BOOL allow) | 739 BOOL AllowDarkModeForWindow(HWND window, BOOL allow) |
769 | 773 |
770 /* Call this on a window to apply the style */ | 774 /* Call this on a window to apply the style */ |
771 BOOL CALLBACK _dw_set_child_window_theme(HWND window, LPARAM lParam) | 775 BOOL CALLBACK _dw_set_child_window_theme(HWND window, LPARAM lParam) |
772 { | 776 { |
773 if(_DW_DARK_MODE_SUPPORTED) | 777 if(_DW_DARK_MODE_SUPPORTED) |
778 { | |
774 AllowDarkModeForWindow(window, _DW_DARK_MODE_ENABLED); | 779 AllowDarkModeForWindow(window, _DW_DARK_MODE_ENABLED); |
780 SendMessageW(window, WM_THEMECHANGED, 0, 0); | |
781 } | |
775 return TRUE; | 782 return TRUE; |
776 } | 783 } |
777 #endif | 784 #endif |
778 | 785 |
779 /* This function adds a signal handler callback into the linked list. | 786 /* This function adds a signal handler callback into the linked list. |
2303 } | 2310 } |
2304 break; | 2311 break; |
2305 case WM_SETTINGCHANGE: | 2312 case WM_SETTINGCHANGE: |
2306 { | 2313 { |
2307 if(_DW_DARK_MODE_SUPPORTED && IsColorSchemeChangeMessage(mp2)) | 2314 if(_DW_DARK_MODE_SUPPORTED && IsColorSchemeChangeMessage(mp2)) |
2308 SendMessageW(hWnd, WM_THEMECHANGED, 0, 0); | 2315 { |
2309 } | 2316 _DW_DARK_MODE_ENABLED = _ShouldAppsUseDarkMode() && !IsHighContrast(); |
2310 break; | 2317 |
2311 case WM_THEMECHANGED: | 2318 RefreshTitleBarThemeColor(hWnd); |
2312 { | 2319 _dw_set_child_window_theme(hWnd, 0); |
2313 if(_DW_DARK_MODE_SUPPORTED) | 2320 EnumChildWindows(hWnd, _dw_set_child_window_theme, 0); |
2314 { | |
2315 _AllowDarkModeForWindow(hWnd, _DW_DARK_MODE_ENABLED); | |
2316 if(GetParent(hWnd) == HWND_DESKTOP) | |
2317 RefreshTitleBarThemeColor(hWnd); | |
2318 } | 2321 } |
2319 } | 2322 } |
2320 break; | 2323 break; |
2321 #endif | 2324 #endif |
2322 #ifdef AEROGLASS1 | 2325 #ifdef AEROGLASS1 |
4367 int API dw_window_show(HWND handle) | 4370 int API dw_window_show(HWND handle) |
4368 { | 4371 { |
4369 int rc; | 4372 int rc; |
4370 RECT rect; | 4373 RECT rect; |
4371 | 4374 |
4372 /* Try to enable dark mode support if our OS supports it */ | 4375 #ifdef AEROGLASS |
4373 _dw_set_child_window_theme(handle, 0); | 4376 if(_DW_DARK_MODE_SUPPORTED) |
4374 EnumChildWindows(handle, _dw_set_child_window_theme, 0); | 4377 { |
4378 /* Try to enable dark mode support if our OS supports it */ | |
4379 _dw_set_child_window_theme(handle, 0); | |
4380 EnumChildWindows(handle, _dw_set_child_window_theme, 0); | |
4381 if(GetParent(handle) == HWND_DESKTOP) | |
4382 RefreshTitleBarThemeColor(handle); | |
4383 } | |
4384 #endif | |
4375 | 4385 |
4376 GetClientRect(handle, &rect); | 4386 GetClientRect(handle, &rect); |
4377 | 4387 |
4378 /* If the client area is 0x0 then call the autosize routine */ | 4388 /* If the client area is 0x0 then call the autosize routine */ |
4379 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0) | 4389 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0) |