summaryrefslogtreecommitdiff
path: root/chromium/components/exo/pointer.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-29 16:35:13 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-02-01 15:33:35 +0000
commitc8c2d1901aec01e934adf561a9fdf0cc776cdef8 (patch)
tree9157c3d9815e5870799e070b113813bec53e0535 /chromium/components/exo/pointer.cc
parentabefd5095b41dac94ca451d784ab6e27372e981a (diff)
downloadqtwebengine-chromium-c8c2d1901aec01e934adf561a9fdf0cc776cdef8.tar.gz
BASELINE: Update Chromium to 64.0.3282.139
Change-Id: I1cae68fe9c94ff7608b26b8382fc19862cdb293a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/exo/pointer.cc')
-rw-r--r--chromium/components/exo/pointer.cc109
1 files changed, 58 insertions, 51 deletions
diff --git a/chromium/components/exo/pointer.cc b/chromium/components/exo/pointer.cc
index da955ddf1e8..f395a767ec1 100644
--- a/chromium/components/exo/pointer.cc
+++ b/chromium/components/exo/pointer.cc
@@ -77,7 +77,7 @@ display::ManagedDisplayInfo GetCaptureDisplayInfo() {
// Pointer, public:
Pointer::Pointer(PointerDelegate* delegate)
- : SurfaceTreeHost("ExoPointer", nullptr),
+ : SurfaceTreeHost("ExoPointer"),
delegate_(delegate),
cursor_(ui::CursorType::kNull),
capture_scale_(GetCaptureDisplayInfo().device_scale_factor()),
@@ -131,11 +131,8 @@ void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) {
}
// Early out if cursor did not change.
- if (!cursor_changed) {
- // Cursor scale or rotation may have changed.
- UpdateCursor();
+ if (!cursor_changed)
return;
- }
// If |SurfaceTreeHost::root_surface_| is set then asynchronously capture a
// snapshot of cursor, otherwise cancel pending capture and immediately set
@@ -149,14 +146,14 @@ void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) {
}
}
-gfx::NativeCursor Pointer::GetCursor() {
- return cursor_;
-}
-
void Pointer::SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate) {
pinch_delegate_ = delegate;
}
+gfx::NativeCursor Pointer::GetCursor() {
+ return cursor_;
+}
+
////////////////////////////////////////////////////////////////////////////////
// SurfaceDelegate overrides:
@@ -164,10 +161,8 @@ void Pointer::OnSurfaceCommit() {
SurfaceTreeHost::OnSurfaceCommit();
// Capture new cursor to reflect result of commit.
- if (focus_surface_ && !host_window()->bounds().IsEmpty())
+ if (focus_surface_)
CaptureCursor(hotspot_);
-
- SubmitCompositorFrame();
}
////////////////////////////////////////////////////////////////////////////////
@@ -175,8 +170,7 @@ void Pointer::OnSurfaceCommit() {
void Pointer::OnSurfaceDestroying(Surface* surface) {
if (surface == focus_surface_) {
- focus_surface_ = nullptr;
- surface->RemoveSurfaceObserver(this);
+ SetFocus(nullptr, gfx::PointF(), 0);
return;
}
if (surface == root_surface()) {
@@ -192,36 +186,16 @@ void Pointer::OnSurfaceDestroying(Surface* surface) {
void Pointer::OnMouseEvent(ui::MouseEvent* event) {
Surface* target = GetEffectiveTargetForEvent(event);
- // If target is different than the current pointer focus then we need to
- // generate enter and leave events.
- if (target != focus_surface_) {
- // First generate a leave event if we currently have a target in focus.
- if (focus_surface_) {
- delegate_->OnPointerLeave(focus_surface_);
- focus_surface_->RemoveSurfaceObserver(this);
- // Require SetCursor() to be called and cursor to be re-defined in
- // response to each OnPointerEnter() call.
- focus_surface_->UnregisterCursorProvider(this);
- focus_surface_ = nullptr;
- cursor_ = ui::CursorType::kNull;
- cursor_capture_weak_ptr_factory_.InvalidateWeakPtrs();
- }
- // Second generate an enter event if focus moved to a new target.
- if (target) {
- delegate_->OnPointerEnter(target, event->location_f(),
- event->button_flags());
- location_ = event->location_f();
- focus_surface_ = target;
- focus_surface_->AddSurfaceObserver(this);
- focus_surface_->RegisterCursorProvider(this);
- }
- delegate_->OnPointerFrame();
- }
+ // Update focus if target is different than the current pointer focus.
+ if (target != focus_surface_)
+ SetFocus(target, event->location_f(), event->button_flags());
if (!focus_surface_)
return;
- if (event->IsMouseEvent() && event->type() != ui::ET_MOUSE_EXITED) {
+ if (event->IsMouseEvent() &&
+ event->type() != ui::ET_MOUSE_EXITED &&
+ event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) {
// 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
@@ -330,20 +304,26 @@ void Pointer::OnGestureEvent(ui::GestureEvent* event) {
}
////////////////////////////////////////////////////////////////////////////////
-// WMHelper::CursorObserver overrides:
+// ui::client::CursorClientObserver overrides:
void Pointer::OnCursorSizeChanged(ui::CursorSize cursor_size) {
- if (focus_surface_)
+ if (!focus_surface_)
+ return;
+
+ if (cursor_ != ui::CursorType::kNull)
UpdateCursor();
}
void Pointer::OnCursorDisplayChanged(const display::Display& display) {
- if (focus_surface_)
+ if (!focus_surface_)
+ return;
+
+ if (cursor_ != ui::CursorType::kNull)
UpdateCursor();
}
////////////////////////////////////////////////////////////////////////////////
-// WMHelper::DisplayConfigurationObserver overrides:
+// ash::WindowTreeHostManager::Observer overrides:
void Pointer::OnDisplayConfigurationChanged() {
UpdatePointerSurface(root_surface());
@@ -364,6 +344,31 @@ Surface* Pointer::GetEffectiveTargetForEvent(ui::Event* event) const {
return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr;
}
+void Pointer::SetFocus(Surface* surface,
+ const gfx::PointF& location,
+ int button_flags) {
+ // First generate a leave event if we currently have a target in focus.
+ if (focus_surface_) {
+ delegate_->OnPointerLeave(focus_surface_);
+ focus_surface_->RemoveSurfaceObserver(this);
+ // Require SetCursor() to be called and cursor to be re-defined in
+ // response to each OnPointerEnter() call.
+ focus_surface_->UnregisterCursorProvider(this);
+ focus_surface_ = nullptr;
+ cursor_ = ui::CursorType::kNull;
+ cursor_capture_weak_ptr_factory_.InvalidateWeakPtrs();
+ }
+ // Second generate an enter event if focus moved to a new surface.
+ if (surface) {
+ delegate_->OnPointerEnter(surface, location, button_flags);
+ location_ = location;
+ focus_surface_ = surface;
+ focus_surface_->AddSurfaceObserver(this);
+ focus_surface_->RegisterCursorProvider(this);
+ }
+ delegate_->OnPointerFrame();
+}
+
void Pointer::UpdatePointerSurface(Surface* surface) {
if (root_surface()) {
host_window()->SetTransform(gfx::Transform());
@@ -389,6 +394,9 @@ void Pointer::CaptureCursor(const gfx::Point& hotspot) {
DCHECK(root_surface());
DCHECK(focus_surface_);
+ // Submit compositor frame to be captured.
+ SubmitCompositorFrame();
+
// Surface size is in DIPs, while layer size is in pseudo-DIP units that
// depend on the DSF of the display mode. Scale the layer to capture the
// surface at a constant pixel size, regardless of the primary display's
@@ -415,14 +423,13 @@ void Pointer::OnCursorCaptured(const gfx::Point& hotspot,
if (!focus_surface_)
return;
- if (result->IsEmpty()) {
- cursor_bitmap_.reset();
- } else {
- cursor_bitmap_ = result->AsSkBitmap();
- DCHECK(cursor_bitmap_.readyToDraw());
- cursor_hotspot_ = hotspot;
- }
+ // Only successful captures should update the cursor.
+ if (result->IsEmpty())
+ return;
+ cursor_bitmap_ = result->AsSkBitmap();
+ DCHECK(cursor_bitmap_.readyToDraw());
+ cursor_hotspot_ = hotspot;
UpdateCursor();
}