Skip to content

Commit

Permalink
Remove special no-op rule from TipInputModeManager::OnSetFocus
Browse files Browse the repository at this point in the history
With this commit, one remaining behavior difference between Mozc
and MS-IME in Windows 11 22H2 will be addressed.

Mozc has had a special no-op rule when switching input focus and the
InputScope specified in the newly focused field is the same as the one
that was previously observed in the same process.  MS-IME, on the other
hand, does not have such a special no-op rule and always updates its
input mode upon switching input focus.

For better app compatibility, let's make it compatible with MS-IME's.

Closes google#826.

PiperOrigin-RevId: 574371235
  • Loading branch information
yukawa authored and hiroyuki-komatsu committed Oct 18, 2023
1 parent ce604c2 commit 00a0bdc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/design_doc/input_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Release History
* 1.11.1490.10x: Initial release
* 2.29.5250.10x
* [#818](https://github.com/google/mozc/issues/818): Remapped `IS_ALPHANUMERIC_HALFWIDTH` to direct mode
* [#826](https://github.com/google/mozc/issues/826): Reflect `InputFocus` on every focus change.

Reference
---------
Expand Down
5 changes: 0 additions & 5 deletions src/win32/tip/tip_input_mode_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ TipInputModeManager::Action TipInputModeManager::OnSetFocus(
}
}

if (!new_input_scopes.empty() && (new_input_scopes == input_scope_)) {
// The same input scope is specified. Use the previous mode.
return kDoNothing;
}

input_scope_ = std::move(new_input_scopes);
mozc_state_ = GetOverriddenState(tsf_state_, input_scopes);
if ((mozc_state_.open_close != prev_effective.open_close) ||
Expand Down
32 changes: 32 additions & 0 deletions src/win32/tip/tip_input_mode_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,38 @@ TEST(TipInputModeManagerTest, HonorOpenCloseModeFromApps_Issue8661096) {
EXPECT_TRUE(input_mode_manager.GetTsfOpenClose());
}

TEST(TipInputModeManagerTest, InputScopeOnSetFocus_GitHubIssue826) {
TipInputModeManager input_mode_manager(GetThreadLocalMode());

// Initialize (Off + Hiragana)
input_mode_manager.OnInitialize(false, kNativeHiragana);

// SetFocus (Off + Hiragana)
std::vector<InputScope> input_scope_email = {IS_EMAIL_SMTPEMAILADDRESS};
auto action =
input_mode_manager.OnSetFocus(false, kNativeHiragana, input_scope_email);
EXPECT_EQ(action, TipInputModeManager::kDoNothing);
EXPECT_FALSE(input_mode_manager.IsIndicatorVisible());
EXPECT_FALSE(input_mode_manager.GetEffectiveOpenClose());
EXPECT_EQ(input_mode_manager.GetEffectiveConversionMode(),
TipInputModeManager::kHiragana);

// On -> (On + Hiragana)
input_mode_manager.OnReceiveCommand(true, TipInputModeManager::kHiragana,
TipInputModeManager::kHiragana);
EXPECT_TRUE(input_mode_manager.GetEffectiveOpenClose());
EXPECT_TRUE(input_mode_manager.IsIndicatorVisible());

// SetFocus again with the same InputScope -> (Off + Hiragana)
action =
input_mode_manager.OnSetFocus(true, kNativeHiragana, input_scope_email);
EXPECT_EQ(action, TipInputModeManager::kUpdateUI);
EXPECT_TRUE(input_mode_manager.IsIndicatorVisible());
EXPECT_FALSE(input_mode_manager.GetEffectiveOpenClose());
EXPECT_EQ(input_mode_manager.GetEffectiveConversionMode(),
TipInputModeManager::kHiragana);
}

} // namespace
} // namespace tsf
} // namespace win32
Expand Down

0 comments on commit 00a0bdc

Please sign in to comment.