Skip to content

Conversation

dcz-self
Copy link
Contributor

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

Implements https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/407

Notably missing: repositioning, reactivity of the popup.

EDIT: this replaces the previous input method for now, so I made it a draft instead.

@dcz-self
Copy link
Contributor Author

To test:

# in anvil
cargo run --release -- --winit &
WAYLAND_DISPLAY=wayland-1 yad &
# in stiwri
WAYLAND_DISPLAY=wayland-1 cargo run --release --bin im_popup

@dcz-self
Copy link
Contributor Author

@dcz-self dcz-self changed the title Add xx_input_method_v1 support. DRAFT: Add xx_input_method_v1 support. May 23, 2025
@dcz-self
Copy link
Contributor Author

Lookng at CI failures, I need some help understanding what they are.

For example, this code wasn't even touched by my change.

  error: fields `popup_geometry_callback`, `new_popup`, and `popup_repositioned` are never read
     --> src/wayland/input_method/input_method_handle.rs:172:16

There's also the ack_configure callback which is for some reason exposed to the compositor, but I don't really understand why, so I couldn't come up with a sensible doc comment.

@ids1024
Copy link
Member

ids1024 commented May 23, 2025

For example, this code wasn't even touched by my change.

I think that's a result of the earlier warning. Because certain methods are never used, the variables that are read only in those methods are never read.

@dcz-self
Copy link
Contributor Author

Added repositioning:

WAYLAND_DISPLAY=wayland-1 cargo run --release --bin im_popup_reposition
Screencast_20250524_202116.webm

@dcz-self dcz-self force-pushed the im_popup branch 2 times, most recently from 335ccb6 to 9497a8f Compare May 25, 2025 13:25
@dcz-self
Copy link
Contributor Author

I did some cleanups:

  • lints, except the ack_configure which I don't understand
  • both input methods are supported and working

Is there anything I can do to make reviewing this easier?

@dcz-self dcz-self changed the title DRAFT: Add xx_input_method_v1 support. Add xx_input_method_v1 support. May 25, 2025
match *self {
PopupKind::Xdg(ref t) => t.send_popup_done(),
PopupKind::InputMethod(_) => {} //Nothing to do the IME takes care of this itself
PopupKind::InputMethodV3(_) => {} //Nothing to do the IME takes care of this itself
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be useful as a way to communicate that the compositor closed the popup? Or is it redundant since normally that would follow from a deactivate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was nothing to do previously since there was no concept of how the popup should function. But you are free to add that now if it is needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the only time the compositor closes the popup is in deactivate, so I decided there's no need for another notification. Would one be useful?

@rano-oss
Copy link
Contributor

run these on your branch and correct them btw:
cargo clippy --features "test_all_features" -- -D warnings
cargo fmt --all -- --check
cargo hack check --each-feature --no-dev-deps --exclude-features use_bindgen

@rano-oss
Copy link
Contributor

rano-oss commented Jun 11, 2025

LGTM otherwise, someone that knows xdg positioner should probably have a look at the positioner and popup part

@dcz-self
Copy link
Contributor Author

The only thing left that breaks ci is the ack_configure which I have no idea what to do with.

@rano-oss
Copy link
Contributor

Just add documentation to this function:

error: missing documentation for a method
   --> src/wayland/input_method_v3/mod.rs:131:5
    |
131 | /     fn popup_ack_configure(
132 | |         &mut self,
133 | |         _surface: &WlSurface,
134 | |         _serial: Serial,
135 | |         _client_state: PopupSurfaceState,
136 | |     ) {
    | |_____^
    |
    = note: `-D missing-docs` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(missing_docs)]`

@dcz-self
Copy link
Contributor Author

Well that's the problem, I don't have a clue what it's meant to do :P I copy-pasted it without understanding and I hope a reviewer can enlighten me.

@dcz-self
Copy link
Contributor Author

This now relies only on published protocols now that experimental is out.

Comment on lines +190 to +191
pub(crate) input_method_handle: input_method::InputMethodHandle,
pub(crate) input_method_v3_handle: input_method_v3::InputMethodHandle,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have two input methods at once. Including using different protocols. Maybe it would make sense if these were grouped together into a single enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works, because those are slots for input methods that may be filled in at any time. See a couple lines below:

if !data.input_method_handle.has_instance() && !data.input_method_v3_handle.has_instance() {

The instance for either may not be present, and because the Option is rather deeply nested (even behind a mutex each), there's no way to turn it into an enum.

I don't remember why it is so, but I do remember originally not liking it and exposing the Option directly. Eventually I just had to copy the same design in v3.

Copy link
Contributor

@rano-oss rano-oss Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually having two at once should be just fine, it depends on how it is used but functionally there really isn't any problem. Though I have only tested it locally, so take my word for it ;)

Copy link
Contributor

@rano-oss rano-oss Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would even go so far as to say that several input method instances is a wanted feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you had to input methods clients though, won't both try to create a popup at the same time, and potentially insert text in response to the same input?

I don't know if there's really a way with the design of this protocol (any version) to have reasonable behavior with multiple input method engines running at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO multiple input methods only work with handover of the protocol. But handover is outside of scope for this, so this MR doesn't allow multiple input method clients.

Copy link
Contributor

@rano-oss rano-oss Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not really be a problem, as long as one has a one-to-one relationship between text-input client and input method client. Input method 1 would have a list [ti1, ti2, t3] and input method 2 [t3, t4, t5]. We can make sure they never overlap in the compositor. Also about the popup, each IME should just own their popup. There is nothing really needed in the protocol to support this, just remove the part that allows only one. I would make a POC if life wasn't in the way currently, maybe in 6 months.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I get the problem, if v2 and v3 don't have a way to separate which IME own which text input then double input methods are definitely a problem.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually only one input method are allowed in the system. So we only process the first request of creating input method?

@dcz-self dcz-self force-pushed the im_popup branch 3 times, most recently from abaea9b to 5c40b3a Compare August 14, 2025 08:03
@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 2.17654% with 809 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.05%. Comparing base (ec35248) to head (5c40b3a).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/wayland/input_method_v3/positioner.rs 0.00% 242 Missing ⚠️
src/wayland/input_method_v3/input_method_handle.rs 0.00% 190 Missing ⚠️
...land/input_method_v3/input_method_popup_surface.rs 0.00% 188 Missing ⚠️
src/wayland/input_method_v3/mod.rs 21.25% 63 Missing ⚠️
anvil/src/state.rs 2.43% 40 Missing ⚠️
src/wayland/input_method_v3/configure_tracker.rs 0.00% 24 Missing ⚠️
src/wayland/text_input/text_input_handle.rs 0.00% 19 Missing ⚠️
anvil/src/shell/mod.rs 0.00% 13 Missing ⚠️
src/wayland/seat/keyboard.rs 0.00% 11 Missing ⚠️
src/desktop/wayland/popup/mod.rs 0.00% 9 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1745      +/-   ##
==========================================
- Coverage   18.89%   18.05%   -0.85%     
==========================================
  Files         176      181       +5     
  Lines       27672    28543     +871     
==========================================
- Hits         5230     5154      -76     
- Misses      22442    23389     +947     
Flag Coverage Δ
wlcs-buffer ?
wlcs-core 15.70% <2.17%> (-0.43%) ⬇️
wlcs-output 6.70% <2.17%> (-0.15%) ⬇️
wlcs-pointer-input 17.38% <2.17%> (-0.47%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dcz-self
Copy link
Contributor Author

Rebased.

Experimental protocol version from July 2025, including popup.
@dcz-self
Copy link
Contributor Author

Rebased again.

where
D: Dispatch<ZwpTextInputV3, TextInputUserData>,
D: SeatHandler,
//D: input_method_v3::InputMethodHandler,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why it is here?

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.

5 participants