ch11ng / exwm

Emacs X Window Manager
2.85k stars 134 forks source link

Fcitx & Ibus refuse to switch to Chinese input on emacs buffers (but works on X windows) #805

Open etiago opened 3 years ago

etiago commented 3 years ago

Hi,

I've been following the Youtube series of Emacs From Scratch and been enjoying exwm quite a bit - thanks for this!

I'm having some issues with the Fcitx input method however.

It's worth noting that my current emacs setup, minus exwm, works as I expect it to if I'm using i3wm. In there, I can get the Chinese input from Fcitx working both on X windows, as well as on emacs.

But when I'm using exwm, I can't get the Chinese input to enable in the emacs' input buffers. Only in the X windows.

Some relevant bits of config I've had to set for it to work in emacs (without exwm):

/etc/locale.conf - had to set LC_CTYPE to zh_CN.UTF-8 to get emacs to accept the input.

LANG=en_GB.UTF-8
LANGUAGE=en_GB
LC_CTYPE=zh_CN.UTF-8

~/.xprofile and ~/.pam_environment - set this on both files, to force fcitx to be used by all modules.

export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export QT4_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

The way I'm launching emacs as a exwm is by having an xsession launched by SDDM, with the following .desktop file:

[Desktop Entry]
Name=EXWM
Comment=Emacs Window Manager
Exec=env XMODIFIERS=@im=fcitx LC_CTYPE=zh_CN.UTF-8 sh /home/tiago/.emacs.d/exwm/start-exwm.sh
TryExec=sh
Type=Application
X-LightDM-DesktopName=exwm
DesktopNames=exwm

Again fruitlessly attempting to force the XMODIFIERS and the LC_CTYPE, to no avail (tried it without too, but no luck).

The start-exwm.sh launches emacs as follows:

exec dbus-launch emacs -mm --debug-init

I don't think I'm doing anything ridiculous, and it works fine if I'm not using exwm. But adding exwm to the mix seems to break fcitx on the emacs own file buffers, and I'm struggling to figure out why.

Does anyone have any ideas or ran into the same issue? I'd prefer not to have to use fcitx for QT/GTK, and emacs' internal Chinese input method for internal buffers, separately...

etiago commented 3 years ago

Just to add that I've been trying different approaches, and Ibus faces exactly the same issue. If I change my whole configuration to launch an ibus-daemon, and use ibus instead of fcitx in the environment variables, I am able to use both PinYin (Chinese) input on GTK and QT windows (e.g., Firefox, Telegram, etc) but emacs (using exwm) doesn't take it.

It seems like exwm isn't following the XMODIFIERS choice of input method...

molekular commented 3 years ago

Hi, could you solve it by now? I am by far not an expert on this - but you might want to check out https://github.com/tumashu/pyim as an input method if you use EXWM. It uses the XIM x windows input method (https://www.x.org/releases/X11R7.7/doc/libX11/XIM/xim.html#Introduction) which works well for EXWM emacs buffers and most applications. Downside: Only if they are not Qt5 applications - XIM doesn't work there yet, I think. For those I could not find a solution yet.

etiago commented 3 years ago

Thanks for your reply @molekular :slightly_smiling_face:

I didn't manage to fix it per se... but I did end up doing what you suggested. I have fcitx5 for X apps and pyim for emacs itself. It's not perfect, but does the job :slightly_smiling_face:

xiaoyuechen commented 2 years ago

This bug occurs to me as well. Neither fcitx or ibus works in emacs buffers of the EXWM emacs instance. However, if I start another emacs instance from EXWM, fcitx and ibus work fine. They also work in any other X windows.