InputSourceSelector icon indicating copy to clipboard operation
InputSourceSelector copied to clipboard

入力ソースにGoogle日本語入力を選択した場合、即座に切り替わらない

Open kota65535 opened this issue 8 years ago • 4 comments

日本語で失礼します。 入力ソースとしてGoogle日本語入力を選択した場合、即座に切り替わらない現象を確認しました。

環境

  • macOS Sierra
  • 英字配列キーボード(無関係?)

再現手順

  1. Google日本語入力が有効となっていることを確認する。
% InputSourceSelector list-enabled                                                                                                
com.apple.keylayout.US (U.S.)
com.apple.inputmethod.Kotoeri.Japanese (Hiragana)
com.apple.inputmethod.Kotoeri.Roman (Romaji)
com.apple.inputmethod.Kotoeri.Japanese.Katakana (Katakana)
com.apple.inputmethod.Kotoeri (Japanese)
com.apple.50onPaletteIM (Japanese Kana Palette)
com.google.inputmethod.Japanese.base (Hiragana (Google))
com.google.inputmethod.Japanese (Google Japanese Input)
com.google.inputmethod.Japanese.Roman (Alphanumeric (Google))
  1. 英字入力からGoogle日本語入力に切り替える。
% InputSourceSelector select com.google.inputmethod.Japanese.base
  1. 画面右上の通知としては入力ソースが切り替わるが、ターミナル上では英字入力のままの状態になる。ただし、ウィンドウを切り替えると入力ソースが正常に切り替わる。

「ことえり」に切り替えた場合はこの症状は起きず、即座に入力ソースが切り替わります。

考察

ことえりで起きないことから、どうやら入力ソース依存なのかもしれません。stackoverflowでも似たような症状に悩む投稿があります。

http://stackoverflow.com/questions/22885767/how-to-programmatically-switch-an-input-method-on-os-x

この中で、下記のような興味深いコメントがあります。

Oh! You’re trying to change the input method to affect another process. Typically these APIs are used by an application to select an IM for itself or one of its documents. If there’s a supported means to do this, it probably involves sending a notification to other processes. Also, beware of the interaction with the “Automatically switch to a document’s input source” system preference, which may affect your results.

推測するに、入力ソースの切り替わりをプロセスに通知するタイミングが、ことえりとGoogle日本語入力で異なるのかもしれません(ことえりは即座に通知するのに対し、Google日本語入力はそうではない?)。もちろん環境依存の可能性も考えられます。

minokiさんの環境ではこのような症状は発生しておりませんでしょうか?

kota65535 avatar Jan 06 '17 14:01 kota65535

下記のようにいくつかの入力ソースの組み合わせで検証してみました。

Before After Result
英数(Google) ひらがな(Google) Fail
U.S ひらがな(Google) OK
英字(ことえり) ひらがな(ことえり) OK
英字(ことえり) ひらがな(Google) Fail

見たところ、

  • U.S 以外 -> ひらがな(Google)

に変換した時に本症状が起きるように見えます。

kota65535 avatar Jan 06 '17 15:01 kota65535

This is a bug of macOS, and you can see https://github.com/noraesae/kawa/pull/12 for background and workarounds.

zcbenz avatar Sep 16 '17 00:09 zcbenz

https://github.com/laishulu/macism/

macism solved this problem.

laishulu avatar Jul 07 '20 08:07 laishulu

Try https://github.com/Yang-Xijie/InputSourceSwitcher.

Source Switcher uses Applescript to manipulate UI operation which is better than using Carbon (a framework most of whose APIs are deprecated) in other tools to change input source.

Yang-Xijie avatar Jun 25 '21 08:06 Yang-Xijie