| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/dri/dri_cursor.h" | 5 #include "ui/ozone/platform/dri/dri_cursor.h" |
| 6 | 6 |
| 7 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 7 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 8 #include "ui/gfx/geometry/point.h" | 8 #include "ui/gfx/geometry/point.h" |
| 9 #include "ui/gfx/geometry/point_conversions.h" | 9 #include "ui/gfx/geometry/point_conversions.h" |
| 10 #include "ui/gfx/geometry/point_f.h" | 10 #include "ui/gfx/geometry/point_f.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 gfx::Point(), 0); | 51 gfx::Point(), 0); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget, | 54 void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget, |
| 55 const gfx::PointF& location) { | 55 const gfx::PointF& location) { |
| 56 if (widget != cursor_window_ && cursor_window_ != gfx::kNullAcceleratedWidget) | 56 if (widget != cursor_window_ && cursor_window_ != gfx::kNullAcceleratedWidget) |
| 57 HideCursor(); | 57 HideCursor(); |
| 58 | 58 |
| 59 cursor_window_ = widget; | 59 cursor_window_ = widget; |
| 60 cursor_location_ = location; | 60 cursor_location_ = location; |
| 61 cursor_root_location_ = location; |
| 61 | 62 |
| 62 if (cursor_window_ == gfx::kNullAcceleratedWidget) | 63 if (cursor_window_ == gfx::kNullAcceleratedWidget) |
| 63 return; | 64 return; |
| 64 | 65 |
| 65 DriWindow* window = window_manager_->GetWindow(cursor_window_); | 66 DriWindow* window = window_manager_->GetWindow(cursor_window_); |
| 66 const gfx::Size& size = window->GetBounds().size(); | 67 gfx::Rect bounds = window->GetBounds(); |
| 68 const gfx::Size& size = bounds.size(); |
| 67 cursor_location_.SetToMax(gfx::PointF(0, 0)); | 69 cursor_location_.SetToMax(gfx::PointF(0, 0)); |
| 68 // Right and bottom edges are exclusive. | 70 // Right and bottom edges are exclusive. |
| 69 cursor_location_.SetToMin(gfx::PointF(size.width() - 1, size.height() - 1)); | 71 cursor_location_.SetToMin(gfx::PointF(size.width() - 1, size.height() - 1)); |
| 70 | 72 |
| 73 cursor_root_location_ = cursor_location_ + bounds.OffsetFromOrigin(); |
| 74 |
| 71 if (cursor_.get()) | 75 if (cursor_.get()) |
| 72 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location()); | 76 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location()); |
| 73 } | 77 } |
| 74 | 78 |
| 75 void DriCursor::MoveCursorTo(const gfx::PointF& location) { | 79 void DriCursor::MoveCursorTo(const gfx::PointF& location) { |
| 76 MoveCursorTo(cursor_window_, location); | 80 MoveCursorTo(cursor_window_, location); |
| 77 } | 81 } |
| 78 | 82 |
| 79 void DriCursor::MoveCursor(const gfx::Vector2dF& delta) { | 83 void DriCursor::MoveCursor(const gfx::Vector2dF& delta) { |
| 80 MoveCursorTo(cursor_window_, cursor_location_ + delta); | 84 MoveCursorTo(cursor_window_, cursor_location_ + delta); |
| 81 } | 85 } |
| 82 | 86 |
| 83 gfx::Rect DriCursor::GetCursorDisplayBounds() { | 87 gfx::Rect DriCursor::GetCursorDisplayBounds() { |
| 84 if (cursor_window_ == gfx::kNullAcceleratedWidget) | 88 if (cursor_window_ == gfx::kNullAcceleratedWidget) |
| 85 return gfx::Rect(); | 89 return gfx::Rect(); |
| 86 | 90 |
| 87 DriWindow* window = window_manager_->GetWindow(cursor_window_); | 91 DriWindow* window = window_manager_->GetWindow(cursor_window_); |
| 88 return window->GetBounds(); | 92 return window->GetBounds(); |
| 89 } | 93 } |
| 90 | 94 |
| 91 gfx::AcceleratedWidget DriCursor::GetCursorWindow() { | 95 gfx::AcceleratedWidget DriCursor::GetCursorWindow() { |
| 92 return cursor_window_; | 96 return cursor_window_; |
| 93 } | 97 } |
| 94 | 98 |
| 95 bool DriCursor::IsCursorVisible() { | 99 bool DriCursor::IsCursorVisible() { |
| 96 return cursor_.get(); | 100 return cursor_.get(); |
| 97 } | 101 } |
| 98 | 102 |
| 99 gfx::PointF DriCursor::location() { | 103 gfx::PointF DriCursor::GetLocation() { |
| 100 return cursor_location_; | 104 return cursor_location_; |
| 101 } | 105 } |
| 102 | 106 |
| 107 gfx::PointF DriCursor::GetRootLocation() { |
| 108 return cursor_root_location_; |
| 109 } |
| 110 |
| 103 gfx::Point DriCursor::bitmap_location() { | 111 gfx::Point DriCursor::bitmap_location() { |
| 104 return gfx::ToFlooredPoint(cursor_location_) - | 112 return gfx::ToFlooredPoint(cursor_location_) - |
| 105 cursor_->hotspot().OffsetFromOrigin(); | 113 cursor_->hotspot().OffsetFromOrigin(); |
| 106 } | 114 } |
| 107 | 115 |
| 108 } // namespace ui | 116 } // namespace ui |
| OLD | NEW |