Skip to content

Mouse events#344

Merged
elinorbgr merged 14 commits intorust-windowing:masterfrom
Xaeroxe:mouse-events
Nov 12, 2017
Merged

Mouse events#344
elinorbgr merged 14 commits intorust-windowing:masterfrom
Xaeroxe:mouse-events

Conversation

@Xaeroxe
Copy link
Copy Markdown
Contributor

@Xaeroxe Xaeroxe commented Nov 6, 2017

Replaces #192

  • Resolves conflicts from that PR
  • Adds support for Windows and OSX

Ralith and others added 6 commits July 2, 2017 20:34
This makes the API more intuitive for common use-cases and allows us
to better propagate platform knowledge of motion semantics.
This emphasizes the difference between motion of the host GUI cursor,
as used for clicking on things, and raw mouse(-like) input data, as
used for first-person controls.
Copy link
Copy Markdown
Contributor

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

1f9afe7 (removing the Motion/Moved fix) bothers me a bit. Since this is a breaking change anyway, I'd like to make the event names consistent to reduce future frustration. This is not a blocker for merging because it's a pre-existing issue.

I'm in favor of the other changes, especially the mousewheel fixes--thanks! This should make the correct solution to typical gamedev mouse input significantly more obvious.

@Ralith Ralith mentioned this pull request Nov 7, 2017
Copy link
Copy Markdown

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

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

Nice 👍

},

/// Motion on some analog axis. May report data redundant to other, more specific events.
Motion { axis: AxisId, value: f64 },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure if I understood this. Does this mean that whether Motion events are also emitted for the mouse is platform-dependent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mouse events should be emitted on all major desktop platforms. Mouse events will also be accompanied by Motion events from the same device with the same deltas. Not all Motion events will be accompanied by Mouse events though, as some Motion events won't come from the Mouse.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could improve this comment to clearly note that Motion is a fallback event for any motion along axis that are not already handled by MouseMoved or MouseWheel (since it seems to be what your implementation does).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@vberger Oh hm woops, my Windows and OSX implementation of this behaves differently from the X11 implementation provided by @Ralith . I'm not using the motion events as a fall back, but I'm instead using them to accompany the mouse events. I'll need to get those behaviors in sync before we merge.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, I see. So, the actual intended behavior is for the generic Motion to repeat MouseMoved? Is there a clear reason for this repetition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Motion is good for being abstract over axes, so it makes sense to include mouse axes in that abstraction. MouseMoved is for when you don't want to be abstract over axes, and you just want the mouse.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Would be nice to include a detailed description of this in the docs given the confusion in these reviews.

@torkleyy
Copy link
Copy Markdown

torkleyy commented Nov 7, 2017

@Ralith I prefer the names that @Xaeroxe added since AxisMoved sounds a bit odd to me because it's not the axis that got moved.

@elinorbgr
Copy link
Copy Markdown
Contributor

Looks good to me modulo the doc nitpick. 👍

@Ralith
Copy link
Copy Markdown
Contributor

Ralith commented Nov 7, 2017

@torkleyy

I prefer the names that @Xaeroxe added since AxisMoved sounds a bit odd to me because it's not the axis that got moved.

I don't really care what the names are, it'd just be nice if they were consistent.

Copy link
Copy Markdown

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

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

I like it, but a more detailed description of the mouse / motion events as well as platform-specific behavior would be nice.

@torkleyy
Copy link
Copy Markdown

torkleyy commented Nov 7, 2017

@Ralith I'd like them to be consistent, too, is there any other place where AxisMoved has been used? Or is it about the Moved postfix?

@Ralith
Copy link
Copy Markdown
Contributor

Ralith commented Nov 7, 2017

The issue I was discussing was inconsistent use of "Moved" versus "Motion." I don't see a need to have both terms; the introduction of a second one was unintended.

@torkleyy
Copy link
Copy Markdown

torkleyy commented Nov 7, 2017

I see. Let's rename all the variants to *Motion then.

@tomaka
Copy link
Copy Markdown
Contributor

tomaka commented Nov 7, 2017

If we're breaking the API of Events, I think we should group all the changes concerning this enum in the same version in order to reduce friction.

@Xaeroxe
Copy link
Copy Markdown
Contributor Author

Xaeroxe commented Nov 7, 2017

r? @torkleyy @Ralith @vberger

@elinorbgr
Copy link
Copy Markdown
Contributor

looks like it needs a rebase. Likely a consequence of #342 which move the pointer logic for wayland into its own file.

@Xaeroxe
Copy link
Copy Markdown
Contributor Author

Xaeroxe commented Nov 12, 2017

@vberger I've resolved the conflict.

So what's the policy for merging PRs in this repo?

axis_buffer: Option<(f32, f32)>,
axis_discrete_buffer: Option<(i32, i32)>,
axis_state: TouchPhase,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it github messing up the displayed diff? It looks like you're undoing part of #342 by re-adding pointer logic in event_loop.rs and removing touch support in the seat...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Woops I think I grabbed the wrong pieces while resolving this, thanks and good catch. Let me try again.

@Xaeroxe
Copy link
Copy Markdown
Contributor Author

Xaeroxe commented Nov 12, 2017

@vberger Ok I think I got it right this time. git has a really weird idea of how changes impact sections of code sometimes and it confused me because I was expecting git to be smarter than it was.

@elinorbgr
Copy link
Copy Markdown
Contributor

Looks like that's not yet it, the struct PointerIData and fn pointer_implementation() should not end up in event_loop.rs.

I think git is getting confused because you modified some part of this code (while changing the variant names), but #342 has moved this code to an other file (pointer.rs)

@Xaeroxe
Copy link
Copy Markdown
Contributor Author

Xaeroxe commented Nov 12, 2017

@vberger Thanks for describing the changes to me, sorry I should have reviewed the PR. I think this is ready now.

Copy link
Copy Markdown
Contributor

@elinorbgr elinorbgr left a comment

Choose a reason for hiding this comment

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

Ok, this looks good. I'll merge this once the CI is finished if all is green.

@elinorbgr
Copy link
Copy Markdown
Contributor

Oh, actually one last thing is missing: could you add a line in the changelog describing the breaking changes which were made?

@Xaeroxe
Copy link
Copy Markdown
Contributor Author

Xaeroxe commented Nov 12, 2017

@vberger done.

@elinorbgr
Copy link
Copy Markdown
Contributor

Alright, perfect! 👍

@elinorbgr elinorbgr merged commit cfd087d into rust-windowing:master Nov 12, 2017
@Xaeroxe Xaeroxe deleted the mouse-events branch November 12, 2017 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants