Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1430)

Unified Diff: ash/autoclick/common/autoclick_controller_common.cc

Issue 2316553003: mash: Add autoclick app. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/autoclick/common/autoclick_controller_common.cc
diff --git a/ash/autoclick/common/autoclick_controller_common.cc b/ash/autoclick/common/autoclick_controller_common.cc
index d622814b3b647e19ce6a238e1567129d7388097a..32a28024c686c29fa1b6447ce4e3a04070a68da0 100644
--- a/ash/autoclick/common/autoclick_controller_common.cc
+++ b/ash/autoclick/common/autoclick_controller_common.cc
@@ -43,16 +43,20 @@ AutoclickControllerCommon::AutoclickControllerCommon(
AutoclickControllerCommon::~AutoclickControllerCommon() {}
-void AutoclickControllerCommon::HandleMouseEvent(const ui::MouseEvent& event) {
+void AutoclickControllerCommon::HandleMouseEvent(
+ const ui::PointerEvent& event) {
+ DCHECK(event.IsMousePointerEvent());
gfx::Point mouse_location = event.location();
- if (event.type() == ui::ET_MOUSE_MOVED &&
+ if (event.type() == ui::ET_POINTER_MOVED &&
!(event.flags() & ui::EF_IS_SYNTHESIZED)) {
mouse_event_flags_ = event.flags();
// TODO(riajiang): Make getting screen location work for mus as well.
// (crbug.com/608547)
- ::wm::ConvertPointToScreen(static_cast<aura::Window*>(event.target()),
- &mouse_location);
+ if (event.target() != nullptr) {
+ ::wm::ConvertPointToScreen(static_cast<aura::Window*>(event.target()),
+ &mouse_location);
+ }
UpdateRingWidget(mouse_location);
// The distance between the mouse location and the anchor location
@@ -65,19 +69,17 @@ void AutoclickControllerCommon::HandleMouseEvent(const ui::MouseEvent& event) {
if (delta.LengthSquared() >= kMovementThreshold * kMovementThreshold) {
anchor_location_ = mouse_location;
autoclick_timer_->Reset();
- autoclick_ring_handler_->StartGesture(delay_, anchor_location_,
- widget_.get());
+ autoclick_ring_handler_->StartGesture(delay_, anchor_location_, widget_);
} else if (autoclick_timer_->IsRunning()) {
- autoclick_ring_handler_->SetGestureCenter(mouse_location, widget_.get());
+ autoclick_ring_handler_->SetGestureCenter(mouse_location, widget_);
}
- } else if (event.type() == ui::ET_MOUSE_PRESSED) {
+ } else if (event.type() == ui::ET_POINTER_DOWN) {
CancelAutoclick();
- } else if (event.type() == ui::ET_MOUSEWHEEL &&
+ } else if (event.type() == ui::ET_POINTER_WHEEL_CHANGED &&
autoclick_timer_->IsRunning()) {
autoclick_timer_->Reset();
UpdateRingWidget(mouse_location);
- autoclick_ring_handler_->StartGesture(delay_, anchor_location_,
- widget_.get());
+ autoclick_ring_handler_->StartGesture(delay_, anchor_location_, widget_);
}
}
@@ -120,10 +122,9 @@ void AutoclickControllerCommon::DoAutoclick() {
void AutoclickControllerCommon::UpdateRingWidget(
const gfx::Point& mouse_location) {
if (!widget_) {
- widget_.reset(
- (delegate_->CreateAutoclickRingWidget(mouse_location)).release());
+ widget_ = delegate_->CreateAutoclickRingWidget(mouse_location);
} else {
- delegate_->UpdateAutoclickRingWidget(widget_.get(), mouse_location);
+ delegate_->UpdateAutoclickRingWidget(widget_, mouse_location);
}
}

Powered by Google App Engine
This is Rietveld 408576698