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

fix: attempt to fix incorrect light theme detection #231

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ charset = "utf-8"
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_style = space
indent_size = 4

[*.md]
indent_style = space
Expand Down
35 changes: 19 additions & 16 deletions ChewingTextService/ChewingTextService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,23 +940,26 @@ void TextService::hideMessage() {
}

bool TextService::isLightTheme() {
DWORD value = 0;
DWORD len = sizeof(value);
LSTATUS st = RegGetValueW(
HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
L"AppsUseLightTheme",
RRF_RT_REG_DWORD,
nullptr,
&value,
&len
);
if (st != ERROR_SUCCESS) {
// assume light theme
return true;
}
DWORD value = 1;
DWORD dataSize = sizeof(value);

LSTATUS result = RegGetValueW(
HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
L"AppsUseLightTheme",
RRF_RT_DWORD,
nullptr,
&value,
&dataSize
);

if (result != ERROR_SUCCESS) {
OutputDebugStringW(L"Determine isLightTheme failed, fallback to light theme");
return true;
}

// 0 = dark theme, 1 = light theme
return value > 0;
return value > 0;
}

void TextService::updateLangButtons() {
Expand Down