Set appropriate cursor position on viewport transition
This CL updates PointerChoreographer to set position of the cursor on
the destination display when cursor crosses the boundary.
Also updates the logic to lookup destination displays in topology to
account for size and offset of the display.
Test: presubmit and manual
Bug: 367660694
Flag: com.android.input.flags.connected_displays_cursor
Change-Id: I18e3bd925a44d541e34946494e7e1b9db0a2e786
diff --git a/services/inputflinger/PointerChoreographer.h b/services/inputflinger/PointerChoreographer.h
index a969935..4ca7323 100644
--- a/services/inputflinger/PointerChoreographer.h
+++ b/services/inputflinger/PointerChoreographer.h
@@ -114,11 +114,11 @@
void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
// TODO(b/362719483) remove these when real topology is available
- enum class DisplayPosition : int32_t {
- RIGHT = 0,
- TOP = 1,
- LEFT = 2,
- BOTTOM = 3,
+ enum class DisplayPosition {
+ RIGHT,
+ TOP,
+ LEFT,
+ BOTTOM,
ftl_last = BOTTOM,
};
@@ -177,9 +177,12 @@
void populateFakeDisplayTopologyLocked(const std::vector<gui::DisplayInfo>& displayInfos)
REQUIRES(getLock());
- std::optional<const DisplayViewport*> findDestinationDisplayLocked(
- const DisplayViewport& sourceViewport, const FloatPoint& unconsumedDelta) const
- REQUIRES(getLock());
+ std::optional<std::pair<const DisplayViewport*, float /*offset*/>> findDestinationDisplayLocked(
+ const ui::LogicalDisplayId sourceDisplayId, const DisplayPosition sourceBoundary,
+ float cursorOffset) const REQUIRES(getLock());
+
+ static vec2 calculateDestinationPosition(const DisplayViewport& destinationViewport,
+ float pointerOffset, DisplayPosition sourceBoundary);
std::unordered_map<ui::LogicalDisplayId, std::vector<AdjacentDisplay>> mTopology
GUARDED_BY(getLock());