# Alacritty stopped accepting keyboard input on X11 due to a wedged fcitx XIM context


One of my Alacritty windows on Linux Mint (X11/Cinnamon) suddenly stopped accepting keyboard input while holding an active tmux and SSH session. Other Alacritty windows on the same desktop kept working normally.

The terminal itself was not frozen: the tmux status clock kept ticking, the SSH connection stayed alive, and Alacritty&#39;s IPC socket answered immediately. **A wedged `fcitx` XIM context for that single window was swallowing every X11 `KeyPress` before it reached Alacritty&#39;s keyboard handler.** Restarting `fcitx` (`fcitx -r -d`) recovered the window in place without closing it, and launching Alacritty with `XMODIFIERS=@im=none` prevents the freeze from coming back.

&lt;!--more--&gt;

## Problem 1: One Alacritty window silently drops all keystrokes

Before touching the session, I checked each layer in the input path from another terminal:

1. **Alacritty process &amp; event loop**: `alacritty msg --socket /run/user/1000/Alacritty-:0-&lt;pid&gt;.sock get-config` returned immediately with exit code `0`, and the tmux clock inside the window continued updating every second.
2. **PTY &amp; tmux**: `stty -a -F /dev/pts/&lt;N&gt;` showed no `ixon` / Ctrl-S flow-control freeze; `tmux list-clients` and `tmux display-message` showed the pane was not dead, not in copy/Vi mode, and not read-only.
3. **SSH**: `ss -tipn` showed `Recv-Q=0`, `Send-Q=0`, and active keepalive traffic on the TCP socket.

With tmux and SSH ruled out, the drop had to be inside X11 / `winit` / IME. Comparing the stuck Alacritty instance against a healthy one exposed the exact point of failure:

- Tracing `recvmsg` on the stuck Alacritty&#39;s X11 socket (`strace -e trace=recvmsg -x -p &lt;pid&gt;`) showed that X11 `KeyPress` events **did** arrive at the window, and Alacritty forwarded them to `fcitx` over `_XIM_PROTOCOL` `ClientMessage` events.
- However, `fcitx` never sent `XIM_FORWARD_EVENT` back for that window&#39;s XIM input context.
- In `winit` on X11 (`winit/src/platform_impl/linux/x11/event_processor.rs`), key events are passed through `XFilterEvent`:

```rust
let filtered = forward_to_ime &amp;&amp; self.filter_event(xev);
if filtered {
    return;
}
```

When `fcitx`&#39;s XIM state gets wedged for a window, `XFilterEvent` consumes the `KeyPress` (`True`) and `fcitx` never forwards it back. Setting a breakpoint on Alacritty&#39;s keyboard entry point (`alacritty/src/input/keyboard.rs:22`) and sending a harmless `Shift_L` key event confirmed it:

- Working Alacritty window: **2 hits** (press &#43; release)
- Stuck Alacritty window: **0 hits**

Because each window has its own XIM input context (`XIC`), one Alacritty window can freeze completely while other Alacritty windows keep working.

## Solution 1: Recover the stuck window in place

Reloading `fcitx` config alone is **not** enough—`fcitx-remote -r` keeps the same `fcitx` process and its wedged XIM context. You need to restart the `fcitx` daemon so `winit` tears down the stale XIM connection and creates a fresh one:

```bash
fcitx -r -d
```

After restarting `fcitx`:
- `strace` immediately showed `fcitx` returning `XIM_FORWARD_EVENT` (`0x2c`) for `KeyPress` and `KeyRelease` on the previously stuck window.
- The `Shift_L` probe hit `alacritty/src/input/keyboard.rs:22` **2/2 times**, matching the working window.
- No terminal windows, tmux sessions, or SSH connections had to be closed.

## Solution 2: Prevent the freeze permanently

All running Alacritty instances inherited `XMODIFIERS=@im=fcitx` from the desktop session. If you don&#39;t need Chinese/IME input inside Alacritty, disable XIM for Alacritty in `~/.local/share/applications/Alacritty.desktop`:

```ini
[Desktop Entry]
Type=Application
TryExec=/home/william/.local/bin/alacritty
Exec=env XMODIFIERS=@im=none /home/william/.local/bin/alacritty
...

[Desktop Action New]
Name=New Terminal
Exec=env XMODIFIERS=@im=none /home/william/.local/bin/alacritty
```

&gt; **Important:** Keep `TryExec=` set to the plain binary path (`/home/william/.local/bin/alacritty`), **not** `env ...`. `TryExec` checks whether a single executable exists; putting `env XMODIFIERS=...` there marks the `.desktop` entry invalid.

Validate the file and update the desktop database:

```bash
desktop-file-validate ~/.local/share/applications/Alacritty.desktop
update-desktop-database ~/.local/share/applications
```

Any new Alacritty window launched from the menu (and any window spawned from it via `Ctrl&#43;Shift&#43;Return`) will inherit `XMODIFIERS=@im=none` and bypass `fcitx` XIM. Existing Alacritty processes keep their old environment until reopened.

*(If you do need IME inside Alacritty, keep `fcitx -r -d` handy as an in-place recovery command, or consider migrating from `fcitx4` to `fcitx5`.)*

## Problem 2 (Gotcha): Alacritty disappears from the Linux Mint menu after editing `.desktop`

If `Alacritty.desktop` is ever saved in an invalid state even briefly (for example, if `TryExec=` is accidentally changed while editing `Exec=`), Cinnamon&#39;s `CMenu` library can cache a `null` `app_info` entry for that file. Even after you fix the file and run `touch` &#43; `update-desktop-database`, searching `ala` in the Mint system menu will stop matching Alacritty.

### Fix: Evict Cinnamon&#39;s `CMenu` cache and reload the menu applet

1. Remove and recreate the `.desktop` file so Cinnamon&#39;s file monitor sees a delete &#43; create event:

```bash
mv ~/.local/share/applications/Alacritty.desktop /tmp/Alacritty.desktop.tmp
sleep 1
cp /tmp/Alacritty.desktop.tmp ~/.local/share/applications/Alacritty.desktop
rm -f /tmp/Alacritty.desktop.tmp
update-desktop-database ~/.local/share/applications
```

2. Reload the Cinnamon menu applet so its search index picks up the refreshed entry:

```bash
dbus-send --session --dest=org.Cinnamon --type=method_call --print-reply \
  /org/Cinnamon org.Cinnamon.ReloadXlet string:&#39;menu@cinnamon.org&#39; string:&#39;APPLET&#39;
```

3. Optionally verify directly inside the running Cinnamon session that `AppSystem` and `menu@cinnamon.org` both have `Alacritty`:

```bash
dbus-send --session --dest=org.Cinnamon --type=method_call --print-reply \
  /org/Cinnamon org.Cinnamon.Eval \
  string:&#39;(function(){ let s = imports.gi.Cinnamon.AppSystem.get_default(); let a = s.lookup_app(&#34;Alacritty.desktop&#34;); return a ? a.get_app_info().get_commandline() : &#34;NOT_FOUND&#34;; })()&#39;
```

Expected output:

```text
&#34;env XMODIFIERS=@im=none /home/william/.local/bin/alacritty&#34;
```


---

> 作者: william  
> URL: https://williamlfang.github.io/2026-12-03-alacritty-fcitx-xim-keyboard-freeze/  

