| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/exo/pointer.h" | 5 #include "components/exo/pointer.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
| 10 #include "components/exo/pointer_delegate.h" | 10 #include "components/exo/pointer_delegate.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
| 50 // Pointer, public: | 50 // Pointer, public: |
| 51 | 51 |
| 52 Pointer::Pointer(PointerDelegate* delegate) | 52 Pointer::Pointer(PointerDelegate* delegate) |
| 53 : delegate_(delegate), | 53 : delegate_(delegate), |
| 54 cursor_(ui::kCursorNull), | 54 cursor_(ui::kCursorNull), |
| 55 cursor_capture_source_id_(base::UnguessableToken::Create()), |
| 55 cursor_capture_weak_ptr_factory_(this) { | 56 cursor_capture_weak_ptr_factory_(this) { |
| 56 auto* helper = WMHelper::GetInstance(); | 57 auto* helper = WMHelper::GetInstance(); |
| 57 helper->AddPreTargetHandler(this); | 58 helper->AddPreTargetHandler(this); |
| 58 helper->AddCursorObserver(this); | 59 helper->AddCursorObserver(this); |
| 59 } | 60 } |
| 60 | 61 |
| 61 Pointer::~Pointer() { | 62 Pointer::~Pointer() { |
| 62 delegate_->OnPointerDestroying(this); | 63 delegate_->OnPointerDestroying(this); |
| 63 if (surface_) | 64 if (surface_) |
| 64 surface_->RemoveSurfaceObserver(this); | 65 surface_->RemoveSurfaceObserver(this); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 334 |
| 334 std::unique_ptr<cc::CopyOutputRequest> request = | 335 std::unique_ptr<cc::CopyOutputRequest> request = |
| 335 cc::CopyOutputRequest::CreateBitmapRequest( | 336 cc::CopyOutputRequest::CreateBitmapRequest( |
| 336 base::Bind(&Pointer::OnCursorCaptured, | 337 base::Bind(&Pointer::OnCursorCaptured, |
| 337 cursor_capture_weak_ptr_factory_.GetWeakPtr(), | 338 cursor_capture_weak_ptr_factory_.GetWeakPtr(), |
| 338 gfx::ScaleToFlooredPoint( | 339 gfx::ScaleToFlooredPoint( |
| 339 hotspot_, | 340 hotspot_, |
| 340 // |hotspot_| is in surface coordinate space so apply | 341 // |hotspot_| is in surface coordinate space so apply |
| 341 // both device scale and UI scale. | 342 // both device scale and UI scale. |
| 342 cursor_scale_ * primary_device_scale_factor))); | 343 cursor_scale_ * primary_device_scale_factor))); |
| 344 request->set_source(cursor_capture_source_id_); |
| 343 surface_->window()->layer()->RequestCopyOfOutput(std::move(request)); | 345 surface_->window()->layer()->RequestCopyOfOutput(std::move(request)); |
| 344 } | 346 } |
| 345 | 347 |
| 346 void Pointer::OnCursorCaptured(const gfx::Point& hotspot, | 348 void Pointer::OnCursorCaptured(const gfx::Point& hotspot, |
| 347 std::unique_ptr<cc::CopyOutputResult> result) { | 349 std::unique_ptr<cc::CopyOutputResult> result) { |
| 348 if (!focus_) | 350 if (!focus_) |
| 349 return; | 351 return; |
| 350 | 352 |
| 351 cursor_ = ui::kCursorNone; | 353 cursor_ = ui::kCursorNone; |
| 352 if (!result->IsEmpty()) { | 354 if (!result->IsEmpty()) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 378 void Pointer::UpdateCursor() { | 380 void Pointer::UpdateCursor() { |
| 379 DCHECK(focus_); | 381 DCHECK(focus_); |
| 380 | 382 |
| 381 aura::client::CursorClient* cursor_client = | 383 aura::client::CursorClient* cursor_client = |
| 382 aura::client::GetCursorClient(focus_->window()->GetRootWindow()); | 384 aura::client::GetCursorClient(focus_->window()->GetRootWindow()); |
| 383 if (cursor_client) | 385 if (cursor_client) |
| 384 cursor_client->SetCursor(cursor_); | 386 cursor_client->SetCursor(cursor_); |
| 385 } | 387 } |
| 386 | 388 |
| 387 } // namespace exo | 389 } // namespace exo |
| OLD | NEW |