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

Per-app Language Preferences 1.1 #1458

Merged
merged 3 commits into from
Jan 23, 2025
Merged

Per-app Language Preferences 1.1 #1458

merged 3 commits into from
Jan 23, 2025

Conversation

yezhiyi9670
Copy link
Contributor

The GetUserDefaultUILanguage is actually called very often in some apps such as explorer.exe. As I have observed, allocating the image path buffer and determining the language for each call can add much overhead. Now I choose to determine the language ID only once for each process at startup, and then return the pre-determined language ID for subsequent calls.

This approach seems to work fine, but may not be entirely correct. Please let me know if there is some better way of implementing this.

break;
}
if(S_OK == PathMatchSpecExW(filename_buf, glob, PMSF_MULTIPLE)) {
lang_id = Wh_GetIntSetting(L"programList[%d].langId", index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string is not freed with Wh_FreeStringSetting in this case. Note that you can also use WindhawkUtils::StringSetting to have it freed automatically.

@m417z
Copy link
Member

m417z commented Jan 23, 2025

This approach seems to work fine, but may not be entirely correct. Please let me know if there is some better way of implementing this.

It seems to be correct from a quick glance. An alternative approach you could use it determining the language in Wh_ModInit and Wh_ModSettingsChanged. Currently, you don't handle Wh_ModSettingsChanged at all, which means that the mod has to be disabled and re-enabled to apply the new settings.

@m417z m417z merged commit c2fe499 into ramensoftware:main Jan 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants