<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://fcitx-im.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Remik1r3n</id>
	<title>Fcitx - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://fcitx-im.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Remik1r3n"/>
	<link rel="alternate" type="text/html" href="https://fcitx-im.org/wiki/Special:Contributions/Remik1r3n"/>
	<updated>2026-05-03T11:24:37Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46229</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46229"/>
		<updated>2025-03-04T12:16:02Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;* X11 ** 环境变量中的 GTK_IM_MODULE ** XSettings 中 Gtk/IMModule 的值 ** 配置文件中的值 ** 基于区域设置的自动选择 * Wayland ** 环境变量中的 GT...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。不设置 GTK_IM_MODULE 的时候，Gtk3/Gtk4 就会自动启用内置的 Wayland 输入法模块。虽然你也可以显式指定 GTK_IM_MODULE=wayland，但是 Gtk2 程序也会读取这个环境变量，导致兼容问题。设置 GTK_IM_MODULE=fcitx 依然是可以工作的，而且如果你使用的合成器不兼容 Wayland 输入法协议，这也是你的唯一选择。&lt;br /&gt;
&lt;br /&gt;
你可以在 Gtk 的配置文件里强制使用某个 IM Module，所以就算你不设置 GTK_IM_MODULE 环境变量也仍然是可以用不同的 IM Module 的。&lt;br /&gt;
&lt;br /&gt;
根据 Gtk 的实现（截至 3.24.41 版本仍有效），优先级顺序如下：&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** 环境变量中的 GTK_IM_MODULE&lt;br /&gt;
** XSettings 中 Gtk/IMModule 的值&lt;br /&gt;
** 配置文件中的值&lt;br /&gt;
** 基于区域设置的自动选择&lt;br /&gt;
* Wayland&lt;br /&gt;
** 环境变量中的 GTK_IM_MODULE&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/18/zh-cn&amp;diff=46228</id>
		<title>Translations:Using Fcitx 5 on Wayland/18/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/18/zh-cn&amp;diff=46228"/>
		<updated>2025-03-04T12:16:02Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;* X11 ** 环境变量中的 GTK_IM_MODULE ** XSettings 中 Gtk/IMModule 的值 ** 配置文件中的值 ** 基于区域设置的自动选择 * Wayland ** 环境变量中的 GT...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* X11&lt;br /&gt;
** 环境变量中的 GTK_IM_MODULE&lt;br /&gt;
** XSettings 中 Gtk/IMModule 的值&lt;br /&gt;
** 配置文件中的值&lt;br /&gt;
** 基于区域设置的自动选择&lt;br /&gt;
* Wayland&lt;br /&gt;
** 环境变量中的 GTK_IM_MODULE&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46227</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46227"/>
		<updated>2025-03-04T12:14:18Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;根据 Gtk 的实现（截至 3.24.41 版本仍有效），优先级顺序如下：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。不设置 GTK_IM_MODULE 的时候，Gtk3/Gtk4 就会自动启用内置的 Wayland 输入法模块。虽然你也可以显式指定 GTK_IM_MODULE=wayland，但是 Gtk2 程序也会读取这个环境变量，导致兼容问题。设置 GTK_IM_MODULE=fcitx 依然是可以工作的，而且如果你使用的合成器不兼容 Wayland 输入法协议，这也是你的唯一选择。&lt;br /&gt;
&lt;br /&gt;
你可以在 Gtk 的配置文件里强制使用某个 IM Module，所以就算你不设置 GTK_IM_MODULE 环境变量也仍然是可以用不同的 IM Module 的。&lt;br /&gt;
&lt;br /&gt;
根据 Gtk 的实现（截至 3.24.41 版本仍有效），优先级顺序如下：&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/17/zh-cn&amp;diff=46226</id>
		<title>Translations:Using Fcitx 5 on Wayland/17/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/17/zh-cn&amp;diff=46226"/>
		<updated>2025-03-04T12:14:18Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;根据 Gtk 的实现（截至 3.24.41 版本仍有效），优先级顺序如下：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;根据 Gtk 的实现（截至 3.24.41 版本仍有效），优先级顺序如下：&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46225</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46225"/>
		<updated>2025-03-04T12:11:54Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;你可以在 Gtk 的配置文件里强制使用某个 IM Module，所以就算你不设置 GTK_IM_MODULE 环境变量也仍然是可以用不同的 IM Module 的。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。不设置 GTK_IM_MODULE 的时候，Gtk3/Gtk4 就会自动启用内置的 Wayland 输入法模块。虽然你也可以显式指定 GTK_IM_MODULE=wayland，但是 Gtk2 程序也会读取这个环境变量，导致兼容问题。设置 GTK_IM_MODULE=fcitx 依然是可以工作的，而且如果你使用的合成器不兼容 Wayland 输入法协议，这也是你的唯一选择。&lt;br /&gt;
&lt;br /&gt;
你可以在 Gtk 的配置文件里强制使用某个 IM Module，所以就算你不设置 GTK_IM_MODULE 环境变量也仍然是可以用不同的 IM Module 的。&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/16/zh-cn&amp;diff=46224</id>
		<title>Translations:Using Fcitx 5 on Wayland/16/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/16/zh-cn&amp;diff=46224"/>
		<updated>2025-03-04T12:11:54Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;你可以在 Gtk 的配置文件里强制使用某个 IM Module，所以就算你不设置 GTK_IM_MODULE 环境变量也仍然是可以用不同的 IM Module 的。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;你可以在 Gtk 的配置文件里强制使用某个 IM Module，所以就算你不设置 GTK_IM_MODULE 环境变量也仍然是可以用不同的 IM Module 的。&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46223</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46223"/>
		<updated>2025-03-04T12:10:55Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。不设置 GTK_IM_MODULE 的时候，Gtk3/Gtk4 就会自动启用内置的 Wayland 输入法模块。虽然你也可以显式指定 GTK_IM_MODULE=wayland，但是 Gtk2 程序也会读取这个环境变量，导致兼容问题。设置 GTK_IM_MODULE=fcitx 依然是可以工作的，而且如果你使用的合成器不兼容 Wayland 输入法协议，这也是你的唯一选择。&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/15/zh-cn&amp;diff=46222</id>
		<title>Translations:Using Fcitx 5 on Wayland/15/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/15/zh-cn&amp;diff=46222"/>
		<updated>2025-03-04T12:10:55Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。不设置 GTK_IM_MODULE 的时候，Gtk3/Gtk4 就会自动启用内置的 Wayland 输入法模块。虽然你也可以显式指定 GTK_IM_MODULE=wayland，但是 Gtk2 程序也会读取这个环境变量，导致兼容问题。设置 GTK_IM_MODULE=fcitx 依然是可以工作的，而且如果你使用的合成器不兼容 Wayland 输入法协议，这也是你的唯一选择。&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46221</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46221"/>
		<updated>2025-03-04T12:10:20Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。在设置该变量的值时，您有多个选择。如果不设置 GTK_IM_MODULE，Gtk3/Gtk4 会自动启用内置的 Wayland 输入法模块。虽然你也可以显式指定 GTK_IM_MODULE=wayland，但是 Gtk2 程序也会读取这个环境变量，导致兼容问题。设置 GTK_IM_MODULE=fcitx 依然是可以工作的，而且如果你使用的合成器不兼容 Wayland 输入法协议，这也是你的唯一选择。&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/15/zh-cn&amp;diff=46220</id>
		<title>Translations:Using Fcitx 5 on Wayland/15/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/15/zh-cn&amp;diff=46220"/>
		<updated>2025-03-04T12:10:20Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;关于 GTK_IM_MODULE 环境变量，目前现代 Gtk3/4 应用程序应当能够使用 text-input-v3 协议（该协议已被绝大多数合成器支持，Weston 除外）。在设置该变量的值时，您有多个选择。如果不设置 GTK_IM_MODULE，Gtk3/Gtk4 会自动启用内置的 Wayland 输入法模块。虽然你也可以显式指定 GTK_IM_MODULE=wayland，但是 Gtk2 程序也会读取这个环境变量，导致兼容问题。设置 GTK_IM_MODULE=fcitx 依然是可以工作的，而且如果你使用的合成器不兼容 Wayland 输入法协议，这也是你的唯一选择。&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/14/zh-cn&amp;diff=46219</id>
		<title>Translations:Using Fcitx 5 on Wayland/14/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/14/zh-cn&amp;diff=46219"/>
		<updated>2025-03-04T12:04:16Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;&amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&amp;#039;Gtk/IMModule&amp;#039;:&amp;lt;&amp;#039;fcitx&amp;#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46218</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46218"/>
		<updated>2025-03-04T12:04:13Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/13/zh-cn&amp;diff=46217</id>
		<title>Translations:Using Fcitx 5 on Wayland/13/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/13/zh-cn&amp;diff=46217"/>
		<updated>2025-03-04T12:04:13Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;5. 如果你在用 GNOME 3 和以上版本，你还需要运行以下命令：&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/12/zh-cn&amp;diff=46216</id>
		<title>Translations:Using Fcitx 5 on Wayland/12/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/12/zh-cn&amp;diff=46216"/>
		<updated>2025-03-04T12:03:52Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;&amp;lt;nowiki&amp;gt;[Settings] gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46215</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46215"/>
		<updated>2025-03-04T12:03:46Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/8/zh-cn&amp;diff=46214</id>
		<title>Translations:Using Fcitx 5 on Wayland/8/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/8/zh-cn&amp;diff=46214"/>
		<updated>2025-03-04T12:03:46Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容：&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46213</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46213"/>
		<updated>2025-03-04T12:03:39Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/11/zh-cn&amp;diff=46212</id>
		<title>Translations:Using Fcitx 5 on Wayland/11/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/11/zh-cn&amp;diff=46212"/>
		<updated>2025-03-04T12:03:39Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;4. 对于 Gtk4。向 ~/.config/gtk-4.0/settings.ini 添加如下内容：&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/10/zh-cn&amp;diff=46211</id>
		<title>Translations:Using Fcitx 5 on Wayland/10/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/10/zh-cn&amp;diff=46211"/>
		<updated>2025-03-04T12:03:19Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;&amp;lt;nowiki&amp;gt;[Settings] gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46210</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46210"/>
		<updated>2025-03-04T12:03:15Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;&amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt; 3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/9/zh-cn&amp;diff=46209</id>
		<title>Translations:Using Fcitx 5 on Wayland/9/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/9/zh-cn&amp;diff=46209"/>
		<updated>2025-03-04T12:03:15Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;&amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt; 3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. 对于 Gtk3，向 ~/.config/gtk-3.0/settings.ini 添加如下内容：&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46208</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46208"/>
		<updated>2025-03-04T12:02:57Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/8/zh-cn&amp;diff=46207</id>
		<title>Translations:Using Fcitx 5 on Wayland/8/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/8/zh-cn&amp;diff=46207"/>
		<updated>2025-03-04T12:02:57Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;2. 对于 Gtk2，向 ~/.gtkrc-2.0 添加如下内容&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46206</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46206"/>
		<updated>2025-03-04T12:02:37Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;1. 不要设置 GTK_IM_MODULE 环境变量！&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. 不要设置 GTK_IM_MODULE 环境变量！&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/7/zh-cn&amp;diff=46205</id>
		<title>Translations:Using Fcitx 5 on Wayland/7/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/7/zh-cn&amp;diff=46205"/>
		<updated>2025-03-04T12:02:37Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;1. 不要设置 GTK_IM_MODULE 环境变量！&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;1. 不要设置 GTK_IM_MODULE 环境变量！&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46204</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46204"/>
		<updated>2025-03-04T12:02:11Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;==== GTK_IM_MODULE ==== 在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/6/zh-cn&amp;diff=46203</id>
		<title>Translations:Using Fcitx 5 on Wayland/6/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/6/zh-cn&amp;diff=46203"/>
		<updated>2025-03-04T12:02:11Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;==== GTK_IM_MODULE ==== 在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== GTK_IM_MODULE ====&lt;br /&gt;
在理想的情况下，你应该在 X11 下运行的 GTK 程序用 im-module，而在纯 Wayland 程序中用 GTK 的 text-input-v3 支持。其方法是：&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46202</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46202"/>
		<updated>2025-03-04T11:54:17Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/5/zh-cn&amp;diff=46201</id>
		<title>Translations:Using Fcitx 5 on Wayland/5/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/5/zh-cn&amp;diff=46201"/>
		<updated>2025-03-04T11:54:17Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XMODIFIERS 确实还需要设置，因为纯 X11 和 XWayland 下运行的 X11 程序基本没什么区别。&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46200</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46200"/>
		<updated>2025-03-04T11:53:39Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;== Applications == === TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;br /&gt;
&lt;br /&gt;
==== XMODIFIERS ====&lt;br /&gt;
For XMODIFIERS, yes, we do. X11 application running under X11 and XWayland has nearly no difference.&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/4/zh-cn&amp;diff=46199</id>
		<title>Translations:Using Fcitx 5 on Wayland/4/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/4/zh-cn&amp;diff=46199"/>
		<updated>2025-03-04T11:53:39Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;== Applications == === TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Applications ==&lt;br /&gt;
=== TLDR：还需要设置 XMODIFIERS，GTK_IM_MODULE 和 QT_IM_MODULE 吗? ===&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46198</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46198"/>
		<updated>2025-03-04T11:51:55Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;本文尽量涵盖目前所有的相关信息，Fcitx 5配置指南亦仍具有参考价值。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TL;DR Do we still need XMODIFIERS, GTK_IM_MODULE and QT_IM_MODULE? ===&lt;br /&gt;
&lt;br /&gt;
==== XMODIFIERS ====&lt;br /&gt;
For XMODIFIERS, yes, we do. X11 application running under X11 and XWayland has nearly no difference.&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/3/zh-cn&amp;diff=46197</id>
		<title>Translations:Using Fcitx 5 on Wayland/3/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/3/zh-cn&amp;diff=46197"/>
		<updated>2025-03-04T11:51:55Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;本文尽量涵盖目前所有的相关信息，Fcitx 5配置指南亦仍具有参考价值。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;本文尽量涵盖目前所有的相关信息，[[Special:MyLanguage /Setup Fcitx 5|Fcitx 5配置指南]]亦仍具有参考价值。&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46196</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46196"/>
		<updated>2025-03-04T11:51:30Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;br /&gt;
&lt;br /&gt;
This page will try to cover all the current information with some underlying details, and [[Special:MyLanguage/Setup Fcitx 5|Setup Fcitx 5]] is still generally useful.&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TL;DR Do we still need XMODIFIERS, GTK_IM_MODULE and QT_IM_MODULE? ===&lt;br /&gt;
&lt;br /&gt;
==== XMODIFIERS ====&lt;br /&gt;
For XMODIFIERS, yes, we do. X11 application running under X11 and XWayland has nearly no difference.&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/2/zh-cn&amp;diff=46195</id>
		<title>Translations:Using Fcitx 5 on Wayland/2/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Translations:Using_Fcitx_5_on_Wayland/2/zh-cn&amp;diff=46195"/>
		<updated>2025-03-04T11:51:30Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;在不同的Wayland合成器上使用输入法可能需要不同的配置，且某些在X11下可用的Fcitx功能尚未被Wayland支持。&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland&amp;diff=46129</id>
		<title>Using Fcitx 5 on Wayland</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland&amp;diff=46129"/>
		<updated>2025-03-04T11:44:39Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Marked this version for translation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
Also, using input method on Wayland-based compositor may require different setup to make it work, and certain features of fcitx that works under X11 are not yet supported by Wayland.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
This page will try to cover all the current information with some underlying details, and [[Special:MyLanguage/Setup Fcitx 5|Setup Fcitx 5]] is still generally useful.&lt;br /&gt;
&lt;br /&gt;
== Applications == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
=== TL;DR Do we still need XMODIFIERS, GTK_IM_MODULE and QT_IM_MODULE? ===&lt;br /&gt;
&lt;br /&gt;
==== XMODIFIERS ==== &amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
For XMODIFIERS, yes, we do. X11 application running under X11 and XWayland has nearly no difference.&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ==== &amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ==== &amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland === &amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 === &amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 === &amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) === &amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron === &amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
# If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
# If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
# However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
# You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
# If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor == &amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma === &amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME === &amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway === &amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston === &amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors === &amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues == &amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window === &amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state === &amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland&amp;diff=46128</id>
		<title>Using Fcitx 5 on Wayland</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland&amp;diff=46128"/>
		<updated>2025-03-04T11:44:10Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
Also, using input method on Wayland-based compositor may require different setup to make it work, and certain features of fcitx that works under X11 are not yet supported by Wayland.&lt;br /&gt;
&lt;br /&gt;
This page will try to cover all the current information with some underlying details, and [[Special:MyLanguage/Setup Fcitx 5|Setup Fcitx 5]] is still generally useful.&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TL;DR Do we still need XMODIFIERS, GTK_IM_MODULE and QT_IM_MODULE? ===&lt;br /&gt;
&lt;br /&gt;
==== XMODIFIERS ====&lt;br /&gt;
For XMODIFIERS, yes, we do. X11 application running under X11 and XWayland has nearly no difference.&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland&amp;diff=46127</id>
		<title>Using Fcitx 5 on Wayland</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland&amp;diff=46127"/>
		<updated>2025-03-04T11:43:07Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://wayland.freedesktop.org/ Wayland] is the next generation of display server protocol. While the initial release of the protocol is in 2008, the support of input method is not really ideal.&lt;br /&gt;
&lt;br /&gt;
Also, using input method on Wayland-based compositor may require different setup to make it work, and certain features of fcitx that works under X11 are not yet supported by Wayland.&lt;br /&gt;
&lt;br /&gt;
This page will try to cover all the current information with some underlying details, and [[Special:MyLanguage/Setup Fcitx 5|Setup Fcitx 5]] is still generally useful.&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TL;DR Do we still need XMODIFIERS, GTK_IM_MODULE and QT_IM_MODULE? ===&lt;br /&gt;
&lt;br /&gt;
==== XMODIFIERS ====&lt;br /&gt;
For XMODIFIERS, yes, we do. X11 application running under X11 and XWayland has nearly no difference.&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
	<entry>
		<id>https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46126</id>
		<title>Using Fcitx 5 on Wayland/zh-cn</title>
		<link rel="alternate" type="text/html" href="https://fcitx-im.org/index.php?title=Using_Fcitx_5_on_Wayland/zh-cn&amp;diff=46126"/>
		<updated>2025-03-04T11:35:29Z</updated>

		<summary type="html">&lt;p&gt;Remik1r3n: Created page with &amp;quot;[https://wayland.freedesktop.org/ Wayland] 是新一代的显示协议。虽然此协议 2008 年便已发布初版，但其目前对输入法的支持仍不十分理想。  A...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://wayland.freedesktop.org/ Wayland] 是新一代的显示协议。虽然此协议 2008 年便已发布初版，但其目前对输入法的支持仍不十分理想。&lt;br /&gt;
&lt;br /&gt;
Also, using input method on Wayland-based compositor may require different setup to make it work, and certain features of fcitx that works under X11 are not yet supported by Wayland.&lt;br /&gt;
&lt;br /&gt;
This page will try to cover all the current information with some underlying details, and [[Special:MyLanguage/Setup Fcitx 5|Setup Fcitx 5]] is still generally useful.&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
=== TL;DR Do we still need XMODIFIERS, GTK_IM_MODULE and QT_IM_MODULE? ===&lt;br /&gt;
&lt;br /&gt;
==== XMODIFIERS ====&lt;br /&gt;
For XMODIFIERS, yes, we do. X11 application running under X11 and XWayland has nearly no difference.&lt;br /&gt;
&lt;br /&gt;
==== GTK_IM_MODULE ====&lt;br /&gt;
In an ideal setup, you should use fcitx im module Gtk application running under X11, and Gtk&#039;s text-input-v3 for wayland. The way of doing this is:&lt;br /&gt;
&lt;br /&gt;
1. Do NOT set GTK_IM_MODULE environment variable.&lt;br /&gt;
&lt;br /&gt;
2. For Gtk2, Add following content to ~/.gtkrc-2.0&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gtk-im-module=&amp;quot;fcitx&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
3. For Gtk 3, add following content to ~/.config/gtk-3.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For Gtk 4, add following content to ~/.config/gtk-4.0/settings.ini&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[Settings]&lt;br /&gt;
gtk-im-module=fcitx&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. If you are using GNOME 3+, also run following command.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;gsettings set org.gnome.settings-daemon.plugins.xsettings overrides &amp;quot;{&#039;Gtk/IMModule&#039;:&amp;lt;&#039;fcitx&#039;&amp;gt;}&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.&lt;br /&gt;
&lt;br /&gt;
It is possible to force a certain im module with Gtk configuration file, so without GTK_IM_MODULE set, it will still be able to use different im module.&lt;br /&gt;
&lt;br /&gt;
Per Gtk implementation (still valid for 3.24.41), the order of preferences is:&lt;br /&gt;
&lt;br /&gt;
* X11&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** Value of Gtk/IMModule from XSettings&lt;br /&gt;
** Value from configuration file&lt;br /&gt;
** A locale based automatic selection&lt;br /&gt;
* Wayland&lt;br /&gt;
** GTK_IM_MODULE in the environment&lt;br /&gt;
** &amp;quot;wayland&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== QT_IM_MODULE ====&lt;br /&gt;
For QT_IM_MODULE, as for now QT can only use its own text-input-v{2,4}, which is only supported by KWin. Which means, under KDE you should unset it, but under other desktop, you will need to set it to QT_IM_MODULE=fcitx. Also the proprietary Qt applications in the wild complicates the situation. Some do not work on Wayland, some do not bundle/provide Qt wayland. Most of them do not bundle fcitx im module because fcitx is only a third party application to Qt, but I also noticed some do bundle but not bundle all the required libraries. While fcitx 5 support ibus protocol, some of those applications do not even bundle ibus im module. There are a few different environment variables you can try for those proprietary Qt applications (WPS, Anki, DaVinci Resolve, Mathematica, etc...).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULE=fcitx # For those who bundle qt im module, e.g. WPS, Anki, you should find a .so file with fcitx in the file name&lt;br /&gt;
QT_IM_MODULE=ibus # For those who bundle ibus im module shipped with Qt, you should find libibusplatforminputcontextplugin.so in the package.&lt;br /&gt;
QT_QPA_PLATFORM=xcb QT_IM_MODULE=ibus # Enforce it to run on X11/XWayland and use ibus im module&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Qt 6.7, there is a new environment variable called &amp;quot;QT_IM_MODULES&amp;quot;, which allows you so specify a fallback order on im modules. You can set it to &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;QT_IM_MODULES=&amp;quot;wayland;fcitx;ibus&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So it will be able pick up the most usable one even for application that bundles no fcitx/wayland. Remember, you may still need to set( or unset) QT_IM_MODULE (not &amp;quot;QT_IM_MODULES&amp;quot;) in order to handle Qt 4/5 applications.&lt;br /&gt;
&lt;br /&gt;
=== Legacy X11 application that runs under XWayland ===&lt;br /&gt;
In a word, XWayland support for input method is as good as normal X11 display server. As long as you set the same environment variable, using Xwayland should not be a issue. This category includes: &lt;br /&gt;
&lt;br /&gt;
* Xlib-based (and also other toolkit based on Xlib, e.g. tk, SDL1, etc), e.g. xterm, rxvt. Make sure XMODIFIERS is set correctly.&lt;br /&gt;
* Gtk2-based applications, similar to Xlib, but can use fcitx im module. Set GTK_IM_MODULE to fcitx will give it best experience.&lt;br /&gt;
* SDL2-based applications that doesn&#039;t default to wayland. Set SDL_IM_MODULE to fcitx&lt;br /&gt;
* electron, chromium, these are still default to X11, similar to Gtk2 case.&lt;br /&gt;
* For Qt4 applcation, Qt 4 can only use X11. You will need to QT_IM_MODULE to fcitx. Same for Qt5+ that uses XCB (can be override with QT_QPA_PLATFORM=xcb).&lt;br /&gt;
&lt;br /&gt;
=== Gtk3 / Gtk4 ===&lt;br /&gt;
Gtk3 and Gtk4 support text-input-v3 natively. At the same time, it&#039;s also possible to use fcitx im module under wayland. So, either GTK_IM_MODULE=wayland or GTK_IM_MODULE=fcitx works. There are some difference to it. text-input-v3&lt;br /&gt;
&lt;br /&gt;
=== Qt5 / Qt6 ===&lt;br /&gt;
If your Qt application natively runs under Wayland, you can either unset QT_IM_MODULE to make it use text-input-v2, or set QT_IM_MODULE=fcitx to make it use fcitx im module.&lt;br /&gt;
&lt;br /&gt;
text-input-v2 is not upstreamed to wayland-protocols, that is probably why only kwin support it. This means in non-kwin environment, you will need to use QT_IM_MODULE=fcitx to make the Qt applications work.&lt;br /&gt;
&lt;br /&gt;
On Qt6, you may also use QT_IM_MODULE= (empty) or QT_IM_MODULE=wayland if your Qt vesion contains this https://codereview.qt-project.org/c/qt/qtwayland/+/416862.&lt;br /&gt;
&lt;br /&gt;
=== Native wayland application (winit) ===&lt;br /&gt;
Most likely text-input-v3 is being used.&lt;br /&gt;
&lt;br /&gt;
=== Chromium / Electron ===&lt;br /&gt;
{{warning|The information in this section may not be up to date to reflect upstream change, especially the default behavior when no option is changed.}}&lt;br /&gt;
TL;DR version, if you use XWayland to run Chromium or Electron application, just install Gtk im module and GTK_IM_MODULE=fcitx the same way like X11.&lt;br /&gt;
&lt;br /&gt;
If you choose to run it natively under Wayland, for chromium you will need to use&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
 # If your compositor &amp;amp; chromium supports text-input-v3 protocol, you may also use&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3 &lt;br /&gt;
&lt;br /&gt;
 # However, due to a different understanding in text-input-v3 protocol, it has some issue when using with KWin.&lt;br /&gt;
 # Prefer text-input-v1 if you&#039;re using kwin.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=1&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
 # You will get wrong position for the input method popup window, unless you use GNOME shell + kimpanel extension.&lt;br /&gt;
 chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4 &lt;br /&gt;
&lt;br /&gt;
For electron, only the first option is avaiable (electron does NOT support to run internal chromium with gtk4), e.g. for vscode&lt;br /&gt;
&lt;br /&gt;
 # If your compositor supports text-input-v1 protocol. Check the compositor section below.&lt;br /&gt;
 code --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime&lt;br /&gt;
&lt;br /&gt;
By default it should run under Xwayland (As of 2023/02/25 on Archlinux/Chromium 110.0.5481.177), but some user also reports it is using wayland even the &amp;quot;Preferred Ozone Platform&amp;quot; is &amp;quot;Default&amp;quot;. So to check whether it&#039;s really run with wayland, you can use xeyes or xwininfo. With xeyes, if it&#039;s an X11 window, the &amp;quot;eyes&amp;quot; will move with mouse, otherwise it&#039;s wayland. With xwininfo, if the mouse cursor changed to &amp;quot;+&amp;quot; shape, and click the window shows the window information, then it is a X11 window.&lt;br /&gt;
&lt;br /&gt;
You may force it to run with Wayland, or X11 with the flag &amp;lt;code&amp;gt;--ozone-platform=wayland&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--ozone-platform=x11&amp;lt;/code&amp;gt;. You may persistent this by changing the option &amp;quot;Preferred Ozone Platform&amp;quot; in chrome://flags. It has four values, &amp;quot;Default&amp;quot;, &amp;quot;X11&amp;quot;, &amp;quot;Wayland&amp;quot;, &amp;quot;Auto&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make it use GTK_IM_MODULE if it runs with Gtk4 (only supported by chromium/chrome at this time, not electron) by passing &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also possible to make it use text-input-v1 by passing  &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; in addition to the flag above.&lt;br /&gt;
&lt;br /&gt;
The Chromium support for text-input-v1 is not very stable and you may hit some random crash. E.g. in the past, version 112 has a crash bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1431532 , which is fixed in version 115. In the bug comment, Chromium developer claims this text-input-v1 is only supposed to be used internally and not well supported, so use this at your own risk though it&#039;s currently the only out of box option. &lt;br /&gt;
&lt;br /&gt;
You should only use one of &amp;lt;code&amp;gt;--enable-wayland-ime&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--gtk-version=4&amp;lt;/code&amp;gt;, depending on you want to use text-input-v1, or gtk4 im module. text-input-v1 works for kwin 5.27 and weston. Gtk4 im module works on all environment, but only GNOME with Kimpanel extension can display the popup window in the correct position.&lt;br /&gt;
&lt;br /&gt;
== Support in Wayland Compositor ==&lt;br /&gt;
&lt;br /&gt;
Even if you are using only native wayland applications, Xwayland is recommended to be enabled for following reason. If client side input panel in im module does not work, fcitx will fallback to a X11 window, instead of a wayland window. The reason for this is because wayland window can not be placed freely on the screen. On the contrary, even if im module can only pass a coordinate relative to the application window to fcitx, which make the coordinate position doesn&#039;t make much sense, if your application window size is &amp;quot;maximized&amp;quot;, the coordinate may just be &amp;quot;right&amp;quot; if treated as the global coordinate. This makes X11 window a better option than a randomly placed wayland window.&lt;br /&gt;
&lt;br /&gt;
=== KDE Plasma ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* KDE Plasma 5.27&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Start fcitx5 by go to &amp;quot;System settings&amp;quot; -&amp;gt; &amp;quot;Virtual keyboard&amp;quot; -&amp;gt; Select Fcitx 5&lt;br /&gt;
** Do not set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;SDL_IM_MODULE&amp;lt;/code&amp;gt; . You could unset &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; by runing &amp;lt;code&amp;gt;im-config&amp;lt;/code&amp;gt; and then selecting &amp;lt;code&amp;gt;do not set any IM from im-config and use desktop default&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Run chromium/electron application with &amp;lt;code&amp;gt;--enable-features=UseOzonePlatform --ozone-platform=wayland  --enable-wayland-ime&amp;lt;/code&amp;gt;&lt;br /&gt;
* Caveats:&lt;br /&gt;
** Certain Gtk/Qt application that only works under X11 may still need to set &amp;lt;code&amp;gt;GTK_IM_MODULE&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QT_IM_MODULE&amp;lt;/code&amp;gt; for them individually.&lt;br /&gt;
** If you set &amp;lt;code&amp;gt;GTK_IM_MODULE/QT_IM_MODULE&amp;lt;/code&amp;gt; globally, you will hit this issue [[Special:MyLanguage/FAQ#Candidate_window_is_blinking_under_wayland_with_Fcitx_5|Candidate window is blinking under wayland with Fcitx 5]]&lt;br /&gt;
&lt;br /&gt;
Support Information:&lt;br /&gt;
* App/Compositor supports text-input-v2 and text-input-v3.&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1. &lt;br /&gt;
* 5.27 additionally supports text-input-v1.&lt;br /&gt;
* 5.24 usable zwp_input_method_v1 with fcitx5. Pre-5.24 there are lots of problems, always use fcitx im module instead.&lt;br /&gt;
* Use &amp;quot;Virtual keyboard&amp;quot; KCM to launch fcitx5. This is required to use text-input protocol. If you launch fcitx this way, make sure you do not use &amp;quot;restart&amp;quot; in the tray menu, since the socket passed from KWin can not be reused with the newly restarted fcitx.&lt;br /&gt;
&lt;br /&gt;
=== GNOME ===&lt;br /&gt;
Best setup:&lt;br /&gt;
* Environment variables:&lt;br /&gt;
** Set &amp;lt;code&amp;gt;XMODIFIERS=@im=fcitx&amp;lt;/code&amp;gt; for XWayland application&lt;br /&gt;
** Set &amp;lt;code&amp;gt;QT_IM_MODULE=fcitx&amp;lt;/code&amp;gt; for Qt, since Qt5 would use XWayland by default.&lt;br /&gt;
** Run chrome with XWayland and &amp;lt;code&amp;gt;GTK_IM_MODULE=fcitx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support information:&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Compositor/Input Method uses ibus dbus protocol, so ibus frontend is required to be used.&lt;br /&gt;
* Adding Fcitx 5 to autostart, it will replace any existing ibus-daemon upon start up so it will work out of box.&lt;br /&gt;
* Popup candidate window is not able to be displayed over gnome-shell UI. Only solution is to use [[Special:MyLanguage/Kimpanel|Kimpanel]], [https://extensions.gnome.org/extension/261/kimpanel/ link to extension].&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Sway ===&lt;br /&gt;
* Application/Compositor uses text-input-v3&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v2, but it&#039;s partially implemented. You will need [https://github.com/swaywm/sway/pull/7226 this pull request] to make it show the popup candidate window for text-input-v3 client.&lt;br /&gt;
* fcitx im module also works.&lt;br /&gt;
* Qt need to use QT_IM_MODULE=fcitx since there is no text-input-v2 support.&lt;br /&gt;
&lt;br /&gt;
=== Weston ===&lt;br /&gt;
* Application/Compositor uses text-input-v1&lt;br /&gt;
* Comopositor/Application uses zwp_input_method_v1.&lt;br /&gt;
* Since it has no text-input-v3, which is more commonly used, im module is the only solution for Gtk/Qt, need to set GTK_IM_MODULE=fcitx and QT_IM_MODULE=fcitx.&lt;br /&gt;
* Add following content to ~/.config/weston.ini to make it launch fcitx 5. (xwayland part is recommended to make fcitx work best, even if it&#039;s wayland)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[core]&lt;br /&gt;
xwayland=true&lt;br /&gt;
&lt;br /&gt;
[input-method]&lt;br /&gt;
path=/usr/bin/fcitx5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other compositors ===&lt;br /&gt;
Please check their upstream for more information. For wlroots based compositors, it is possible that they also support in the same way as Sway does, or zwp_input_method could also be unsupported.&lt;br /&gt;
&lt;br /&gt;
== Known Issues ==&lt;br /&gt;
=== Fcitx managed XKB layout ===&lt;br /&gt;
Unlike X11, there is no generic way to set XKB layout to compositor, which means it can only be implemented for every individual desktop. Right now, Fcitx managed layout only works for KDE Plasma and GNOME.&lt;br /&gt;
&lt;br /&gt;
As for other desktop, in order to make this &amp;quot;semi&amp;quot; work you&#039;ll need to ensure following:&lt;br /&gt;
&lt;br /&gt;
* The XKB layout of the input method group should be the same as the actual xkb layout you configured for the compositor. Fcitx will &amp;quot;think&amp;quot; the layout is the same and bypass the key conversion logic.&lt;br /&gt;
* If you need other layout for text typing (e.g. Arabic), just add them to the Fcitx. As long as the key is forwarded to fcitx, it should work.&lt;br /&gt;
&lt;br /&gt;
=== Popup candidate window ===&lt;br /&gt;
Wayland does not have a global coordinate system for regular client, so for native wayland client, it is impossible for Fcitx to place a wayland surface at a certain position. In order for popup window to be placed at the correct position, there are following cases:&lt;br /&gt;
* Xwayland have no problem and it should work as good as X11.&lt;br /&gt;
* If zwp_input_method protocol can be used, it has a surface role to allow compositor to place the popup window for input method. This only works if client uses text-input protocol.&lt;br /&gt;
* For GNOME, kimpanel extension can read window coordinate since it&#039;s running inside compositor. As long as im module can report relative coordinate, kimpanel extension can display the popup window at the correct position. As similar approach for Plasma kimpanel is planned, but not yet implemented.&lt;br /&gt;
* For Gtk/Qt, fcitx&#039;s im module implement a way to render the popup with in the client process. This has some limitation because implemenation of xdg_popup in Gtk3/Qt5 doesn&#039;t support reposition the window. So show/hide trick is used to mitigate this, but it may cause window blinking. Fcitx tries not to move window if possible. You may also disable popup animation if you&#039;re using KWin to help reduce the blinking.&lt;br /&gt;
&lt;br /&gt;
=== Per-window input method state ===&lt;br /&gt;
When zwp_input_method is used, essentially there is only one input context visible to fcitx, and fcitx cannot distinguish what application is being used. Which means the input method &amp;quot;active&amp;quot;/&amp;quot;inactivate&amp;quot; state is now &amp;quot;global&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now fcitx supports two protocol to figure out the focused window and the corresponding application name, including wlr-foreign-toplevel-management (used by wlroots based compositor) and plasma-window-management (used by kwin).&lt;/div&gt;</summary>
		<author><name>Remik1r3n</name></author>
	</entry>
</feed>