Revert "Check if cursor has moved out of viewport bounds in Curs..."
Revert submission 30111126-cd-cursor
Reason for revert: DroidMonitor: Potential culprit for http://b/379706345 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Reverted changes: /q/submissionid:30111126-cd-cursor
Change-Id: Ibff6c02be1359729802d4c85fa8dc0fdb4c75492
diff --git a/libs/input/MouseCursorController.cpp b/libs/input/MouseCursorController.cpp
index 4330f0a..d993b87 100644
--- a/libs/input/MouseCursorController.cpp
+++ b/libs/input/MouseCursorController.cpp
@@ -28,15 +28,13 @@
#define INDENT " "
#define INDENT2 " "
-namespace android {
-
namespace {
-
// Time to spend fading out the pointer completely.
const nsecs_t POINTER_FADE_DURATION = 500 * 1000000LL; // 500 ms
-
} // namespace
+namespace android {
+
// --- MouseCursorController ---
MouseCursorController::MouseCursorController(PointerControllerContext& context)
@@ -66,21 +64,17 @@
mLocked.pointerSprite.clear();
}
-vec2 MouseCursorController::move(float deltaX, float deltaY) {
+void MouseCursorController::move(float deltaX, float deltaY) {
#if DEBUG_MOUSE_CURSOR_UPDATES
ALOGD("Move pointer by deltaX=%0.3f, deltaY=%0.3f", deltaX, deltaY);
#endif
if (deltaX == 0.0f && deltaY == 0.0f) {
- return {};
+ return;
}
- // When transition occurs, the MouseCursorController object may or may not be deleted, depending
- // if there's another display on the other side of the transition. At this point we still need
- // to move the cursor to the boundary.
std::scoped_lock lock(mLock);
- const vec2 pos{mLocked.pointerX + deltaX, mLocked.pointerY + deltaY};
- setPositionLocked(pos.x, pos.y);
- return vec2{pos.x - mLocked.pointerX, pos.y - mLocked.pointerY};
+
+ setPositionLocked(mLocked.pointerX + deltaX, mLocked.pointerY + deltaY);
}
void MouseCursorController::setPosition(float x, float y) {
@@ -88,26 +82,22 @@
ALOGD("Set pointer position to x=%0.3f, y=%0.3f", x, y);
#endif
std::scoped_lock lock(mLock);
-
setPositionLocked(x, y);
}
-FloatRect MouseCursorController::getBoundsLocked() REQUIRES(mLock) {
+void MouseCursorController::setPositionLocked(float x, float y) REQUIRES(mLock) {
+ const auto& v = mLocked.viewport;
+ if (!v.isValid()) return;
+
// The valid bounds for a mouse cursor. Since the right and bottom edges are considered outside
// the display, clip the bounds by one pixel instead of letting the cursor get arbitrarily
// close to the outside edge.
- return FloatRect{
+ const FloatRect bounds{
static_cast<float>(mLocked.viewport.logicalLeft),
static_cast<float>(mLocked.viewport.logicalTop),
static_cast<float>(mLocked.viewport.logicalRight - 1),
static_cast<float>(mLocked.viewport.logicalBottom - 1),
};
-}
-void MouseCursorController::setPositionLocked(float x, float y) REQUIRES(mLock) {
- const auto& v = mLocked.viewport;
- if (!v.isValid()) return;
-
- const FloatRect bounds = getBoundsLocked();
mLocked.pointerX = std::max(bounds.left, std::min(bounds.right, x));
mLocked.pointerY = std::max(bounds.top, std::min(bounds.bottom, y));