wayland/pointer_constraints: call remove_constraint when pointer leave surface - #2107
wayland/pointer_constraints: call remove_constraint when pointer leave surface#2107skygrango wants to merge 2 commits into
Conversation
|
@YaLTeR Does this meet your needs ? |
7ea2362 to
b665e57
Compare
|
Introducing the |
| if deactivated { | ||
| data.remove_constraint(self, &pointer); | ||
| } |
There was a problem hiding this comment.
I would imagine that this code should go inside deactivate() itself to avoid putting it into every caller?
Or I guess data is inaccessible from there? Hmm, not sure how to structure this
There was a problem hiding this comment.
I've updated the signature of deactivate(), which I believe addresses your suggestion.
However, the downside is that PointerConstraintsHandler has now become a trait dependency of PointerTarget.
There was a problem hiding this comment.
That looks like the change that I had in mind, yeah.
It also doesn't seem like the repeated remove_constraint() call from destroyed() is a problem, because the constraint is required to be unique per surface, so the surface must destroy the previous constraint before making a new one, so it shouldn't be possible for a repeated remove_constraint() call to operate on a cursor position hint from a different constraint. Is my reasoning correct here?
There was a problem hiding this comment.
For Lifetime::Oneshot, explicitly calling deactivate() does result in one extra invocation of remove_constraint(). However, I don't think this has any practical impact. The compositor should ensure that only a single surface's cursor position hint is stored at any given time(per seat), and that the hint is consumed after it has been been applied. Consequently, the second invocation becomes a no-op because there is no cursor position hint remaining to apply.
There was a problem hiding this comment.
Yes, and I am thinking through whether it's possible to end up with the incorrect stored hint through overlapping pointer constraint objects, and so far I don't see any way.
c731f38 to
d551a7f
Compare
|
I moved Since |
| self.backend_data.update_led_state(led_state) | ||
| } | ||
|
|
||
| fn remove_constraint( |
There was a problem hiding this comment.
Urgh, I am not sure I like the move here. So if you don't expose the constrains-protocol, you still have to implement this function? That makes no sense.
| with_pointer_constraint(self, &pointer, |constraint| { | ||
| if let Some(constraint) = constraint { | ||
| constraint.deactivate(); | ||
| constraint.deactivate(data, &self, &pointer); |
There was a problem hiding this comment.
So the issue is this call, right? (This would be so easy, if we had specialization.)
I would honestly rather have the PointerTarget impl for WlSurface require the PointerContraintsHandler, than remove_constraint to be part of the SeatHandler, if nobody has a better idea.
There was a problem hiding this comment.
how do you think about
/// Callback that returns a reference to the pointer constraints handler, if implemented.
fn pointer_constraints_handler(&mut self) -> Option<&mut dyn PointerConstraintsHandler<Self>> {
None
}for SeatHandler
There was a problem hiding this comment.
No please. The SeatHandler should not expose anything related to pointer constraints. If our WlSurface implementation of PointerTarget needs it, just add a requirement for the PointerConstraintsHandler.
4b0ab03 to
9698623
Compare
29c3be2 to
43ee475
Compare
|
@Drakulix Following your suggestion, I added |
Drakulix
left a comment
There was a problem hiding this comment.
LGTM
I'll clean up the Git history later.
I can simply squash the commits on merge, if you want.
Description
related: #2027 (comment)
The implementation ensures that remove_constraint() is invoked when the pointer leaves the surface, allowing the last saved cursor position hint to be applied.
This both improves the expected behavior of
Lifetime::Persistentand ensures that pointer focus changes are handled immediately.Checklist