[Magnifier-41] Fix behavior in windows with insets
The CL fixes the magnifier's behavior when its parent window has positive insets in its surface: - we compute the content copy coordinates sent to the pixel copy request relative to the surface the content is copied from. We were clamping them inside the visible region of the magnified view as returned by belonging to the view which is magnified. However, the method returns coordinates relative to the window. Therefore, the CL offsets the visible rectangle with the window insets, to account for them. Otherwise, when the insets were non-zero, on a text line we were allowing the magnifier to display content from the left outside of the text line, while a certain region at the end of the text line could have never been magnified - when clamping against the visible view region, when the surface we copy from is a SurfaceView, #getGlobalVisibleRect is still returning coordinates relative to the main window, whereas the coordinates we are trying to clamp are relative to the surface of the SurfaceView. In order to make the visible rectangle relative to the surface of the SurfaceView instead, this CL negatively offsets the visible rectangle with the SurfaceView position in the parent surface - the selection/insertion handles are hidden when they overlap the magnifier. To check this, we intersect the magnifier rectangle with the rectangle of each handle. However, when we were performing this check, the magnifier rectangle was relative to the surface, whereas the handles' rectangle was relative to the main window. The CL negatively offsets the magnifier position with the surface insets, to make both rectangles relative to the window. Bug: 78621162 Test: manual testing Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest Change-Id: I0d749c1abb38520fe8fc477d22d6523f470e9abc
Loading
Please register or sign in to comment