Skip to content

Commit

Permalink
Merge pull request #231 from chewing/fix-default-value-light-theme
Browse files Browse the repository at this point in the history
fix: attempt to fix incorrect light theme detection
  • Loading branch information
kanru authored Dec 21, 2024
2 parents eb27a8a + 7953d4e commit dcd249b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
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

0 comments on commit dcd249b

Please sign in to comment.