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