Improve robustness of DisplayLayout creation
During a window drag operation, mGlobalBoundsDp from DisplayLayout is
used to determine if the window intersects with the display and to
render an indicator surface showing the window's current position.
Previously, creating a DisplayLayout and setting its mGlobalBoundsDp
from the display topology were two separate steps. This design was
fragile, as a future developer could easily add a new call site to
create a DisplayLayou` but forget to set its global bounds.
This commit refactors display layout creation to be more robust
by coupling the creation and initialization:
1. Consolidate Bounds Initialization: The DisplayRecord.createLayout()
method is now responsible for both creating the DisplayLayout and
populating its mGlobalBoundsDp.
2. Add a Safety Net: DisplayLayout.mGlobalBoundsDp is now initialized
to an empty RectF(). This acts as a failsafe, ensuring that if
topology is somehow unavailable at creation time, the layout will
not cause incorrect intersections.
Separately, this commit also removes the mUnpopulatedDisplayBounds
caching mechanism. This was originally implemented to handle a race
condition between onDisplayTopologyChanged and onDisplayAdded. It is no
longer necessary because the DisplayController now maintains a reference
to the latest DisplayTopology.
Bug: 419272794
Test: Manual test; atest WMShellUnitTests:DisplayControllerTests
Flag: com.android.window.flags.enable_connected_displays_window_drag
Change-Id: Ibfec219f1202d84ddefc78cf723a852cade1ecd5
Loading
Please register or sign in to comment