Commit bf3e5ab4 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Update cursor on Widget

Views client is supposed to use Widget::SetCursor so that
it can tell the correct cursor when asked via GetCursor on Widget.

Exo pointer should follow the same pattern and Arc notification
should simply use the cursor on the widget.

TBR=yoshiki@chromium.org
BUG=798056
TEST=manual. Cursor does not flicker on ARC notifications

Change-Id: I09e93526181c9707786ff1a9b0eb4cb682e6026b
Reviewed-on: https://chromium-review.googlesource.com/903223Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534601}
parent 5ea9cfb3
......@@ -23,6 +23,7 @@
#include "ui/events/event.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/transform_util.h"
#include "ui/views/widget/widget.h"
#if defined(USE_OZONE)
#include "ui/ozone/public/cursor_factory_ozone.h"
......@@ -478,7 +479,22 @@ void Pointer::UpdateCursor() {
#endif
}
cursor_client->SetCursor(cursor_);
// If there is a focused surface, update its widget as the views framework
// expect that Widget knows the current cursor. Otherwise update the
// cursor directly on CursorClient.
if (focus_surface_) {
aura::Window* window = focus_surface_->window();
do {
views::Widget* widget = views::Widget::GetWidgetForNativeView(window);
if (widget) {
widget->SetCursor(cursor_);
return;
}
window = window->parent();
} while (window);
} else {
cursor_client->SetCursor(cursor_);
}
}
} // namespace exo
......@@ -152,10 +152,6 @@ void SurfaceTreeHost::GetHitTestMask(gfx::Path* mask) const {
root_surface_->GetHitTestMask(mask);
}
gfx::NativeCursor SurfaceTreeHost::GetCursor(const gfx::Point& point) const {
return root_surface_ ? root_surface_->GetCursor() : ui::CursorType::kNull;
}
void SurfaceTreeHost::DidReceiveCompositorFrameAck() {
active_frame_callbacks_.splice(active_frame_callbacks_.end(),
frame_callbacks_);
......
......@@ -49,10 +49,6 @@ class SurfaceTreeHost : public SurfaceDelegate,
// surface tree.
void GetHitTestMask(gfx::Path* mask) const;
// Returns the cursor for the given position. If no cursor provider is
// registered then CursorType::kNull is returned.
gfx::NativeCursor GetCursor(const gfx::Point& point) const;
// Call this to indicate that the previous CompositorFrame is processed and
// the surface is being scheduled for a draw.
void DidReceiveCompositorFrameAck();
......
......@@ -30,7 +30,13 @@ 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 notification_surface_->GetCursor(point);
views::Widget* widget = views::Widget::GetTopLevelWidgetForNativeView(
notification_surface_->host_window());
// Exo explicitly update the cursor on widget, so just use the one
// set on the cursor.
if (widget)
return widget->GetNativeWindow()->GetCursor(point /* not used */);
return ui::CursorType::kNull;
}
int GetNonClientComponent(const gfx::Point& point) const override {
return HTNOWHERE;
......
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