fix(window): imm enable and disable

This commit is contained in:
Nomango 2023-09-08 22:17:52 +08:00
parent f1dda09638
commit 612a4cd21d
1 changed files with 6 additions and 6 deletions

View File

@ -83,7 +83,7 @@ private:
bool is_moving_or_resizing_; bool is_moving_or_resizing_;
bool is_minimized_; bool is_minimized_;
CursorType mouse_cursor_; CursorType mouse_cursor_;
HIMC imc_; HIMC imc_restore_;
String device_name_; String device_name_;
Vector<Resolution> resolutions_; Vector<Resolution> resolutions_;
@ -173,7 +173,7 @@ WindowWin32Impl::WindowWin32Impl()
, is_minimized_(false) , is_minimized_(false)
, mouse_cursor_(CursorType::Arrow) , mouse_cursor_(CursorType::Arrow)
, key_map_{} , key_map_{}
, imc_(nullptr) , imc_restore_(nullptr)
{ {
// Keys // Keys
key_map_[VK_UP] = KeyCode::Up; key_map_[VK_UP] = KeyCode::Up;
@ -329,17 +329,17 @@ void WindowWin32Impl::PumpEvents()
void WindowWin32Impl::SetImmEnabled(bool enable) void WindowWin32Impl::SetImmEnabled(bool enable)
{ {
const bool enabled = imc_ != nullptr; const bool enabled = imc_restore_ == nullptr;
if (enable != enabled) if (enable != enabled)
{ {
if (enable) if (enable)
{ {
imc_ = ::ImmAssociateContext(handle_, nullptr); ::ImmAssociateContext(handle_, imc_restore_);
imc_restore_ = nullptr;
} }
else else
{ {
::ImmAssociateContext(handle_, imc_); imc_restore_ = ::ImmAssociateContext(handle_, nullptr);
imc_ = nullptr;
} }
} }
} }