Revert "[Windows] Use dark title bar on dark system theme" (#110890)
This commit is contained in:
parent
22c8e79cc1
commit
c075ef058c
@ -33,7 +33,6 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
|||||||
# Add dependency libraries and include directories. Add any application-specific
|
# Add dependency libraries and include directories. Add any application-specific
|
||||||
# dependencies here.
|
# dependencies here.
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
|
|
||||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Run the Flutter tool portions of the build. This must not be removed.
|
# Run the Flutter tool portions of the build. This must not be removed.
|
||||||
|
@ -4,28 +4,14 @@
|
|||||||
|
|
||||||
#include "win32_window.h"
|
#include "win32_window.h"
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <flutter_windows.h>
|
#include <flutter_windows.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Window attribute that enables dark mode window decorations.
|
|
||||||
///
|
|
||||||
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
||||||
/// version 10.0.22000.0.
|
|
||||||
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||||
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
||||||
|
|
||||||
// The number of Win32Window objects that currently exist.
|
// The number of Win32Window objects that currently exist.
|
||||||
static int g_active_window_count = 0;
|
static int g_active_window_count = 0;
|
||||||
|
|
||||||
@ -144,8 +130,6 @@ bool Win32Window::Create(const std::wstring& title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTheme(window);
|
|
||||||
|
|
||||||
return OnCreate();
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +196,6 @@ Win32Window::MessageHandler(HWND hwnd,
|
|||||||
SetFocus(child_content_);
|
SetFocus(child_content_);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
|
||||||
UpdateTheme(hwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||||
@ -271,17 +251,3 @@ bool Win32Window::OnCreate() {
|
|||||||
void Win32Window::OnDestroy() {
|
void Win32Window::OnDestroy() {
|
||||||
// No-op; provided for subclasses.
|
// No-op; provided for subclasses.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::UpdateTheme(HWND const window) {
|
|
||||||
DWORD light_mode;
|
|
||||||
DWORD light_mode_size = sizeof(light_mode);
|
|
||||||
LONG result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
|
|
||||||
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD,
|
|
||||||
nullptr, &light_mode, &light_mode_size);
|
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
|
||||||
BOOL enable_dark_mode = light_mode == 0;
|
|
||||||
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
||||||
&enable_dark_mode, sizeof(enable_dark_mode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -91,9 +91,6 @@ class Win32Window {
|
|||||||
// Retrieves a class instance pointer for |window|
|
// Retrieves a class instance pointer for |window|
|
||||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||||
|
|
||||||
// Update the window frame's theme to match the system theme.
|
|
||||||
static void UpdateTheme(HWND const window);
|
|
||||||
|
|
||||||
bool quit_on_close_ = false;
|
bool quit_on_close_ = false;
|
||||||
|
|
||||||
// window handle for top level window.
|
// window handle for top level window.
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_driver/driver_extension.dart';
|
import 'package:flutter_driver/driver_extension.dart';
|
||||||
|
|
||||||
import 'windows.dart';
|
|
||||||
|
|
||||||
void drawHelloWorld() {
|
void drawHelloWorld() {
|
||||||
final ui.ParagraphStyle style = ui.ParagraphStyle();
|
final ui.ParagraphStyle style = ui.ParagraphStyle();
|
||||||
final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(style)
|
final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(style)
|
||||||
@ -31,38 +30,33 @@ void drawHelloWorld() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
// Create a completer to send the window visibility result back to the
|
// Create a completer to send the result back to the integration test.
|
||||||
// integration test.
|
final Completer<String> completer = Completer<String>();
|
||||||
final Completer<String> visibilityCompleter = Completer<String>();
|
enableFlutterDriverExtension(handler: (String? message) => completer.future);
|
||||||
enableFlutterDriverExtension(handler: (String? message) async {
|
|
||||||
if (message == 'verifyWindowVisibility') {
|
|
||||||
return visibilityCompleter.future;
|
|
||||||
} else if (message == 'verifyTheme') {
|
|
||||||
final bool app = await isAppDarkModeEnabled();
|
|
||||||
final bool system = await isSystemDarkModeEnabled();
|
|
||||||
|
|
||||||
return (app == system)
|
|
||||||
? 'success'
|
|
||||||
: 'error: app dark mode ($app) does not match system dark mode ($system)';
|
|
||||||
}
|
|
||||||
|
|
||||||
throw 'Unrecognized message: $message';
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (await isWindowVisible()) {
|
const MethodChannel methodChannel =
|
||||||
|
MethodChannel('tests.flutter.dev/windows_startup_test');
|
||||||
|
|
||||||
|
final bool? visible = await methodChannel.invokeMethod('isWindowVisible');
|
||||||
|
if (visible == null || visible == true) {
|
||||||
throw 'Window should be hidden at startup';
|
throw 'Window should be hidden at startup';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool firstFrame = true;
|
bool firstFrame = true;
|
||||||
ui.PlatformDispatcher.instance.onBeginFrame = (Duration duration) async {
|
ui.PlatformDispatcher.instance.onBeginFrame = (Duration duration) async {
|
||||||
if (await isWindowVisible()) {
|
final bool? visible = await methodChannel.invokeMethod('isWindowVisible');
|
||||||
|
if (visible == null) {
|
||||||
|
throw 'Method channel unavailable';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visible == true) {
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
throw 'Window should be hidden on first frame';
|
throw 'Window should be hidden on first frame';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!visibilityCompleter.isCompleted) {
|
if (!completer.isCompleted) {
|
||||||
visibilityCompleter.complete('success');
|
completer.complete('success');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +68,7 @@ void main() async {
|
|||||||
|
|
||||||
ui.PlatformDispatcher.instance.scheduleFrame();
|
ui.PlatformDispatcher.instance.scheduleFrame();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
visibilityCompleter.completeError(e);
|
completer.completeError(e);
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
const MethodChannel _kMethodChannel =
|
|
||||||
MethodChannel('tests.flutter.dev/windows_startup_test');
|
|
||||||
|
|
||||||
/// Returns true if the application's window is visible.
|
|
||||||
Future<bool> isWindowVisible() async {
|
|
||||||
final bool? visible = await _kMethodChannel.invokeMethod<bool?>('isWindowVisible');
|
|
||||||
if (visible == null) {
|
|
||||||
throw 'Method channel unavailable';
|
|
||||||
}
|
|
||||||
|
|
||||||
return visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if the app's dark mode is enabled.
|
|
||||||
Future<bool> isAppDarkModeEnabled() async {
|
|
||||||
final bool? enabled = await _kMethodChannel.invokeMethod<bool?>('isAppDarkModeEnabled');
|
|
||||||
if (enabled == null) {
|
|
||||||
throw 'Method channel unavailable';
|
|
||||||
}
|
|
||||||
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if the operating system dark mode setting is enabled.
|
|
||||||
Future<bool> isSystemDarkModeEnabled() async {
|
|
||||||
final bool? enabled = await _kMethodChannel.invokeMethod<bool?>('isSystemDarkModeEnabled');
|
|
||||||
if (enabled == null) {
|
|
||||||
throw 'Method channel unavailable';
|
|
||||||
}
|
|
||||||
|
|
||||||
return enabled;
|
|
||||||
}
|
|
@ -8,16 +8,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
|||||||
void main() {
|
void main() {
|
||||||
test('Windows app starts and draws frame', () async {
|
test('Windows app starts and draws frame', () async {
|
||||||
final FlutterDriver driver = await FlutterDriver.connect(printCommunication: true);
|
final FlutterDriver driver = await FlutterDriver.connect(printCommunication: true);
|
||||||
final String result = await driver.requestData('verifyWindowVisibility');
|
final String result = await driver.requestData(null);
|
||||||
|
|
||||||
expect(result, equals('success'));
|
|
||||||
|
|
||||||
await driver.close();
|
|
||||||
}, timeout: Timeout.none);
|
|
||||||
|
|
||||||
test('Windows app theme matches system theme', () async {
|
|
||||||
final FlutterDriver driver = await FlutterDriver.connect(printCommunication: true);
|
|
||||||
final String result = await driver.requestData('verifyTheme');
|
|
||||||
|
|
||||||
expect(result, equals('success'));
|
expect(result, equals('success'));
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
|||||||
# Add dependency libraries and include directories. Add any application-specific
|
# Add dependency libraries and include directories. Add any application-specific
|
||||||
# dependencies here.
|
# dependencies here.
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
|
|
||||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Run the Flutter tool portions of the build. This must not be removed.
|
# Run the Flutter tool portions of the build. This must not be removed.
|
||||||
|
@ -7,25 +7,11 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <flutter/method_channel.h>
|
#include <flutter/method_channel.h>
|
||||||
#include <flutter/standard_method_codec.h>
|
#include <flutter/standard_method_codec.h>
|
||||||
|
|
||||||
#include "flutter/generated_plugin_registrant.h"
|
#include "flutter/generated_plugin_registrant.h"
|
||||||
|
|
||||||
/// Window attribute that enables dark mode window decorations.
|
|
||||||
///
|
|
||||||
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
||||||
/// version 10.0.22000.0.
|
|
||||||
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
||||||
|
|
||||||
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
|
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
|
||||||
: project_(project) {}
|
: project_(project) {}
|
||||||
|
|
||||||
@ -64,38 +50,11 @@ bool FlutterWindow::OnCreate() {
|
|||||||
&flutter::StandardMethodCodec::GetInstance());
|
&flutter::StandardMethodCodec::GetInstance());
|
||||||
|
|
||||||
channel.SetMethodCallHandler(
|
channel.SetMethodCallHandler(
|
||||||
[&](const flutter::MethodCall<>& call,
|
[](const flutter::MethodCall<>& call,
|
||||||
std::unique_ptr<flutter::MethodResult<>> result) {
|
std::unique_ptr<flutter::MethodResult<>> result) {
|
||||||
std::string method = call.method_name();
|
std::scoped_lock lock(visible_mutex);
|
||||||
|
if (call.method_name() == "isWindowVisible") {
|
||||||
if (method == "isWindowVisible") {
|
|
||||||
std::scoped_lock lock(visible_mutex);
|
|
||||||
result->Success(visible);
|
result->Success(visible);
|
||||||
} else if (method == "isAppDarkModeEnabled") {
|
|
||||||
BOOL enabled;
|
|
||||||
HRESULT hr = DwmGetWindowAttribute(GetHandle(),
|
|
||||||
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
||||||
&enabled, sizeof(enabled));
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
result->Success((bool)enabled);
|
|
||||||
} else {
|
|
||||||
result->Error("error", "Received result handle " + hr);
|
|
||||||
}
|
|
||||||
} else if (method == "isSystemDarkModeEnabled") {
|
|
||||||
DWORD data;
|
|
||||||
DWORD data_size = sizeof(data);
|
|
||||||
LONG status = RegGetValue(HKEY_CURRENT_USER,
|
|
||||||
kGetPreferredBrightnessRegKey,
|
|
||||||
kGetPreferredBrightnessRegValue,
|
|
||||||
RRF_RT_REG_DWORD, nullptr, &data, &data_size);
|
|
||||||
|
|
||||||
if (status == ERROR_SUCCESS) {
|
|
||||||
// Preferred brightness is 0 if dark mode is enabled,
|
|
||||||
// otherwise non-zero.
|
|
||||||
result->Success(data == 0);
|
|
||||||
} else {
|
|
||||||
result->Error("error", "Received status " + status);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
result->NotImplemented();
|
result->NotImplemented();
|
||||||
}
|
}
|
||||||
|
@ -4,28 +4,14 @@
|
|||||||
|
|
||||||
#include "win32_window.h"
|
#include "win32_window.h"
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <flutter_windows.h>
|
#include <flutter_windows.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Window attribute that enables dark mode window decorations.
|
|
||||||
///
|
|
||||||
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
||||||
/// version 10.0.22000.0.
|
|
||||||
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||||
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
||||||
|
|
||||||
// The number of Win32Window objects that currently exist.
|
// The number of Win32Window objects that currently exist.
|
||||||
static int g_active_window_count = 0;
|
static int g_active_window_count = 0;
|
||||||
|
|
||||||
@ -144,8 +130,6 @@ bool Win32Window::Create(const std::wstring& title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTheme(window);
|
|
||||||
|
|
||||||
return OnCreate();
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +196,6 @@ Win32Window::MessageHandler(HWND hwnd,
|
|||||||
SetFocus(child_content_);
|
SetFocus(child_content_);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
|
||||||
UpdateTheme(hwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||||
@ -271,17 +251,3 @@ bool Win32Window::OnCreate() {
|
|||||||
void Win32Window::OnDestroy() {
|
void Win32Window::OnDestroy() {
|
||||||
// No-op; provided for subclasses.
|
// No-op; provided for subclasses.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::UpdateTheme(HWND const window) {
|
|
||||||
DWORD light_mode;
|
|
||||||
DWORD light_mode_size = sizeof(light_mode);
|
|
||||||
LONG result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
|
|
||||||
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD,
|
|
||||||
nullptr, &light_mode, &light_mode_size);
|
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
|
||||||
BOOL enable_dark_mode = light_mode == 0;
|
|
||||||
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
||||||
&enable_dark_mode, sizeof(enable_dark_mode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -91,9 +91,6 @@ class Win32Window {
|
|||||||
// Retrieves a class instance pointer for |window|
|
// Retrieves a class instance pointer for |window|
|
||||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||||
|
|
||||||
// Update the window frame's theme to match the system theme.
|
|
||||||
static void UpdateTheme(HWND const window);
|
|
||||||
|
|
||||||
bool quit_on_close_ = false;
|
bool quit_on_close_ = false;
|
||||||
|
|
||||||
// window handle for top level window.
|
// window handle for top level window.
|
||||||
|
@ -33,7 +33,6 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
|||||||
# Add dependency libraries and include directories. Add any application-specific
|
# Add dependency libraries and include directories. Add any application-specific
|
||||||
# dependencies here.
|
# dependencies here.
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
|
|
||||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Run the Flutter tool portions of the build. This must not be removed.
|
# Run the Flutter tool portions of the build. This must not be removed.
|
||||||
|
@ -4,28 +4,14 @@
|
|||||||
|
|
||||||
#include "win32_window.h"
|
#include "win32_window.h"
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <flutter_windows.h>
|
#include <flutter_windows.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Window attribute that enables dark mode window decorations.
|
|
||||||
///
|
|
||||||
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
||||||
/// version 10.0.22000.0.
|
|
||||||
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||||
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
||||||
|
|
||||||
// The number of Win32Window objects that currently exist.
|
// The number of Win32Window objects that currently exist.
|
||||||
static int g_active_window_count = 0;
|
static int g_active_window_count = 0;
|
||||||
|
|
||||||
@ -144,8 +130,6 @@ bool Win32Window::Create(const std::wstring& title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTheme(window);
|
|
||||||
|
|
||||||
return OnCreate();
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +196,6 @@ Win32Window::MessageHandler(HWND hwnd,
|
|||||||
SetFocus(child_content_);
|
SetFocus(child_content_);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
|
||||||
UpdateTheme(hwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||||
@ -271,17 +251,3 @@ bool Win32Window::OnCreate() {
|
|||||||
void Win32Window::OnDestroy() {
|
void Win32Window::OnDestroy() {
|
||||||
// No-op; provided for subclasses.
|
// No-op; provided for subclasses.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::UpdateTheme(HWND const window) {
|
|
||||||
DWORD light_mode;
|
|
||||||
DWORD light_mode_size = sizeof(light_mode);
|
|
||||||
LONG result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
|
|
||||||
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD,
|
|
||||||
nullptr, &light_mode, &light_mode_size);
|
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
|
||||||
BOOL enable_dark_mode = light_mode == 0;
|
|
||||||
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
||||||
&enable_dark_mode, sizeof(enable_dark_mode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -91,9 +91,6 @@ class Win32Window {
|
|||||||
// Retrieves a class instance pointer for |window|
|
// Retrieves a class instance pointer for |window|
|
||||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||||
|
|
||||||
// Update the window frame's theme to match the system theme.
|
|
||||||
static void UpdateTheme(HWND const window);
|
|
||||||
|
|
||||||
bool quit_on_close_ = false;
|
bool quit_on_close_ = false;
|
||||||
|
|
||||||
// window handle for top level window.
|
// window handle for top level window.
|
||||||
|
@ -33,7 +33,6 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
|||||||
# Add dependency libraries and include directories. Add any application-specific
|
# Add dependency libraries and include directories. Add any application-specific
|
||||||
# dependencies here.
|
# dependencies here.
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
|
|
||||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Run the Flutter tool portions of the build. This must not be removed.
|
# Run the Flutter tool portions of the build. This must not be removed.
|
||||||
|
@ -4,28 +4,14 @@
|
|||||||
|
|
||||||
#include "win32_window.h"
|
#include "win32_window.h"
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <flutter_windows.h>
|
#include <flutter_windows.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Window attribute that enables dark mode window decorations.
|
|
||||||
///
|
|
||||||
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
||||||
/// version 10.0.22000.0.
|
|
||||||
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||||
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
||||||
|
|
||||||
// The number of Win32Window objects that currently exist.
|
// The number of Win32Window objects that currently exist.
|
||||||
static int g_active_window_count = 0;
|
static int g_active_window_count = 0;
|
||||||
|
|
||||||
@ -144,8 +130,6 @@ bool Win32Window::Create(const std::wstring& title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTheme(window);
|
|
||||||
|
|
||||||
return OnCreate();
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +196,6 @@ Win32Window::MessageHandler(HWND hwnd,
|
|||||||
SetFocus(child_content_);
|
SetFocus(child_content_);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
|
||||||
UpdateTheme(hwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||||
@ -271,17 +251,3 @@ bool Win32Window::OnCreate() {
|
|||||||
void Win32Window::OnDestroy() {
|
void Win32Window::OnDestroy() {
|
||||||
// No-op; provided for subclasses.
|
// No-op; provided for subclasses.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::UpdateTheme(HWND const window) {
|
|
||||||
DWORD light_mode;
|
|
||||||
DWORD light_mode_size = sizeof(light_mode);
|
|
||||||
LONG result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
|
|
||||||
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD,
|
|
||||||
nullptr, &light_mode, &light_mode_size);
|
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
|
||||||
BOOL enable_dark_mode = light_mode == 0;
|
|
||||||
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
||||||
&enable_dark_mode, sizeof(enable_dark_mode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -91,9 +91,6 @@ class Win32Window {
|
|||||||
// Retrieves a class instance pointer for |window|
|
// Retrieves a class instance pointer for |window|
|
||||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||||
|
|
||||||
// Update the window frame's theme to match the system theme.
|
|
||||||
static void UpdateTheme(HWND const window);
|
|
||||||
|
|
||||||
bool quit_on_close_ = false;
|
bool quit_on_close_ = false;
|
||||||
|
|
||||||
// window handle for top level window.
|
// window handle for top level window.
|
||||||
|
@ -33,7 +33,6 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
|||||||
# Add dependency libraries and include directories. Add any application-specific
|
# Add dependency libraries and include directories. Add any application-specific
|
||||||
# dependencies here.
|
# dependencies here.
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
|
|
||||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Run the Flutter tool portions of the build. This must not be removed.
|
# Run the Flutter tool portions of the build. This must not be removed.
|
||||||
|
@ -4,28 +4,14 @@
|
|||||||
|
|
||||||
#include "win32_window.h"
|
#include "win32_window.h"
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <flutter_windows.h>
|
#include <flutter_windows.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Window attribute that enables dark mode window decorations.
|
|
||||||
///
|
|
||||||
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
||||||
/// version 10.0.22000.0.
|
|
||||||
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||||
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
||||||
|
|
||||||
// The number of Win32Window objects that currently exist.
|
// The number of Win32Window objects that currently exist.
|
||||||
static int g_active_window_count = 0;
|
static int g_active_window_count = 0;
|
||||||
|
|
||||||
@ -95,8 +81,6 @@ const wchar_t* WindowClassRegistrar::GetWindowClass() {
|
|||||||
window_class.cbClsExtra = 0;
|
window_class.cbClsExtra = 0;
|
||||||
window_class.cbWndExtra = 0;
|
window_class.cbWndExtra = 0;
|
||||||
window_class.hInstance = GetModuleHandle(nullptr);
|
window_class.hInstance = GetModuleHandle(nullptr);
|
||||||
window_class.hIcon =
|
|
||||||
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
|
|
||||||
window_class.hbrBackground = 0;
|
window_class.hbrBackground = 0;
|
||||||
window_class.lpszMenuName = nullptr;
|
window_class.lpszMenuName = nullptr;
|
||||||
window_class.lpfnWndProc = Win32Window::WndProc;
|
window_class.lpfnWndProc = Win32Window::WndProc;
|
||||||
@ -111,9 +95,7 @@ void WindowClassRegistrar::UnregisterWindowClass() {
|
|||||||
class_registered_ = false;
|
class_registered_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Win32Window::Win32Window() {
|
Win32Window::Win32Window() { ++g_active_window_count; }
|
||||||
++g_active_window_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
Win32Window::~Win32Window() {
|
Win32Window::~Win32Window() {
|
||||||
--g_active_window_count;
|
--g_active_window_count;
|
||||||
@ -144,8 +126,6 @@ bool Win32Window::Create(const std::wstring& title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTheme(window);
|
|
||||||
|
|
||||||
return OnCreate();
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +134,7 @@ bool Win32Window::Show() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
LRESULT CALLBACK Win32Window::WndProc(HWND const window,
|
LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message,
|
||||||
UINT const message,
|
|
||||||
WPARAM const wparam,
|
WPARAM const wparam,
|
||||||
LPARAM const lparam) noexcept {
|
LPARAM const lparam) noexcept {
|
||||||
if (message == WM_NCCREATE) {
|
if (message == WM_NCCREATE) {
|
||||||
@ -174,9 +153,7 @@ LRESULT CALLBACK Win32Window::WndProc(HWND const window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LRESULT
|
LRESULT
|
||||||
Win32Window::MessageHandler(HWND hwnd,
|
Win32Window::MessageHandler(HWND hwnd, UINT const message, WPARAM const wparam,
|
||||||
UINT const message,
|
|
||||||
WPARAM const wparam,
|
|
||||||
LPARAM const lparam) noexcept {
|
LPARAM const lparam) noexcept {
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
@ -212,10 +189,6 @@ Win32Window::MessageHandler(HWND hwnd,
|
|||||||
SetFocus(child_content_);
|
SetFocus(child_content_);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
|
||||||
UpdateTheme(hwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||||
@ -255,9 +228,7 @@ RECT Win32Window::GetClientArea() {
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND Win32Window::GetHandle() {
|
HWND Win32Window::GetHandle() { return window_handle_; }
|
||||||
return window_handle_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Win32Window::SetQuitOnClose(bool quit_on_close) {
|
void Win32Window::SetQuitOnClose(bool quit_on_close) {
|
||||||
quit_on_close_ = quit_on_close;
|
quit_on_close_ = quit_on_close;
|
||||||
@ -271,17 +242,3 @@ bool Win32Window::OnCreate() {
|
|||||||
void Win32Window::OnDestroy() {
|
void Win32Window::OnDestroy() {
|
||||||
// No-op; provided for subclasses.
|
// No-op; provided for subclasses.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::UpdateTheme(HWND const window) {
|
|
||||||
DWORD light_mode;
|
|
||||||
DWORD light_mode_size = sizeof(light_mode);
|
|
||||||
LONG result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
|
|
||||||
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD,
|
|
||||||
nullptr, &light_mode, &light_mode_size);
|
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
|
||||||
BOOL enable_dark_mode = light_mode == 0;
|
|
||||||
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
||||||
&enable_dark_mode, sizeof(enable_dark_mode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -63,8 +63,7 @@ class Win32Window {
|
|||||||
// Processes and route salient window messages for mouse handling,
|
// Processes and route salient window messages for mouse handling,
|
||||||
// size change and DPI. Delegates handling of these to member overloads that
|
// size change and DPI. Delegates handling of these to member overloads that
|
||||||
// inheriting classes can handle.
|
// inheriting classes can handle.
|
||||||
virtual LRESULT MessageHandler(HWND window,
|
virtual LRESULT MessageHandler(HWND window, UINT const message,
|
||||||
UINT const message,
|
|
||||||
WPARAM const wparam,
|
WPARAM const wparam,
|
||||||
LPARAM const lparam) noexcept;
|
LPARAM const lparam) noexcept;
|
||||||
|
|
||||||
@ -83,17 +82,13 @@ class Win32Window {
|
|||||||
// non-client DPI scaling so that the non-client area automatically
|
// non-client DPI scaling so that the non-client area automatically
|
||||||
// responsponds to changes in DPI. All other messages are handled by
|
// responsponds to changes in DPI. All other messages are handled by
|
||||||
// MessageHandler.
|
// MessageHandler.
|
||||||
static LRESULT CALLBACK WndProc(HWND const window,
|
static LRESULT CALLBACK WndProc(HWND const window, UINT const message,
|
||||||
UINT const message,
|
|
||||||
WPARAM const wparam,
|
WPARAM const wparam,
|
||||||
LPARAM const lparam) noexcept;
|
LPARAM const lparam) noexcept;
|
||||||
|
|
||||||
// Retrieves a class instance pointer for |window|
|
// Retrieves a class instance pointer for |window|
|
||||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||||
|
|
||||||
// Update the window frame's theme to match the system theme.
|
|
||||||
static void UpdateTheme(HWND const window);
|
|
||||||
|
|
||||||
bool quit_on_close_ = false;
|
bool quit_on_close_ = false;
|
||||||
|
|
||||||
// window handle for top level window.
|
// window handle for top level window.
|
||||||
|
@ -33,7 +33,6 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
|||||||
# Add dependency libraries and include directories. Add any application-specific
|
# Add dependency libraries and include directories. Add any application-specific
|
||||||
# dependencies here.
|
# dependencies here.
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||||
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
|
|
||||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Run the Flutter tool portions of the build. This must not be removed.
|
# Run the Flutter tool portions of the build. This must not be removed.
|
||||||
|
@ -1,27 +1,13 @@
|
|||||||
#include "win32_window.h"
|
#include "win32_window.h"
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <flutter_windows.h>
|
#include <flutter_windows.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Window attribute that enables dark mode window decorations.
|
|
||||||
///
|
|
||||||
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
||||||
/// version 10.0.22000.0.
|
|
||||||
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||||
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
||||||
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
||||||
|
|
||||||
// The number of Win32Window objects that currently exist.
|
// The number of Win32Window objects that currently exist.
|
||||||
static int g_active_window_count = 0;
|
static int g_active_window_count = 0;
|
||||||
|
|
||||||
@ -140,8 +126,6 @@ bool Win32Window::Create(const std::wstring& title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTheme(window);
|
|
||||||
|
|
||||||
return OnCreate();
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,10 +192,6 @@ Win32Window::MessageHandler(HWND hwnd,
|
|||||||
SetFocus(child_content_);
|
SetFocus(child_content_);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
|
||||||
UpdateTheme(hwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||||
@ -267,17 +247,3 @@ bool Win32Window::OnCreate() {
|
|||||||
void Win32Window::OnDestroy() {
|
void Win32Window::OnDestroy() {
|
||||||
// No-op; provided for subclasses.
|
// No-op; provided for subclasses.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::UpdateTheme(HWND const window) {
|
|
||||||
DWORD light_mode;
|
|
||||||
DWORD light_mode_size = sizeof(light_mode);
|
|
||||||
LONG result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
|
|
||||||
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD,
|
|
||||||
nullptr, &light_mode, &light_mode_size);
|
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
|
||||||
BOOL enable_dark_mode = light_mode == 0;
|
|
||||||
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
||||||
&enable_dark_mode, sizeof(enable_dark_mode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -87,9 +87,6 @@ class Win32Window {
|
|||||||
// Retrieves a class instance pointer for |window|
|
// Retrieves a class instance pointer for |window|
|
||||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||||
|
|
||||||
// Update the window frame's theme to match the system theme.
|
|
||||||
static void UpdateTheme(HWND const window);
|
|
||||||
|
|
||||||
bool quit_on_close_ = false;
|
bool quit_on_close_ = false;
|
||||||
|
|
||||||
// window handle for top level window.
|
// window handle for top level window.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user