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() { ...@@ -95,7 +95,6 @@ Pointer::~Pointer() {
delegate_->OnPointerDestroying(this); delegate_->OnPointerDestroying(this);
if (focus_surface_) { if (focus_surface_) {
focus_surface_->RemoveSurfaceObserver(this); focus_surface_->RemoveSurfaceObserver(this);
focus_surface_->UnregisterCursorProvider(this);
} }
if (pinch_delegate_) if (pinch_delegate_)
pinch_delegate_->OnPointerDestroying(this); pinch_delegate_->OnPointerDestroying(this);
...@@ -151,10 +150,6 @@ void Pointer::SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate) { ...@@ -151,10 +150,6 @@ void Pointer::SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate) {
pinch_delegate_ = delegate; pinch_delegate_ = delegate;
} }
gfx::NativeCursor Pointer::GetCursor() {
return cursor_;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SurfaceDelegate overrides: // SurfaceDelegate overrides:
...@@ -358,7 +353,6 @@ void Pointer::SetFocus(Surface* surface, ...@@ -358,7 +353,6 @@ void Pointer::SetFocus(Surface* surface,
focus_surface_->RemoveSurfaceObserver(this); focus_surface_->RemoveSurfaceObserver(this);
// Require SetCursor() to be called and cursor to be re-defined in // Require SetCursor() to be called and cursor to be re-defined in
// response to each OnPointerEnter() call. // response to each OnPointerEnter() call.
focus_surface_->UnregisterCursorProvider(this);
focus_surface_ = nullptr; focus_surface_ = nullptr;
cursor_capture_weak_ptr_factory_.InvalidateWeakPtrs(); cursor_capture_weak_ptr_factory_.InvalidateWeakPtrs();
} }
...@@ -368,7 +362,6 @@ void Pointer::SetFocus(Surface* surface, ...@@ -368,7 +362,6 @@ void Pointer::SetFocus(Surface* surface,
location_ = location; location_ = location;
focus_surface_ = surface; focus_surface_ = surface;
focus_surface_->AddSurfaceObserver(this); focus_surface_->AddSurfaceObserver(this);
focus_surface_->RegisterCursorProvider(this);
} }
delegate_->OnPointerFrame(); delegate_->OnPointerFrame();
} }
......
...@@ -60,9 +60,6 @@ class Pointer : public SurfaceTreeHost, ...@@ -60,9 +60,6 @@ class Pointer : public SurfaceTreeHost,
// Set delegate for pinch events. // Set delegate for pinch events.
void SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate); void SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate);
// Returns the current cursor for the pointer.
gfx::NativeCursor GetCursor();
// Overridden from SurfaceDelegate: // Overridden from SurfaceDelegate:
void OnSurfaceCommit() override; void OnSurfaceCommit() override;
......
...@@ -115,7 +115,11 @@ class CustomWindowDelegate : public aura::WindowDelegate { ...@@ -115,7 +115,11 @@ class CustomWindowDelegate : public aura::WindowDelegate {
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {} const gfx::Rect& new_bounds) override {}
gfx::NativeCursor GetCursor(const gfx::Point& point) 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 { int GetNonClientComponent(const gfx::Point& point) const override {
return HTNOWHERE; return HTNOWHERE;
...@@ -652,25 +656,6 @@ Surface::GetHitTestShapeRects() const { ...@@ -652,25 +656,6 @@ Surface::GetHitTestShapeRects() const {
return rects; 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) { void Surface::SetSurfaceDelegate(SurfaceDelegate* delegate) {
DCHECK(!delegate_ || !delegate); DCHECK(!delegate_ || !delegate);
delegate_ = delegate; delegate_ = delegate;
......
...@@ -43,7 +43,6 @@ class CompositorFrame; ...@@ -43,7 +43,6 @@ class CompositorFrame;
namespace exo { namespace exo {
class Buffer; class Buffer;
class LayerTreeFrameSinkHolder; class LayerTreeFrameSinkHolder;
class Pointer;
class SurfaceObserver; class SurfaceObserver;
class Surface; class Surface;
...@@ -54,10 +53,6 @@ class PropertyHelper; ...@@ -54,10 +53,6 @@ class PropertyHelper;
// Counter-clockwise rotations. // Counter-clockwise rotations.
enum class Transform { NORMAL, ROTATE_90, ROTATE_180, ROTATE_270 }; 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. // This class represents a rectangular area that is displayed on the screen.
// It has a location, size and pixel contents. // It has a location, size and pixel contents.
class Surface final : public ui::PropertyHandler { class Surface final : public ui::PropertyHandler {
...@@ -198,15 +193,6 @@ class Surface final : public ui::PropertyHandler { ...@@ -198,15 +193,6 @@ class Surface final : public ui::PropertyHandler {
std::unique_ptr<aura::WindowTargeter::HitTestRects> GetHitTestShapeRects() std::unique_ptr<aura::WindowTargeter::HitTestRects> GetHitTestShapeRects()
const; 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. // Set the surface delegate.
void SetSurfaceDelegate(SurfaceDelegate* delegate); void SetSurfaceDelegate(SurfaceDelegate* delegate);
...@@ -397,9 +383,6 @@ class Surface final : public ui::PropertyHandler { ...@@ -397,9 +383,6 @@ class Surface final : public ui::PropertyHandler {
// callbacks when compositing successfully ends. // callbacks when compositing successfully ends.
base::TimeTicks last_compositing_start_time_; 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 // 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 // can set this to handle Commit() and apply any double buffered state it
// maintains. // 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