diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-12 14:07:37 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-17 10:29:26 +0000 |
commit | ec02ee4181c49b61fce1c8fb99292dbb8139cc90 (patch) | |
tree | 25cde714b2b71eb639d1cd53f5a22e9ba76e14ef /chromium/components/exo/pointer.cc | |
parent | bb09965444b5bb20b096a291445170876225268d (diff) | |
download | qtwebengine-chromium-ec02ee4181c49b61fce1c8fb99292dbb8139cc90.tar.gz |
BASELINE: Update Chromium to 59.0.3071.134
Change-Id: Id02ef6fb2204c5fd21668a1c3e6911c83b17585a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/exo/pointer.cc')
-rw-r--r-- | chromium/components/exo/pointer.cc | 93 |
1 files changed, 52 insertions, 41 deletions
diff --git a/chromium/components/exo/pointer.cc b/chromium/components/exo/pointer.cc index 1697f5c34dc..1cc32a42637 100644 --- a/chromium/components/exo/pointer.cc +++ b/chromium/components/exo/pointer.cc @@ -89,9 +89,8 @@ void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) { } if (surface_) { surface_->window()->SetTransform(gfx::Transform()); - WMHelper::GetInstance() - ->GetContainer(ash::kShellWindowId_MouseCursorContainer) - ->RemoveChild(surface_->window()); + if (surface_->window()->parent()) + surface_->window()->parent()->RemoveChild(surface_->window()); surface_->SetSurfaceDelegate(nullptr); surface_->RemoveSurfaceObserver(this); } @@ -119,7 +118,7 @@ void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) { if (!cursor_changed) return; - // If |surface_| is set then ascynchrounsly capture a snapshot of cursor, + // If |surface_| is set then asynchronously capture a snapshot of cursor, // otherwise cancel pending capture and immediately set the cursor to "none". if (surface_) { CaptureCursor(); @@ -140,9 +139,6 @@ gfx::NativeCursor Pointer::GetCursor() { void Pointer::OnMouseEvent(ui::MouseEvent* event) { Surface* target = GetEffectiveTargetForEvent(event); - if (event->flags() & ui::EF_TOUCH_ACCESSIBILITY) - return; - // If target is different than the current pointer focus then we need to // generate enter and leave events. if (target != focus_) { @@ -169,7 +165,10 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) { delegate_->OnPointerFrame(); } - if (focus_ && event->IsMouseEvent() && event->type() != ui::ET_MOUSE_EXITED) { + if (!focus_) + return; + + if (event->IsMouseEvent() && event->type() != ui::ET_MOUSE_EXITED) { // Generate motion event if location changed. We need to check location // here as mouse movement can generate both "moved" and "entered" events // but OnPointerMotion should only be called if location changed since @@ -183,44 +182,52 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) { switch (event->type()) { case ui::ET_MOUSE_PRESSED: - case ui::ET_MOUSE_RELEASED: - if (focus_) { - delegate_->OnPointerButton(event->time_stamp(), - event->changed_button_flags(), - event->type() == ui::ET_MOUSE_PRESSED); - delegate_->OnPointerFrame(); - } + case ui::ET_MOUSE_RELEASED: { + delegate_->OnPointerButton(event->time_stamp(), + event->changed_button_flags(), + event->type() == ui::ET_MOUSE_PRESSED); + delegate_->OnPointerFrame(); break; - case ui::ET_SCROLL: - if (focus_) { - ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event); - delegate_->OnPointerScroll( - event->time_stamp(), - gfx::Vector2dF(scroll_event->x_offset(), scroll_event->y_offset()), - false); - delegate_->OnPointerFrame(); - } + } + case ui::ET_SCROLL: { + ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event); + delegate_->OnPointerScroll( + event->time_stamp(), + gfx::Vector2dF(scroll_event->x_offset(), scroll_event->y_offset()), + false); + delegate_->OnPointerFrame(); break; - case ui::ET_MOUSEWHEEL: - if (focus_) { - delegate_->OnPointerScroll( - event->time_stamp(), - static_cast<ui::MouseWheelEvent*>(event)->offset(), true); - delegate_->OnPointerFrame(); - } + } + case ui::ET_MOUSEWHEEL: { + delegate_->OnPointerScroll( + event->time_stamp(), + static_cast<ui::MouseWheelEvent*>(event)->offset(), true); + delegate_->OnPointerFrame(); break; - case ui::ET_SCROLL_FLING_START: - if (focus_) { - delegate_->OnPointerScrollStop(event->time_stamp()); - delegate_->OnPointerFrame(); - } + } + case ui::ET_SCROLL_FLING_START: { + // Fling start in chrome signals the lifting of fingers after scrolling. + // In wayland terms this signals the end of a scroll sequence. + delegate_->OnPointerScrollStop(event->time_stamp()); + delegate_->OnPointerFrame(); break; - case ui::ET_SCROLL_FLING_CANCEL: - if (focus_) { - delegate_->OnPointerScrollCancel(event->time_stamp()); + } + case ui::ET_SCROLL_FLING_CANCEL: { + // Fling cancel is generated very generously at every touch of the + // touchpad. Since it's not directly supported by the delegate, we do not + // want limit this event to only right after a fling start has been + // generated to prevent erronous behavior. + if (last_event_type_ == ui::ET_SCROLL_FLING_START) { + // We emulate fling cancel by starting a new scroll sequence that + // scrolls by 0 pixels, effectively stopping any kinetic scroll motion. + delegate_->OnPointerScroll(event->time_stamp(), gfx::Vector2dF(), + false); + delegate_->OnPointerFrame(); + delegate_->OnPointerScrollStop(event->time_stamp()); delegate_->OnPointerFrame(); } break; + } case ui::ET_MOUSE_MOVED: case ui::ET_MOUSE_DRAGGED: case ui::ET_MOUSE_ENTERED: @@ -232,14 +239,17 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) { break; } - if (focus_) - UpdateCursorScale(); + last_event_type_ = event->type(); + UpdateCursorScale(); } void Pointer::OnScrollEvent(ui::ScrollEvent* event) { OnMouseEvent(event); } +//////////////////////////////////////////////////////////////////////////////// +// WMHelper::CursorObserver overrides: + void Pointer::OnCursorSetChanged(ui::CursorSetType cursor_set) { if (focus_) UpdateCursorScale(); @@ -324,6 +334,7 @@ void Pointer::UpdateCursorScale() { void Pointer::CaptureCursor() { DCHECK(surface_); + DCHECK(focus_); // Set UI scale before submitting capture request. surface_->window()->layer()->SetTransform( |