fix: activate Windows IME profile for session scope

This commit is contained in:
millionart committed 2026-05-01 21:23:24 +08:00
1 parent e8bc4af8eb
commit 57a562c253
2 files changed
+10 -6

No files matched your search

@@ -3,7 +3,9 @@ use std::time::Duration;
use crate::windows_ime_protocol::ImeSubmitStatus;
pub const IME_CLIENT_WAIT_TIMEOUT: Duration = Duration::from_millis(700);
pub const IME_SUBMIT_TIMEOUT: Duration = Duration::from_millis(900);
// Must exceed the IME DLL owner-thread commit timeout (3000 ms), otherwise Rust
// can fall back while the DLL later commits and duplicates insertion.
pub const IME_SUBMIT_TIMEOUT: Duration = Duration::from_millis(3800);
const IME_PIPE_RETRY_INTERVAL: Duration = Duration::from_millis(25);
const ERROR_FILE_NOT_FOUND: u32 = 2;
@@ -192,8 +192,8 @@ mod windows_impl {
use windows::Win32::UI::Input::KeyboardAndMouse::HKL;
use windows::Win32::UI::TextServices::{
CLSID_TF_InputProcessorProfiles, ITfInputProcessorProfileMgr, GUID_TFCAT_TIP_KEYBOARD,
TF_INPUTPROCESSORPROFILE, TF_IPPMF_FORPROCESS, TF_PROFILETYPE_INPUTPROCESSOR,
TF_PROFILETYPE_KEYBOARDLAYOUT,
TF_INPUTPROCESSORPROFILE, TF_IPPMF_DONTCARECURRENTINPUTLANGUAGE, TF_IPPMF_FORSESSION,
TF_PROFILETYPE_INPUTPROCESSOR, TF_PROFILETYPE_KEYBOARDLAYOUT,
};
use winreg::enums::{HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_64KEY};
use winreg::RegKey;
@@ -201,6 +201,8 @@ mod windows_impl {
const OPENLESS_COM_INPROC_KEY: &str =
r"Software\Classes\CLSID\{6B9F3F4F-5EE7-42D6-9C61-9F80B03A5D7D}\InprocServer32";
const OPENLESS_TSF_PROFILE_KEY: &str = r"Software\Microsoft\CTF\TIP\{6B9F3F4F-5EE7-42D6-9C61-9F80B03A5D7D}\LanguageProfile\0x00000804\{9B5F5E04-23F6-47DA-9A26-D221F6C3F02E}";
const PROFILE_ACTIVATION_FLAGS: u32 =
TF_IPPMF_FORSESSION | TF_IPPMF_DONTCARECURRENTINPUTLANGUAGE;
struct ComApartment;
@@ -255,7 +257,7 @@ mod windows_impl {
&clsid,
&profile_guid,
null_hkl(),
TF_IPPMF_FORPROCESS,
PROFILE_ACTIVATION_FLAGS,
)
})
}
@@ -274,7 +276,7 @@ mod windows_impl {
&clsid,
&profile_guid,
null_hkl(),
TF_IPPMF_FORPROCESS,
PROFILE_ACTIVATION_FLAGS,
)
})
}
@@ -289,7 +291,7 @@ mod windows_impl {
&zero_guid,
&zero_guid,
hkl,
TF_IPPMF_FORPROCESS,
PROFILE_ACTIVATION_FLAGS,
)
})
}