Skip to content

Report cursor size to input method #2918

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dcz-self
Copy link

@dcz-self dcz-self commented May 1, 2025

This is a follow-up to https://discourse.iced.rs/t/better-input-method-suport-on-wayland/973 .

The input method may place a popup with suggestions on the screen. For this, it needs to know the area that should not be covered. That's the cursor rectangle in winit.

So far, the size of the rectangle has been hardcoded to 10x10px. This fills it with actual line height.

Testing: working on it (I am not aware of any input method that uses it yet, and I'm currently checking anvil's implementation).

This does not take preedit into account. Depending on the wishes of the reviewer, I can submit that in the same or separate MR once it's done.

Background for this change: I have NLNet support to make Wayland input method support awesome (or at least not suck as much). I need a toolkit where it works great, and I can pull iced to that level.

@dcz-self
Copy link
Author

dcz-self commented May 2, 2025

For your testing convenience:

Tested on an updated anvil: https://github.com/dcz-self/smithay

cd anvil
cargo run -- --winit

Client using iced: https://codeberg.org/dcz/wlimfeld

# first download iced to ../iced
WAYLAND_DISPLAY=wayland-1 cargo run

Input method that actually requests a popup is https://codeberg.org/dcz/stiwri.git .

git checkout im
WAYLAND_DISPLAY=wayland-1 cargo run --bin im_popup

The change will be barely visible at this point: the popup is going to be a couple piels higher or lower. More dramatic difference expected once the input method side implements better positioning.

@kenz-gelsoft
Copy link
Contributor

@hecrj I can agree to pass the caret Rectangle instead of the caret's bottom-left Point. As this PR fixes my ad-hoc caret size specification to 10x10.

Though I don't sure the caret width should be 0 or other values e.g. includes preedit width.

BTW, I think this PR should be a draft as this doesn't change documentation comment.

@dcz-self
Copy link
Author

dcz-self commented May 4, 2025

I'm sure that setting the size to 0 is wrong. The cursor area is where the window manager attaches the input method popup, so it's rather "the area that should not be covered", rather than just the cursor. I guess that would mean preedit area?

Like I wrote in the other comment, I can take the preedit into account. I would appreciate some feedback about how the non-cover area should behave then.
Should it be both the preedit and the caret, like this?
Screenshot_20250504_072735
Or should it be just the preedit, like this?
Screenshot_20250504_072928

If the caret is in the keep-away area, then there's also the decision if the popup is allowed to cover the selected text or not.

@dcz-self
Copy link
Author

dcz-self commented May 4, 2025

It seems I misclicked when commenting -_- Can this be reopened?

Regarding the draft, I'd rather fix the shortcomings than back down. Comment altered.

@kenz-gelsoft
Copy link
Contributor

You should be able to reopen your own PR, but I recommend to open new one as this PR looks something wrong, it shows no commits.

@dcz-self dcz-self reopened this May 4, 2025
@dcz-self
Copy link
Author

dcz-self commented May 4, 2025

Apparently a misclick was not the only thing I did wrong. I also pushed the wrong branch. Mornings are like that, I guess.

Anyway, I'm ready to apply your guidance as to what this should look like next.

@kenz-gelsoft
Copy link
Contributor

I'm sure that setting the size to 0 is wrong.

I didn't say the size should be 0. I said that
I am not sure if it is correct caret area width is 0 like your fix.

BTW, I am not a member who have review/merge right. So addressing my comments won't guarantee landing your change.

I advice you to file an issue first which describes the problem this PR will fix. Read the contribution guidelines.

@dcz-self
Copy link
Author

dcz-self commented May 5, 2025

Let me correct myself: I'm sure setting the width to 0 is wrong for 99% of cases.

I think if you wrote the previous version, then it shows your expertise in the topic and hopefully gives you some authority on this subject area within the project.

But I can't force you if you don't want to comment on the contents of this change.

Regarding contributions, https://discourse.iced.rs/t/better-input-method-suport-on-wayland/973 but I got tired of waiting and decided to post what I already had.

@dcz-self
Copy link
Author

Bump. Is there any interest in input methods? I wouldn't want to put in lots of effort into something that's gets forgotten.

@Decodetalkers
Copy link
Contributor

seems good enough, I hope this pr will be merged soon

@hecrj
Copy link
Member

hecrj commented May 13, 2025

There are 104 PRs open, and I have to review all of them.

Take a seat and relax. Will take some time.

@dcz-self
Copy link
Author

I'm asking for the sake of future work. I intend to implement all the incoming updates to text-input, and I wouldn't want to choose a project that doesn't want them :p

But from the answers so far I don't think that's the case, so I'll continue down that path (but only while the NLNet support continues).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants