Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows bug: Update the window theme without taking into account the preferred theme. #479

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions windows/window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,21 +1020,12 @@ void WindowManager::SetOpacity(const flutter::EncodableMap& args) {
}

void WindowManager::SetBrightness(const flutter::EncodableMap& args) {
DWORD light_mode;
DWORD light_mode_size = sizeof(light_mode);
LSTATUS result =
RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD, nullptr,
&light_mode, &light_mode_size);

if (result == ERROR_SUCCESS) {
std::string brightness =
std::get<std::string>(args.at(flutter::EncodableValue("brightness")));
HWND hWnd = GetMainWindow();
BOOL enable_dark_mode = light_mode == 0 && brightness == "dark";
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE,
&enable_dark_mode, sizeof(enable_dark_mode));
}
std::string brightness =
std::get<std::string>(args.at(flutter::EncodableValue("brightness")));
HWND hWnd = GetMainWindow();
BOOL enable_dark_mode = brightness == "dark";
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE,
&enable_dark_mode, sizeof(enable_dark_mode));
}

void WindowManager::SetIgnoreMouseEvents(const flutter::EncodableMap& args) {
Expand Down
Loading