Skip to content

Commit 3c769a4

Browse files
author
Arpit Singh
committed
[CD Cursor] Update pointer display in line with topology update
This CL fixes issues related to pointer display on topology update. When we are working with topology cursor display should only be updated when topology is updated or user moves the cursor between displays. This CL Specifically implements following behaviour: 1. Ignore setDefaultMouseDisplayId whith topology. 2. Only update pointer display when topology is set. 3. Fallback to the primary display id pointer display is removed. Test: atest inputflinger_tests Bug: 395033854 Flag: com.android.input.flags.connected_displays_cursor Change-Id: I576107b0ee5b81d596bdb91c796ceb6ac9eb2f73
1 parent 44ff4fc commit 3c769a4

2 files changed

Lines changed: 274 additions & 102 deletions

File tree

services/inputflinger/PointerChoreographer.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,21 @@ void PointerChoreographer::notifyPointerCaptureChanged(
602602
}
603603

604604
void PointerChoreographer::setDisplayTopology(const DisplayTopologyGraph& displayTopologyGraph) {
605-
std::scoped_lock _l(getLock());
606-
mTopology = displayTopologyGraph;
605+
PointerDisplayChange pointerDisplayChange;
606+
{ // acquire lock
607+
std::scoped_lock _l(getLock());
608+
mTopology = displayTopologyGraph;
609+
610+
// make primary display default mouse display, if it was not set or
611+
// the existing display was removed
612+
if (mDefaultMouseDisplayId == ui::LogicalDisplayId::INVALID ||
613+
mTopology.graph.find(mDefaultMouseDisplayId) == mTopology.graph.end()) {
614+
mDefaultMouseDisplayId = mTopology.primaryDisplayId;
615+
pointerDisplayChange = updatePointerControllersLocked();
616+
}
617+
} // release lock
607618

608-
// make primary display default mouse display, if it was not set
609-
// or the existing display was removed
610-
if (mDefaultMouseDisplayId == ui::LogicalDisplayId::INVALID ||
611-
mTopology.graph.find(mDefaultMouseDisplayId) != mTopology.graph.end()) {
612-
mDefaultMouseDisplayId = mTopology.primaryDisplayId;
613-
}
619+
notifyPointerDisplayChange(pointerDisplayChange, mPolicy);
614620
}
615621

616622
void PointerChoreographer::dump(std::string& dump) {
@@ -785,6 +791,10 @@ PointerChoreographer::calculatePointerDisplayChangeToNotify() {
785791
}
786792

787793
void PointerChoreographer::setDefaultMouseDisplayId(ui::LogicalDisplayId displayId) {
794+
if (InputFlags::connectedDisplaysCursorEnabled()) {
795+
// In connected displays scenario, default mouse display will only be updated from topology.
796+
return;
797+
}
788798
PointerDisplayChange pointerDisplayChange;
789799

790800
{ // acquire lock

0 commit comments

Comments
 (0)