Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

implement text-input and input-method protocol support #12

Closed
wants to merge 3 commits into from

Conversation

Shugyousha
Copy link
Contributor

This is mostly copied from the sway implementation here:

https://github.com/swaywm/sway/pull/4740/files

I have confirmed that with these implementations, dwl behaves the same as sway when we run the input-method and text-input examples of wlroots.

I have tried to run other input-method implementations for testing but both https://github.com/emersion/wlhangul and https://github.com/xdavidwu/wlchewing depend on further protocols being implemented (both need virtual-keyboard protocol support and wlhangul some extra patches IIRC) before they can be tested.

I will try to prepare some more testing (I'm currently checking if I can manage to implement input-method V2 easily in ibus, see here ibus/ibus#2182) but until I'm done with that you can have a first look at the code.

Base automatically changed from master to main February 16, 2021 19:18
@Shugyousha
Copy link
Contributor Author

I have wanted to give an update on the current state of this PR since
it has been a while ...

I have tried to implement input-method V2 in ibus here
ibus/ibus#2256 but unfortunately got stuck
(any help would be appreciated!).

Luckily I have found https://github.com/tadeokondrak/anthywl
which is an input method with input_method v2 protocol support
that also implements the input method popup support. Anthywl has
allowed me to test that the code that I have mostly copied from
swaywm/sway#5890 (for the input popup
implementation) and from the sway implementation of the input method V2
protocol (see above) is working okayish on dwl as well (you will need
to patch wlroots with swaywm/wlroots#2550 for
the input method popup support before you will be able to test this).

Note that this is (quite) a lot of code to implement functionality
that is depending on currently still unstable and faulty wayland
protocols. Other helpful devs have documented the state of these protocols
at https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/39
and the issues that they still have at the following link:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/40

Given that the area of input methods on Wayland is still very much
in flux it probably makes sense to wait with merging this PR. I would
suggest to leave this PR open in a draft state for now so that people
that want to experiment with these protocols and their implementations
can more easily do so.

What do you think?

@guyuming76
Copy link

@Shugyousha , i cloned https://github.com/Shugyousha/dwl/tree/input-protocols , but it failed to make, i guess i might be incompatible wlroots version, could you please let me know what version of wlroots to work with?

@Shugyousha
Copy link
Contributor Author

Shugyousha commented Apr 9, 2022 via email

@guyuming76
Copy link

I just tried to compile dwl on my machine using the newest git and non-git version of wlroots that is available on my Linux distribution. Neither the git nor the non-git version of wlroots made dwl (main or wlroots-next) compile on my machine for me.

i tried:

git clone https://gitlab.freedesktop.org/wlroots/wlroots.git
cd wlroots
git checkout 0.15.1
meson build/
sudo ninja -C build/ install

cd ~
git clone https://github.com/djpohly/dwl.git
cd dwl
make

it compiles fine.

but if i try:

git clone https://github.com/Shugyousha/dwl.git dwl-ime
cd ~/dwl-ime
git checkout input-protocols
make

it prompts compile error. i guess i should enter the wlroots folder and git checkout some_commit_id and reinstall, the some_commit_id can be that you compile your code with when you made the pull request. but i don't know what is the some_commit_id.

@Shugyousha
Copy link
Contributor Author

Shugyousha commented Apr 10, 2022 via email

@guyuming76
Copy link

guyuming76 commented Apr 12, 2022

@Shugyousha I made changes to current dwl.c based on your pull request, and add text_input.c text_input.h files so that i can make changes to dwl.c as little as possible.

i commented out most popups related code since i cannot pass compilation with them. But konsole works with fcitx5 on my machine now. However, other VTs such as foot and alacritty does not work with fcitx5. I wonder if it is related with the "popups" code.

i have some technical issue with pushing to github, so i published my change here: https://gitee.com/guyuming76/dwl/tree/guyuming1

update: turned out i can input Chinese in konsole with fcitx5, no need for any change to dwl. with dbus-monitor, i can see that konsole communicate with fcitx5 via dbus, but alacritty don't.

The problem is i change from xorg to wayland because i heard that in x, one window can get key event of another window. Now if we rely on dbus, will one window in wayland still be able to get IME input of another wayland window thought dbus message sniffering?

@guyuming76
Copy link

@Shugyousha , your code now compiles fine on my machine: https://gitee.com/guyuming76/dwl/tree/guyuming3 . However, it gives sigsegv error as screenshot i put in fcitx/fcitx5#481 , when i press ctrl+space in alacritty to switch to IME.

i think the problem is with the line 2595 in https://github.com/djpohly/dwl/pull/12/files :client = client_from_wlr_surface(surface)

the left side of assignment is of type Client, while the right side is surface->data, which can be of type struct wlr_scene_node *

image

I compare your input_popups_set_focus implementation with that in https://github.com/swaywm/sway/pull/5890/files , the problem of which is that the view_from_wlr_surface function implementation does not return anything!

@guyuming76
Copy link

i seemed to make it work, that is, i can input Chinese in alacritty: https://gitee.com/guyuming76/dwl/commits/guyuming4

but i am facing sigsegv error with Xwayland unmanaged window, i have some screenshots here https://gitee.com/guyuming76/personal/commit/45d2e97adc98e483ef990cd45bcd5aca463a361b

and i raised a question here: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3427

@Shugyousha
Copy link
Contributor Author

Shugyousha commented May 9, 2022 via email

@guyuming76
Copy link

i just summarized my "rebase" here: (https://gitee.com/guyuming76/dwl/commit/f82c23c196e2c3f1d1997812bff473eae2a20a10 ), gitee now support github and gitlab account sign-in.

@Shugyousha
Copy link
Contributor Author

I have rebased this code so it should work on main. Here is the updated PR: #235

Note that there are still issues but at least now the code compiles and works (mostly) again. Let's move all discussion to the new PR.

@Shugyousha Shugyousha closed this May 15, 2022
@yoandrisolis yoandrisolis mentioned this pull request Jul 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants