CEF does not work with IMEs on Linux

Issue #1813 new
Xinkai Chen created an issue

Both cefclient and cefsimple do not play well with IMEs on Linux. I have tried with ibus and fcitx, both failed.

With cefclient(GTK2), the address bar's cursor does not blink even though it responses to typing, and both IMEs cannot be activated in address bar, the web view, nor the dev tool window. With cefsimple(X11 native?), both IMEs cannot be activated in the web view.

If I modifiy the code, to use off-screen-rendering in cefclient however, the native GTK address bar becomes normal, but the web view still does not response to IME hotkeys.

In the cases where IMEs do not work at all, I noticed that in /proc/pid/maps, the corresponding libraries are not loaded at all.

What pazzles me is that, both Brackets and LightTable which in turn utilize CEF technology, function as one would hope.

The tests above are done in Archlinux x64 and Ubuntu 14.04 x64.

Any help is appreciated! Thanks in advance.

Comments (23)

  1. Xinkai Chen reporter

    Append:

    I tested with multiple WMs(kwin, mutter, compiz), different CEF versions(2171 - trunk) are tested, not every combination though.

  2. Kevin Kratzer

    I can confirm this problem. I have tested the following versions:

    • cef_binary_3.2680.1395.g84fe790_linux64_client
    • cef_binary_3.2526.1364.gf6bf57b_linux64_client
    • cef_binary_3.2454.1320.g807de3c_linux64_client

    I'm using IBus 1.5.10 + Mozc 1.15.1857.102 on Linux version 4.2.0-34-generic (buildd@lgw01-54) (gcc version 5.2.1 2015/10/10 (Ubuntu 5.2.1-22ubuntu2) ) # 39-Ubuntu SMP Thu Mar 10 22:13:01 UTC 2016 (Xubuntu 15.10, xfce 4.12.1)

    ime_problem_cef_binary_3.2680.1395.g84fe790_linux64_client.gif

  3. Kevin Kratzer

    This feature is marked as a TODO in the source code. It is possible to implement your own IME handling by registering an IME factory during initialization in libcef/browser/browser_main.cc e.g.:

     void CefBrowserMainParts::PreEarlyInitialization() {
     #if defined(USE_AURA) && defined(OS_LINUX)
    -  // TODO(linux): Consider using a real input method or
    -  // views::LinuxUI::SetInstance.
    -  ui::InitializeInputMethodForTesting();
    +  ui::InitializeInputMethod();
    +  LinuxInputMethodContextFactory::SetInstance(this);
     #endif
     }
    
  4. Abhijit Apte

    At this stage, the gtk input method context is active. The preedit start, changed, commit, end callbacks are successfully invoked. these need to be relayed back to the delegate RealInputMethodContext and from thereon to LinuxInputMethodAuraLinux.

    ime.jpg

  5. Abhijit Apte

    Gist of changes - @magreenblatt

    Comparing the newly introduced classes to whatever is available in Chromium, here is the one to one mapping. CEF's RealInputMethodContextFactory corresponds to Chromium's libgtkui::GtkUi (derives from LinuxUI which derives from ui::LinuxInputMethodContextFactory) CEF's RealInputMethodContext corresponds to Chromium's libgtkui::X11InputMethodContextImplGtk2

    In order to externalize the GTK implementation contained in the equivalent of libgtkui::X11InputMethodContextImplGtk2 i.e., RealInputMethodContext , I have created a CefImeHandler and the implementation of it is in cefclient ClientImeHandlerGtk. This is where GtkImContext gets created and the callbacks are registered. The IME callbacks originating via GtkImContext are supposed to relay the information back to the RealInputMethodContext which in turn has a reference to ui::LinuxInputMethodContextDelegate delegate in our case this happens to be ui::InputMethodAuraLinux.

    The left over part yet to be implemented is the delegation from callbacks, please refer to ime_handler_gtk.cc

  6. earth ripple

    I do n’t quite understand why this problem is still reproducible on ubuntu. I tried the latest version cef_binary_81.2.24 + gc0b313d + chromium-81.0.4044.113_linux64.tar.bz2. I tried to modify the code above and found the code. There are certain differences.

    1. The void CefBrowserMainParts :: PreEarlyInitialization () function is now
      int CefBrowserMainParts :: PreEarlyInitialization () internal implementation is also different
      2.// Tells the system IME the surrounding text around the cursor location.
         virtual void SetSurroundingText (const base :: string16 & text,
                                         const gfx :: Range & selection_range) = 0;
      Virtual function is not implemented

  7. han moneybags

    @Abhijit Apte @Marshall Greenblatt I modified the code according to the above method, but an error will occur, the error message is as follows:

    How can i solve this problem? And I am using 3683 branch.

    Thanks.

  8. Guofeng Zhang

    I tried the latest version cef_binary_95.7.14+g9f72f35+chromium-95.0.4638.69_linux64,this problem is still reproducible on ubuntu.

  9. Log in to comment