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

Add local position property to touch and pointer events #2785

Merged
merged 10 commits into from
May 16, 2023

Conversation

wmww
Copy link
Contributor

@wmww wmww commented Jan 14, 2023

For #1792 we'll want to pass events from the frontend to the window manager. In order to meaningfully use them events will need to preserve global position in addition to local position.

@codecov
Copy link

codecov bot commented May 8, 2023

Codecov Report

Merging #2785 (2b1b276) into main (1cffa30) will decrease coverage by 0.02%.
The diff coverage is 86.95%.

@@            Coverage Diff             @@
##             main    #2785      +/-   ##
==========================================
- Coverage   78.36%   78.35%   -0.02%     
==========================================
  Files        1052     1053       +1     
  Lines       71877    71905      +28     
==========================================
+ Hits        56327    56338      +11     
- Misses      15550    15567      +17     
Impacted Files Coverage Δ
include/common/mir/events/touch_contact.h 100.00% <ø> (ø)
src/server/frontend_wayland/wl_pointer.h 100.00% <ø> (ø)
...er/frontend_xwayland/xwayland_surface_observer.cpp 0.00% <0.00%> (ø)
src/server/frontend_wayland/wl_pointer.cpp 51.30% <80.00%> (-1.28%) ⬇️
src/server/frontend_wayland/wl_touch.cpp 91.56% <81.81%> (-2.62%) ⬇️
src/common/events/event_helpers.cpp 100.00% <100.00%> (ø)
src/common/events/pointer_event.cpp 70.00% <100.00%> (+2.30%) ⬆️
src/common/events/touch_event.cpp 89.87% <100.00%> (+0.98%) ⬆️
src/server/input/surface_input_dispatcher.cpp 89.09% <100.00%> (+0.13%) ⬆️
...unit-tests/input/test_surface_input_dispatcher.cpp 97.64% <100.00%> (ø)

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@wmww wmww marked this pull request as ready for review May 8, 2023 19:42
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 is slightly confusing to me, but I think I see what's happening.

There's a nit to fix, and we should work out what the miroil behaviour should be before landing it, I think.

@@ -84,6 +84,20 @@ void MirTouchEvent::set_position(size_t index, geom::PointF position)
contacts[index].position = position;
}

std::optional<geom::PointF> MirTouchEvent::local_position(size_t index) const
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - we've been spelling this auto MirTouchEvent::local_position(size_t index) const -> std::optional<geom::PointF>

Comment on lines -484 to +485
EXPECT_CALL(*surface, consume(mt::TouchEvent(0,0))).Times(1);
EXPECT_CALL(*surface, consume(mt::TouchUpEvent(0,0))).Times(1);
EXPECT_CALL(*surface, consume(mt::TouchEvent(1,1))).Times(1);
EXPECT_CALL(*surface, consume(mt::TouchUpEvent(1,1))).Times(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these changes correct? It looks to me like we're creating a 1×1 surface at (1,1), and then touching at (1,1), which should be (0,0) in surface coordinates?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right. No, because we're now sending absolute coordinates through to consume(), but we only send the local coordinates contained within the event through to the wl_surface?


void miroil::dispatch_input_event(const miral::Window& window, const MirInputEvent* event)
{
if (auto surface = std::shared_ptr<mir::scene::Surface>(window))
{
surface->consume(mir::events::clone_event(*event));
std::shared_ptr<MirEvent> const clone = mir::events::clone_event(*event);
// Unclear if this is the right thing to do
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably work out whether or not this is the right thing to do before landing, yes?

Copy link
Contributor Author

@wmww wmww May 15, 2023

Choose a reason for hiding this comment

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

The really correct thing to do would be to allow miroil to create input events with local and global positions. Should probably introduce methods into it's event builder that allow that. Also should change this to be more correct until it updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, adding that api is just introducing more areas for possible confusion. Should probably wait until they need it.

@wmww
Copy link
Contributor Author

wmww commented May 15, 2023

Oh! Elegant solution to the clumsy event positions transformers: allow mapping all positions in an event with one method.

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.

Yeah, that's a nice simplification.

There's still a style nit, but that's fine.

@RAOF RAOF added this pull request to the merge queue May 16, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 16, 2023
@AlanGriffiths AlanGriffiths added this pull request to the merge queue May 16, 2023
Merged via the queue into main with commit a056287 May 16, 2023
@AlanGriffiths AlanGriffiths deleted the events-local-positions branch May 16, 2023 09:37
@wmww
Copy link
Contributor Author

wmww commented May 16, 2023

Oops, sorry didn't see that

@AlanGriffiths AlanGriffiths mentioned this pull request May 18, 2023
AlanGriffiths added a commit that referenced this pull request May 18, 2023
Saviq added a commit that referenced this pull request May 18, 2023
wmww added a commit that referenced this pull request May 19, 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

3 participants