Commit d693c730 authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-DRI] Fix cursor showing on wrong monitor after display changes

When windows are moved the underlying display controller changes. In these cases
we need to hide the cursor before moving and restore it after.

BUG=none
NOTRY=true

Review URL: https://codereview.chromium.org/566953002

Cr-Commit-Position: refs/heads/master@{#294699}
parent 5a27ea9e
......@@ -27,23 +27,32 @@ void DriCursor::SetCursor(gfx::AcceleratedWidget widget,
PlatformCursor platform_cursor) {
scoped_refptr<BitmapCursorOzone> cursor =
BitmapCursorFactoryOzone::GetBitmapCursor(platform_cursor);
if (cursor_ == cursor)
if (cursor_ == cursor || cursor_window_ != widget)
return;
cursor_ = cursor;
if (cursor_.get())
ShowCursor();
}
void DriCursor::ShowCursor() {
if (cursor_.get())
hardware_->SetHardwareCursor(cursor_window_,
cursor_->bitmaps(),
bitmap_location(),
cursor_->frame_delay_ms());
else
UnsetCursor(cursor_window_);
HideCursor();
}
void DriCursor::HideCursor() {
hardware_->SetHardwareCursor(
cursor_window_, std::vector<SkBitmap>(), gfx::Point(), 0);
}
void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) {
if (widget != cursor_window_)
UnsetCursor(cursor_window_);
HideCursor();
cursor_window_ = widget;
cursor_location_ = location;
......@@ -77,9 +86,4 @@ gfx::Point DriCursor::bitmap_location() {
cursor_->hotspot().OffsetFromOrigin();
}
void DriCursor::UnsetCursor(gfx::AcceleratedWidget widget) {
hardware_->SetHardwareCursor(
widget, std::vector<SkBitmap>(), gfx::Point(), 0);
}
} // namespace ui
......@@ -27,6 +27,8 @@ class DriCursor : public CursorDelegateEvdev {
virtual ~DriCursor();
void SetCursor(gfx::AcceleratedWidget widget, PlatformCursor platform_cursor);
void ShowCursor();
void HideCursor();
gfx::AcceleratedWidget GetCursorWindow();
// CursorDelegateEvdev:
......@@ -37,8 +39,6 @@ class DriCursor : public CursorDelegateEvdev {
virtual gfx::PointF location() OVERRIDE;
private:
void UnsetCursor(gfx::AcceleratedWidget widget);
// The location of the bitmap (the cursor location is the hotspot location).
gfx::Point bitmap_location();
......
......@@ -55,7 +55,13 @@ void DriWindow::Close() {}
void DriWindow::SetBounds(const gfx::Rect& bounds) {
bounds_ = bounds;
delegate_->OnBoundsChanged(bounds);
if (cursor_->GetCursorWindow() == widget_)
cursor_->HideCursor();
dri_window_delegate_->OnBoundsChanged(bounds);
if (cursor_->GetCursorWindow() == widget_)
cursor_->ShowCursor();
}
gfx::Rect DriWindow::GetBounds() {
......
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