mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-06 06:09:50 +00:00
Compare commits
1 Commits
v1.24.2812
...
dev/lhecke
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38e2a16607 |
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include <dwmapi.h>
|
||||
#include <uxtheme.h>
|
||||
|
||||
#include "../inc/conint.h"
|
||||
|
||||
using namespace Microsoft::Console::Internal;
|
||||
@@ -21,7 +24,27 @@ using namespace Microsoft::Console::Internal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT Theming::TrySetDarkMode(HWND /*hwnd*/) noexcept
|
||||
[[nodiscard]] HRESULT Theming::TrySetDarkMode(HWND hwnd) noexcept
|
||||
{
|
||||
return S_FALSE;
|
||||
static constexpr auto subKey = LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize)";
|
||||
static constexpr auto get = [](HKEY key, const wchar_t* value, DWORD& data) {
|
||||
DWORD dataType = 0;
|
||||
DWORD size = sizeof(data);
|
||||
return RegGetValueW(key, subKey, value, RRF_RT_REG_DWORD, &dataType, &data, &size);
|
||||
};
|
||||
|
||||
// This is the approach that WinUI3 used in its initial source code release at the time of writing.
|
||||
DWORD useLightTheme = 0;
|
||||
if (get(HKEY_CURRENT_USER, L"AppsUseLightTheme", useLightTheme) != ERROR_SUCCESS)
|
||||
{
|
||||
if (get(HKEY_LOCAL_MACHINE, L"SystemUsesLightTheme", useLightTheme) != ERROR_SUCCESS)
|
||||
{
|
||||
useLightTheme = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const BOOL useDarkMode = useLightTheme == 0;
|
||||
LOG_IF_FAILED(SetWindowTheme(hwnd, useLightTheme ? L"" : L"DarkMode_Explorer", nullptr));
|
||||
LOG_IF_FAILED(DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &useDarkMode, sizeof(useDarkMode)));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#include "precomp.h"
|
||||
#include "inc/ThemeUtils.h"
|
||||
|
||||
namespace Microsoft::Console::ThemeUtils
|
||||
{
|
||||
// Routine Description:
|
||||
// - Attempts to enable/disable the dark mode on the frame of a window.
|
||||
// Arguments:
|
||||
// - hwnd: handle to the window to change
|
||||
// - enabled: whether to enable or not the dark mode on the window's frame
|
||||
// Return Value:
|
||||
// - S_OK or suitable HRESULT from DWM engines.
|
||||
[[nodiscard]] HRESULT SetWindowFrameDarkMode(HWND /* hwnd */, bool /* enabled */) noexcept
|
||||
{
|
||||
// TODO:GH #3425 implement the new DWM API and change
|
||||
// src/interactivity/win32/windowtheme.cpp to use it.
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace Microsoft::Console::ThemeUtils
|
||||
{
|
||||
[[nodiscard]] HRESULT SetWindowFrameDarkMode(HWND hwnd, bool enabled) noexcept;
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
<ClCompile Include="..\GlyphWidth.cpp" />
|
||||
<ClCompile Include="..\ScreenInfoUiaProviderBase.cpp" />
|
||||
<ClCompile Include="..\sgrStack.cpp" />
|
||||
<ClCompile Include="..\ThemeUtils.cpp" />
|
||||
<ClCompile Include="..\UiaTextRangeBase.cpp" />
|
||||
<ClCompile Include="..\UiaTracing.cpp" />
|
||||
<ClCompile Include="..\TermControlUiaTextRange.cpp" />
|
||||
@@ -38,7 +37,6 @@
|
||||
<ClInclude Include="..\inc\GlyphWidth.hpp" />
|
||||
<ClInclude Include="..\inc\IInputEvent.hpp" />
|
||||
<ClInclude Include="..\inc\sgrStack.hpp" />
|
||||
<ClInclude Include="..\inc\ThemeUtils.h" />
|
||||
<ClInclude Include="..\inc\utils.hpp" />
|
||||
<ClInclude Include="..\inc\Viewport.hpp" />
|
||||
<ClInclude Include="..\IUiaEventDispatcher.h" />
|
||||
|
||||
@@ -42,9 +42,6 @@
|
||||
<ClCompile Include="..\UiaTextRangeBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ThemeUtils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sgrStack.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -107,9 +104,6 @@
|
||||
<ClInclude Include="..\inc\utils.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\inc\ThemeUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\inc\sgrStack.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -35,7 +35,6 @@ SOURCES= \
|
||||
..\convert.cpp \
|
||||
..\colorTable.cpp \
|
||||
..\utils.cpp \
|
||||
..\ThemeUtils.cpp \
|
||||
..\ScreenInfoUiaProviderBase.cpp \
|
||||
..\sgrStack.cpp \
|
||||
..\UiaTextRangeBase.cpp \
|
||||
|
||||
Reference in New Issue
Block a user