Using Fcitx with container
This page is intended to describe tricks that need to be applied in order to use Fcitx with container based application.
There can be some issue to use Fcitx on the host with an application running in the container, such as flatpak or docker. Here we will discuss all the possible issues and the resolution.
The application running in the container needs a way to communicate with Fcitx, that has no difference comparing to the application running on the host. Which means you still need to set input method related environment variables for the application within the container. The question is that is usually not enough.
IM module that uses DBus
Container usually does not have shared dbus with host. Flatpak is specialized to have a dbus proxy that filters dbus service based on service name and object path. Luckily, Fcitx has such support by using org.freedesktop.portal as service prefix. This requires to use Fcitx newer than 22.214.171.124. But still, you will need to have im module with in the flatpak runtime. Common freedesktop runtime contains Fcitx/Fcitx 5 im modules, including org.freedesktop.Sdk, org.kde.Sdk, and org.gnome.Sdk. Some would require a newer version to have proper Fcitx 5 support.
If you are not using flatpak, you would not have much luck, especially for general purpose container like docker.
XIM uses X server to communicate with input method. If your application is using X, then it should able to use XIM. But the issue is that the environment with in the container may be broken to use libX11 XIM properly. Also, Qt 5 drops XIM support. If your application is Gtk/Qt, you will need to set XMODIFIERS and GTK_IM_MODULE/QT_IM_MODULE. You will also need to make sure the environment variable is passed to container correctly, because container usually do not accept environment variables from Host directly.