The Road to Fcitx 5: 1. libxcb replaces libX11

This is the first post of “Road to Fcitx 5”. I planned to talk about more the changes in Fcitx 5, and comments are welcome.

Right now, I’m using Fcitx 5 from day to day. As you can see from our jenkins service, there are more and more packages get ported to fcitx 5. Our ABI and API is not stable yet, so be sure to recompile all packages before you try out a new version.

One of an early plan about Fcitx 5 is I’d like to get rid of libX11 and replace it with xcb. libX11 is somehow more or less in a maintenance only mode. And it is complex, full of hack (especially for the input method part) to keep old API work.

The road to xcb is not easy for Fcitx. So far there is only one implementation for the XIM Server, which is called IMDkit, bundled within every input method server on Linux. To be honest, I have never read through the IMDkit code but just doing small adaption based on the old implementation back to Fcitx 3.6.

XCB is in a much more clearer state, without the key event hackish inside the LibX11 implementation. But there is no xcb only implementation for input method server/client. That’s bascially one of the reason why Qt5/SDL2 does not have xim support. So I decided to write my own library.

https://github.com/wengxt/xcb-imdkit

And here it is. It’s a pure C library that make use of C11 features to dispatch the protocol serialization. Generating XIM protocol from libX11 based source code is also a funny experience. I even discovered some spelling error in the source that sit there from about 22 years ago. Anyway, it’s a tiny library, support both server and client. It should also be easy to use if you want to write pure Xcb application with input method support. You can also check the examples in the test/ directory of the source code.

Also, if you find my work helpful to you, feel free to buy me a beer. The donation link can be found at https://www.csslayer.info/wordpress/donation/ .

See you next time 🙂 .

This entry was posted in fcitx development and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.