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

(#2777) Tests for input-method-v1 #302

Merged
merged 15 commits into from
Aug 21, 2023
Merged

(#2777) Tests for input-method-v1 #302

merged 15 commits into from
Aug 21, 2023

Conversation

mattkae
Copy link
Contributor

@mattkae mattkae commented Aug 16, 2023

input-method-v1

What's new?

  • Wrote a bunch of tests for input-method-v1
  • I purposefully left out some tests as they are unimplemented in Mir for now, but these will cover some good initial ground

@mattkae mattkae requested review from Saviq and RAOF August 17, 2023 13:31
Copy link
Contributor

@RAOF RAOF left a comment

Choose a reason for hiding this comment

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

This looks pretty good all up.

The two pervasive issues are cross-client synchronisation (which should probably use dispatch_until on the receiving end), and serial handling for update_state. The latter is important because a compositor could reasonably discard any update_state requests with an incorrect serial - after all, they're attempting to update no-longer-valid state.

struct TextInputV2WithInputMethodV1Test : wlcs::StartedInProcessServer
{
TextInputV2WithInputMethodV1Test()
: StartedInProcessServer{},
Copy link
Contributor

Choose a reason for hiding this comment

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

We have traditionally not explicitly called the superclass constructor unless it's necessary (to pass parameters down). It's not wrong, though.

Comment on lines +52 to +54
the_server().move_surface_to(app_surface.value(), 0, 0);
pointer.move_to(10, 10);
pointer.left_click();
Copy link
Contributor

Choose a reason for hiding this comment

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

We really need to make this an explicit interface of the WLCS integration 😉

(That's not something to be here, to be clear, just pointing this out to remind everyone including myself)

{
create_focused_surface();
zwp_text_input_v2_enable(text_input, app_surface->wl_surface());
zwp_text_input_v2_update_state(text_input, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to use the symbolic update_state reason here.

Also, I think this is wrong? As far as I can tell:

  • You don't need to send an update_state in order for enable to be processed - the protocol is unclear, but it doesn't say enable is double-buffered state committed by update_state, and it's not important that it be associated with a particular batch of changes
  • The serial here should be from an enter (or input_method_changed) event. We should have got one of those as a part of the surface being focused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • In our text-input-v2 implementation, that request is left "pending" until an update_state comes through, which would make it such that the input-method-v1 never gets activated. Perhaps our implementation is wrong? It could be...
  • Agreed!

zwp_text_input_v2_enable(text_input, app_surface->wl_surface());
zwp_text_input_v2_update_state(text_input, 0, 0);
app_client.roundtrip();
input_client.roundtrip();
Copy link
Contributor

Choose a reason for hiding this comment

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

These cross-client synchronisation requirements are hard; it's possible this is racy (I don't think it is in Mir, but I don't believe the protocol guarantees it isn't).

Probably you want to do app_client.roundtrip() and then input_client.dispatch_until(...) for the input client.

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 think I did this correctly now 🤔 Let me know!

app_client.roundtrip();
input_client.roundtrip();
zwp_text_input_v2_disable(text_input, app_surface->wl_surface());
zwp_text_input_v2_update_state(text_input, 1, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I'm reasonably confident that enable/disable does not require committing with update_state.

const size_t data_length = 33;
wl_array map;
wl_array_init(&map);
const char** data = static_cast<const char**>(wl_array_add(&map, sizeof(char) * data_length));
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: You can probably declare this as auto data, as you're explicitly casting on the rhs?

@mattkae mattkae requested a review from RAOF August 18, 2023 19:48
Copy link
Contributor

@RAOF RAOF left a comment

Choose a reason for hiding this comment

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

LGTM now!

@RAOF RAOF added this pull request to the merge queue Aug 21, 2023
Merged via the queue into main with commit 4c6db9a Aug 21, 2023
9 checks passed
@RAOF RAOF deleted the feature/2777 branch August 21, 2023 08:22
@Saviq Saviq mentioned this pull request Dec 14, 2023
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.

None yet

2 participants