Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inputmethod, zwp_virtual_keyboard_v1 and text-input-v3 message loop with certain text-input-v3 implemenation #8143

Closed
wengxt opened this issue May 1, 2024 · 3 comments · Fixed by #8181
Labels
bug Not working as intended

Comments

@wengxt
Copy link

wengxt commented May 1, 2024

Please fill out the following:

  • Sway Version:

    • 1.9
  • Debug Log:

    • Run sway -d 2> ~/sway.log from a TTY and upload it to a pastebin, such as gist.github.com.
    • This will record information about sway's activity. Please try to keep the reproduction as brief as possible and exit sway.
    • Attach the full file, do not truncate it.
  • Description:
    In fcitx 5 5.1.9, fcitx changes how it handles the zwp_virtual_keyboard_v1, by only create zwp_virtual_keyboard_v1 object when input method is activated. The rational behind this is that, there was once people report bug about virtual keyboard key may be keep pressed, specifically for the modifier keys, and destroy virtual keyboard object itself, seems to clear out all such state that fcitx can't control when keyboard grab shouldn't be placed.

However, we see some infinite message loop triggered by this change in sway, because when zwp_virtual_keyboard_v1 is destroyed, sway will send a wl_keyboard.leave and immediately followed by another wl_keyboard.enter.

As seen in gtk's text-input-v3 and kovidgoyal/kitty#7396 .

They seems to associate the wl_keyboard focus with window focus, and thus, wl_keyboard.leave will trigger a window focus out, and thus send text-input-v3.disable.

The message loop looks like
sway: wl_keyboard.leave
-> gedit: text-input-v3.disable
-> sway: zwp_input_method_v2.activate
-> fcitx5 create_virtual_keyboard
-> wl_keyboard.leave & wl_keyboard.enter (triggered by virtual keyboard re-creation)
-> gedit: text-input-v3.disable / enable # <<----------- loop starts here.

While this seems to be a easy fix (only enable / disable after text-input-v3.enter), I still wonder if sway's behavior of wl_keyboard.enter & wl_keyboard.leave on virtual keyboard change is really a desirable behavior since it would trigger window focus change in client.

@wengxt wengxt added the bug Not working as intended label May 1, 2024
@wengxt
Copy link
Author

wengxt commented May 1, 2024

@wengxt
Copy link
Author

wengxt commented May 1, 2024

Sway current implemation seems to also a conflict between wl_keyboard.enter & text-input-v3.enter

text-input-v3 focus may not follow wl_keyboard focus in this case as seen in the message trace.

@wengxt
Copy link
Author

wengxt commented May 7, 2024

Specifically, the code here:

struct wlr_surface *surface = seat->wlr_seat->keyboard_state.focused_surface;

virtual keyboard is implemented as a "sway device" thus it may trigger the "synthetic" focus change here.

This somehow may mess up the application that relies on wl_keyboard.enter/leave to handle the window focus change. And it makes text-input-v3 focus and wl_keyboard focus inconsistent.

wengxt added a commit to fcitx/fcitx5 that referenced this issue May 7, 2024
This reverts commit b2924bd.

While I don't think it's doing anything wrong, but many wlroots
comopsitor does not like this and may make Gtk app choke.

(#1044, #1037, #1039)
swaywm/sway#8143
llyyr added a commit to llyyr/sway that referenced this issue May 25, 2024
llyyr added a commit to llyyr/sway that referenced this issue May 25, 2024
llyyr added a commit to llyyr/sway that referenced this issue Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Development

Successfully merging a pull request may close this issue.

1 participant