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_.Offset(bounds.origin().x(), bounds.origin().y()); | |
spang
2014/11/10 20:30:47
I noticed a bug. This is using the original locati
llandwerlin-old
2014/11/11 11:03:53
Done.
| |
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::MoveCursor(const gfx::Vector2dF& delta) { | 79 void DriCursor::MoveCursor(const gfx::Vector2dF& delta) { |
76 MoveCursorTo(cursor_window_, cursor_location_ + delta); | 80 MoveCursorTo(cursor_window_, cursor_location_ + delta); |
77 } | 81 } |
78 | 82 |
79 gfx::AcceleratedWidget DriCursor::GetCursorWindow() { | 83 gfx::AcceleratedWidget DriCursor::GetCursorWindow() { |
80 return cursor_window_; | 84 return cursor_window_; |
81 } | 85 } |
82 | 86 |
83 bool DriCursor::IsCursorVisible() { | 87 bool DriCursor::IsCursorVisible() { |
84 return cursor_.get(); | 88 return cursor_.get(); |
85 } | 89 } |
86 | 90 |
87 gfx::PointF DriCursor::location() { | 91 gfx::PointF DriCursor::location() { |
88 return cursor_location_; | 92 return cursor_location_; |
89 } | 93 } |
90 | 94 |
95 gfx::PointF DriCursor::root_location() { | |
96 return cursor_root_location_; | |
97 } | |
98 | |
91 gfx::Point DriCursor::bitmap_location() { | 99 gfx::Point DriCursor::bitmap_location() { |
92 return gfx::ToFlooredPoint(cursor_location_) - | 100 return gfx::ToFlooredPoint(cursor_location_) - |
93 cursor_->hotspot().OffsetFromOrigin(); | 101 cursor_->hotspot().OffsetFromOrigin(); |
94 } | 102 } |
95 | 103 |
96 } // namespace ui | 104 } // namespace ui |
OLD | NEW |