Mozc switches to direct input (English) haphazardly #1137
Replies: 2 comments 5 replies
-
The short answer is that currently there is no way to control the behavior as you expected. Sorry about that. The long answer is that this is due to Windows API contracts between applications and IMEs. On Windows, there are several public APIs that can be called by applications to specify what kind of characters are expected in the current editing context. This means when an application calls a certain Windows API, Mozc does change its mode as requested by the application. I'm mostly certain that this is what you have been observing. Windows Terminal you mentioned in indeed a good example.
The behavior to change the IME mode to the direct input upon startup is indeed explicitly implemented in the Windows Terminal per the following request. Then they had also received several complaints about such a behavior. And finally the behavior is now configurable.
One idea is to implement a new optional mode to completely ignore such Windows APIs. I think it's technically doable, but unfortunately I most likely don't have time to design and implement it in the near time future. |
Beta Was this translation helpful? Give feedback.
-
I put together an ahk (v2) script to partially deal with this issue. GetKeyboard() {
hwnd := WinGetID("A")
threadID := DllCall("GetWindowThreadProcessId", "UInt", hwnd, "UInt", 0)
langCode := DllCall("GetKeyboardLayout", "UInt", threadID, "UInt")
return langCode
}
SetKeyboard(LocaleID) {
Static
SPI_SETDEFAULTINPUTLANG := 0x005A
SPIF_SENDWININICHANGE := 2
Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
binaryLocaleID := Buffer(16)
NumPut("UInt", LocaleID, binaryLocaleID)
DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "Ptr", binaryLocaleID, "UInt", SPIF_SENDWININICHANGE)
id := WinGetID("A")
PostMessage 0x50, 0, Lan, , "ahk_id " id
}
RShift:: {
cil := GetKeyboard()
if cil = 68224017 { ; 日本語
SetKeyboard(0x0409) ; English (US)
}
else {
SetKeyboard(0x0411) ; 日本語
Send "{vk16sc1F2}"
}
} When any keyboard other than the Japanese one is selected, pressing It sets the Japanese keyboard to hiragana mode by sending the |
Beta Was this translation helpful? Give feedback.
-
Description
I want mozc to always be in the mode I specified (hiragana), however, even without typing any keys that would switch it to direct input (English), mozc often switches to English by itself, which is very annoying. In fact, Google Japanese Input and Microsoft Japanese IME have similar issue (but don't seem to be exactly the same).
The behavior is kind of inconsistent. On most apps, it always starts as direct input but seems to stay the same if I change it to hiragana for once. However, if I exit and reopen them, it will be in direct input again. In some cases, it will always switch to direct input whenever the app window is switched to be in focus.
This issue was mentioned in #907.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
Mozc doesn't change input mode unless I tell it to do so.
Actual behavior
Mozc changes input mode to direct input unexpectedly.
Start as direct input after app starts: PDF-XChange, Windows Explorer, Windows settings search box, VS Code, MATLAB, Directory Opus, Obsidian, ...,
even, Windows desktop (the input mode when no app window is in focus, it changes to direct input after Windows restarts).
Always switches to direct input: Windows Terminal.
Version or commit-id
Mozc-2.30.5618.100+24.11.oss
Environment
Beta Was this translation helpful? Give feedback.
All reactions