chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.28k stars 457 forks source link

CEF does not work with IMEs on Linux #1813

Open magreenblatt opened 8 years ago

magreenblatt commented 8 years ago

Original report by Xinkai Chen (Bitbucket: xinkai, GitHub: xinkai).


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.

magreenblatt commented 8 years ago

Original comment by Xinkai Chen (Bitbucket: xinkai, GitHub: xinkai).


Append:

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

magreenblatt commented 8 years ago

Original comment by Kevin Kratzer (Bitbucket: illfang, GitHub: illfang).


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

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

magreenblatt commented 8 years ago

Original comment by Kevin Kratzer (Bitbucket: illfang, GitHub: illfang).


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.:

#!c++

 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
 }
magreenblatt commented 7 years ago

Issue #2039 was marked as a duplicate of this issue.

magreenblatt commented 7 years ago

Original comment by XKorolX (Bitbucket: Oleg Oleg).


Is it planned to fix this bug? Thanks.

magreenblatt commented 7 years ago

Original comment by azraelrabbit (Bitbucket: azraelrabbit, GitHub: azraelrabbit).


Is it planned to fix this bug?

magreenblatt commented 6 years ago

Original comment by 823639792 (Bitbucket: 823639792, GitHub: 823639792).


Is it planned to fix this bug? same as Kevin Kratzer said.

magreenblatt commented 6 years ago

Issue #2292 was marked as a duplicate of this issue.

magreenblatt commented 6 years ago

Pull requests to fix this bug would be welcome.

magreenblatt commented 6 years ago

Original comment by Abhijit Apte (Bitbucket: abhijitapte, GitHub: abhijitapte).


I have come up with this fix and tested it out on Linux. https://bitbucket.org/abhijitapte/cef_3163/commits/334af31b8ace200930505712e27b12e2efb280c3

magreenblatt commented 6 years ago

Original comment by Abhijit Apte (Bitbucket: abhijitapte, GitHub: abhijitapte).


Raised PR 127 @magreenblatt please review the fix.

magreenblatt commented 6 years ago

@abhijitapte Thanks for the PR. See comments there.

magreenblatt commented 6 years ago

Original comment by Abhijit Apte (Bitbucket: abhijitapte, GitHub: abhijitapte).


@magreenblatt addressed most review comments. there's some more wiring that needs to be done between ClientImeHandlerGtk and RealInputMethodContext. please see my commit https://bitbucket.org/abhijitapte/cef/commits/778a1af9e3056e76d4ac89f77b52b29d3809c37b

magreenblatt commented 6 years ago

Original comment by Abhijit Apte (Bitbucket: abhijitapte, GitHub: abhijitapte).


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

magreenblatt commented 6 years ago

Original comment by Abhijit Apte (Bitbucket: abhijitapte, GitHub: abhijitapte).


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

magreenblatt commented 5 years ago

@abhijitapte Please submit your changes as a PR against current master.

magreenblatt commented 4 years ago

Original comment by earth ripple (Bitbucket: 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

magreenblatt commented 4 years ago

Original comment by han moneybags (Bitbucket: hanmoneybags, GitHub: hanmoneybags).


@{5a02b5e49ec0fc1b0de9ee52} @{557058:2f2a2aee-b500-4023-9734-037e9897c3ab} 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.

magreenblatt commented 3 years ago

Issue #3086 was marked as a duplicate of this issue.

magreenblatt commented 3 years ago

Issue #3120 was marked as a duplicate of this issue.

magreenblatt commented 3 years ago

Also possibly related to issue #2892

magreenblatt commented 2 years ago

Original comment by Guofeng Zhang (Bitbucket: 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.

magreenblatt commented 2 years ago

Original comment by fox (Bitbucket: fox, GitHub: fox).


@@Marshall Greenblatt 

Is there any plan to fix this bug on the new version, and is there any way to update this problem

magreenblatt commented 2 years ago

Someone is welcome to fix this issue and submit a pull request for consideration.

magreenblatt commented 7 years ago