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

Commit 1afc65d2 authored by chaviw's avatar chaviw
Browse files

Fix ActivityView input forwarding.

The current behavior for input expects the input to be in screen space.
However, ActivityView was forwarding input in View space so it was
causing the touch to be in the wrong place.

This fix updates the touch event so it's translated into screen space
before forwarding to the InputManager.

Test: ActivityView touches
Change-Id: I8b86a17adb166fdd95f24610f2ba9ae55c39f7c5
Fixes: 111440225
parent ff2e7d8f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.view.IWindowManager;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceControl;
@@ -291,9 +290,14 @@ public class ActivityView extends ViewGroup {
        return super.onGenericMotionEvent(event);
    }

    private boolean injectInputEvent(InputEvent event) {
    private boolean injectInputEvent(MotionEvent event) {
        if (mInputForwarder != null) {
            try {
                // The touch event that the ActivityView gets is in View space, but the event needs
                // to get forwarded in screen space. This offsets the touch event by the location
                // the ActivityView is on screen and sends it to the input forwarder.
                getLocationOnScreen(mLocationOnScreen);
                event.offsetLocation(mLocationOnScreen[0], mLocationOnScreen[1]);
                return mInputForwarder.forwardEvent(event);
            } catch (RemoteException e) {
                e.rethrowAsRuntimeException();