Commit 46d3870f authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Use the cursor stored in Widget for regular surface as well.

The original CL crrev.com/c/903223 changed the GetCurosr logic
only for notification surface. Regular exo surface should do the same.

This also removes obsolete path.

Bug: 814600
Test: manual. See bug for repro step.
Change-Id: Icbdf000db30efa96aa056c1b7fe15d38822b7610
Reviewed-on: https://chromium-review.googlesource.com/956103Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542347}
parent 779ed842
......@@ -95,7 +95,6 @@ Pointer::~Pointer() {
delegate_->OnPointerDestroying(this);
if (focus_surface_) {
focus_surface_->RemoveSurfaceObserver(this);
focus_surface_->UnregisterCursorProvider(this);
}
if (pinch_delegate_)
pinch_delegate_->OnPointerDestroying(this);
......@@ -151,10 +150,6 @@ void Pointer::SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate) {
pinch_delegate_ = delegate;
}
gfx::NativeCursor Pointer::GetCursor() {
return cursor_;
}
////////////////////////////////////////////////////////////////////////////////
// SurfaceDelegate overrides:
......@@ -358,7 +353,6 @@ void Pointer::SetFocus(Surface* 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_capture_weak_ptr_factory_.InvalidateWeakPtrs();
}
......@@ -368,7 +362,6 @@ void Pointer::SetFocus(Surface* surface,
location_ = location;
focus_surface_ = surface;
focus_surface_->AddSurfaceObserver(this);
focus_surface_->RegisterCursorProvider(this);
}
delegate_->OnPointerFrame();
}
......
......@@ -60,9 +60,6 @@ class Pointer : public SurfaceTreeHost,
// Set delegate for pinch events.
void SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate);
// Returns the current cursor for the pointer.
gfx::NativeCursor GetCursor();
// Overridden from SurfaceDelegate:
void OnSurfaceCommit() override;
......
......@@ -115,7 +115,11 @@ class CustomWindowDelegate : public aura::WindowDelegate {
void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {}
gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return surface_->GetCursor();
views::Widget* widget =
views::Widget::GetTopLevelWidgetForNativeView(surface_->window());
if (widget)
return widget->GetNativeWindow()->GetCursor(point /* not used */);
return ui::CursorType::kNull;
}
int GetNonClientComponent(const gfx::Point& point) const override {
return HTNOWHERE;
......@@ -652,25 +656,6 @@ Surface::GetHitTestShapeRects() const {
return rects;
}
void Surface::RegisterCursorProvider(Pointer* provider) {
cursor_providers_.insert(provider);
}
void Surface::UnregisterCursorProvider(Pointer* provider) {
cursor_providers_.erase(provider);
}
gfx::NativeCursor Surface::GetCursor() {
// What cursor we display when we have multiple cursor providers is not
// important. Return the first non-null cursor.
for (auto* cursor_provider : cursor_providers_) {
gfx::NativeCursor cursor = cursor_provider->GetCursor();
if (cursor != ui::CursorType::kNull)
return cursor;
}
return ui::CursorType::kNull;
}
void Surface::SetSurfaceDelegate(SurfaceDelegate* delegate) {
DCHECK(!delegate_ || !delegate);
delegate_ = delegate;
......
......@@ -43,7 +43,6 @@ class CompositorFrame;
namespace exo {
class Buffer;
class LayerTreeFrameSinkHolder;
class Pointer;
class SurfaceObserver;
class Surface;
......@@ -54,10 +53,6 @@ class PropertyHelper;
// Counter-clockwise rotations.
enum class Transform { NORMAL, ROTATE_90, ROTATE_180, ROTATE_270 };
// The pointer class is currently the only cursor provider class but this can
// change in the future when better hardware cursor support is added.
using CursorProvider = Pointer;
// This class represents a rectangular area that is displayed on the screen.
// It has a location, size and pixel contents.
class Surface final : public ui::PropertyHandler {
......@@ -198,15 +193,6 @@ class Surface final : public ui::PropertyHandler {
std::unique_ptr<aura::WindowTargeter::HitTestRects> GetHitTestShapeRects()
const;
// Surface does not own cursor providers. It is the responsibility of the
// caller to remove the cursor provider before it is destroyed.
void RegisterCursorProvider(CursorProvider* provider);
void UnregisterCursorProvider(CursorProvider* provider);
// Returns the cursor for the surface. If no cursor provider is registered
// then CursorType::kNull is returned.
gfx::NativeCursor GetCursor();
// Set the surface delegate.
void SetSurfaceDelegate(SurfaceDelegate* delegate);
......@@ -397,9 +383,6 @@ class Surface final : public ui::PropertyHandler {
// callbacks when compositing successfully ends.
base::TimeTicks last_compositing_start_time_;
// Cursor providers. Surface does not own the cursor providers.
std::set<CursorProvider*> cursor_providers_;
// This can be set to have some functions delegated. E.g. ShellSurface class
// can set this to handle Commit() and apply any double buffered state it
// maintains.
......
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