Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51141c0a authored by Robert Carr's avatar Robert Carr
Browse files

ScreenMagnifier: Track SurfaceFlinger Input

Surface scaling is now automatically/in-general applied to input
coordinates and so the accessibility service doesn't need to do
it's own scaling. We also track the renaming of "scaleFactor"
to "globalScaleFactor"

Bug: 80101428
Bug: 113136004
Bug: 111440400
Test: Magnifier works
Change-Id: Ib6a0ad7df56c7d040497d6f352abe3d74c38a49f
parent fcc08525
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ bool NativeInputWindowHandle::updateInfo() {
            gInputWindowHandleClassInfo.frameBottom);
    mInfo.surfaceInset = env->GetIntField(obj,
            gInputWindowHandleClassInfo.surfaceInset);
    mInfo.scaleFactor = env->GetFloatField(obj,
    mInfo.globalScaleFactor = env->GetFloatField(obj,
            gInputWindowHandleClassInfo.scaleFactor);

    jobject regionObj = env->GetObjectField(obj,
+0 −27
Original line number Diff line number Diff line
@@ -273,33 +273,6 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation {

    private void dispatchTransformedEvent(MotionEvent event, MotionEvent rawEvent,
            int policyFlags) {
        if (DEBUG_ALL) Slog.i(LOG_TAG, "dispatchTransformedEvent(event = " + event + ")");

        // If the touchscreen event is within the magnified portion of the screen we have
        // to change its location to be where the user thinks he is poking the
        // UI which may have been magnified and panned.
        if (mMagnificationController.isMagnifying()
                && event.isFromSource(SOURCE_TOUCHSCREEN)
                && mMagnificationController.magnificationRegionContains(
                        event.getX(), event.getY())) {
            final float scale = mMagnificationController.getScale();
            final float scaledOffsetX = mMagnificationController.getOffsetX();
            final float scaledOffsetY = mMagnificationController.getOffsetY();
            final int pointerCount = event.getPointerCount();
            PointerCoords[] coords = getTempPointerCoordsWithMinSize(pointerCount);
            PointerProperties[] properties = getTempPointerPropertiesWithMinSize(
                    pointerCount);
            for (int i = 0; i < pointerCount; i++) {
                event.getPointerCoords(i, coords[i]);
                coords[i].x = (coords[i].x - scaledOffsetX) / scale;
                coords[i].y = (coords[i].y - scaledOffsetY) / scale;
                event.getPointerProperties(i, properties[i]);
            }
            event = MotionEvent.obtain(event.getDownTime(),
                    event.getEventTime(), event.getAction(), pointerCount, properties,
                    coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0, event.getSource(),
                    event.getFlags());
        }
        if (DEBUG_EVENT_STREAM) {
            storeEventInto(mDebugOutputEventHistory, event);
            try {