Commit 51ff3afa authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Commit Bot

Unconstrain pointer when surface is destroyed

As per the wayland-protocol spec for locked pointer, the locked pointer
object is no longer valid if the surface to which it is constrained is
destroyed.

This CL makes sure to break the constraint and send an unlock event when
the surface associated with a locked pointer is destroyed.

Bug: None
Change-Id: I368af9a725da3c3b871c7574b2c76fe5fc113fec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1854879Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Prabir Pradhan <prabirmsp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705358}
parent 0b54d114
......@@ -125,8 +125,11 @@ Pointer::~Pointer() {
pinch_delegate_->OnPointerDestroying(this);
if (relative_pointer_delegate_)
relative_pointer_delegate_->OnPointerDestroying(this);
if (pointer_constraint_delegate_)
if (pointer_constraint_delegate_) {
pointer_constraint_delegate_->GetConstrainedSurface()
->RemoveSurfaceObserver(this);
pointer_constraint_delegate_->OnConstraintBroken();
}
WMHelper* helper = WMHelper::GetInstance();
helper->RemovePreTargetHandler(this);
// TODO(sky): CursorClient does not exist in mash
......@@ -309,6 +312,9 @@ bool Pointer::EnablePointerCapture(Surface* capture_surface) {
if (!base::FeatureList::IsEnabled(kPointerCapture))
return false;
if (!capture_surface->HasSurfaceObserver(this))
capture_surface->AddSurfaceObserver(this);
capture_window_ = capture_surface->window();
auto* capture_client = WMHelper::GetInstance()->GetCaptureClient();
......@@ -342,6 +348,12 @@ void Pointer::OnSurfaceCommit() {
// SurfaceObserver overrides:
void Pointer::OnSurfaceDestroying(Surface* surface) {
if (surface && pointer_constraint_delegate_ &&
surface == pointer_constraint_delegate_->GetConstrainedSurface()) {
surface->RemoveSurfaceObserver(this);
pointer_constraint_delegate_->OnConstraintBroken();
UnconstrainPointer();
}
if (surface == focus_surface_) {
SetFocus(nullptr, gfx::PointF(), 0);
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment