Skip to content

on_focus_change erroneously invoked on every loop with sway+fcitx5 #7396

@mochaaP

Description

@mochaaP

Describe the bug
When Fcitx 5 is enabled on Sway, on_focus_change is repeatedly called due to multiple wl_keyboard's existence. (e.g. on Sway, virtual keyboard and physical keyboard are two different objects.)

To Reproduce
Steps to reproduce the behavior:

  1. Install fcitx 5.1.9, Sway 1.9, kitty
  2. Run kitty --config NONE --debug-keyboard
  3. Activate input method and try focusing different windows
  4. See on_focus_change spam in logs, CPU time spike on calls to libxkbcommon

Environment details

kitty 0.34.1 created by Kovid Goyal
Linux thonkbook 6.9.0-0.rc5.20240424git9d1ddab261f3.46.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 24 15:05:48 UTC 2024 x86_64
S
Kernel 6.9.0-0.rc5.20240424git9d1ddab261f3.46.fc41.x86_64 on an x86_64 (/dev/tty)

Running under: Wayland (swayfx version 0.3.3 (based on sway 1.9.0)) missing: blur
OpenGL: '4.6 (Core Profile) Mesa 24.0.5' Detected version: 4.6
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib64/kitty
  extensions dir: /usr/lib64/kitty/kitty
  system shell: /usr/bin/fish

Config options different from defaults:

Important environment variables seen by the kitty process:
	PATH                                /opt/cosmo/bin:/home/mochaa/ghq/github.com/google/purr/scripts:/home/mochaa/.local/bin:/home/mochaa/.local/share/solana/install/active_release/bin:/home/mochaa/.local/share/luarocks/bin:/home/mochaa/.local/share/cargo/bin:/home/mochaa/.local/share/go/bin:/home/mochaa/.local/share/cabal/bin:/home/mochaa/.local/share/pnpm/bin:/home/mochaa/.local/share/deno/bin:/home/mochaa/.local/share/bun/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
	LANG                                en_US.utf8
	EDITOR                              nvim
	SHELL                               /usr/bin/fish
	GLFW_IM_MODULE                      ibus
	DISPLAY                             :0
	WAYLAND_DISPLAY                     wayland-1
	USER                                mochaa
	XCURSOR_SIZE                        24
	XDG_DATA_HOME                       /home/mochaa/.local/share
	XDG_RUNTIME_DIR                     /run/user/1000
	XDG_SESSION_DESKTOP                 sway
	XDG_VTNR                            4
	XDG_STATE_HOME                      /home/mochaa/.local/state
	XDG_SESSION_CLASS                   user
	XDG_CONFIG_HOME                     /home/mochaa/.config
	XDG_SESSION_ID                      5
	XDG_CACHE_HOME                      /home/mochaa/.cache
	XDG_DATA_DIRS                       /home/mochaa/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/
	XDG_CURRENT_DESKTOP                 sway
	XDG_SEAT                            seat0
	XDG_SESSION_TYPE                    wayland

Additional context
Notes from fcitx5 developer @/wengxt:

There was a behavior change in fcitx, where it only creates virtual keyboard alongside creating the input method. I don't think this is wrong and this won't be reverted.

Maybe the initial trigger was the second wl_keyboard.enter, because I don't see any other text-input v3 clients doing wl_keyboard.leave on start
So it's almost certainly an issue on kitty's side
Probably the second wl_keyboard.enter triggered kitty's on_focus_change

I think the core issue is text_input's enable/disable should be triggered by text_input_enter / text_input_leave instead of wl_keyboard's enter/leave.

Also it's worth mentioning that multiple wl_keyboard objects could co-exisist.

flamegraph

wl-debug.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions