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

Commit 5f31a4bd authored by Michael Wright's avatar Michael Wright Committed by Android (Google) Code Review
Browse files

Merge "Remove unnecessary input event indirection"

parents 8509ccce c9c487e6
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -31,11 +31,13 @@ import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowManagerPolicy.PointerEventListener;
import android.view.MotionEvent.PointerCoords;

import java.util.ArrayList;

public class PointerLocationView extends View implements InputDeviceListener {
public class PointerLocationView extends View implements InputDeviceListener,
        PointerEventListener {
    private static final String TAG = "Pointer";

    // The system property key used to specify an alternate velocity tracker strategy
@@ -520,7 +522,8 @@ public class PointerLocationView extends View implements InputDeviceListener {
                .toString());
    }

    public void addPointerEvent(MotionEvent event) {
    @Override
    public void onPointerEvent(MotionEvent event) {
        final int action = event.getAction();
        int NP = mPointers.size();

@@ -648,7 +651,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
    
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        addPointerEvent(event);
        onPointerEvent(event);

        if (event.getAction() == MotionEvent.ACTION_DOWN && !isFocused()) {
            requestFocus();
@@ -660,7 +663,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
    public boolean onGenericMotionEvent(MotionEvent event) {
        final int source = event.getSource();
        if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) {
            addPointerEvent(event);
            onPointerEvent(event);
        } else if ((source & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
            logMotionEvent("Joystick", event);
        } else if ((source & InputDevice.SOURCE_CLASS_POSITION) != 0) {
+3 −23
Original line number Diff line number Diff line
@@ -308,17 +308,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    WindowState mFocusedWindow;
    IApplicationToken mFocusedApp;

    private final class PointerLocationPointerEventListener implements PointerEventListener {
        @Override
        public void onPointerEvent(MotionEvent motionEvent) {
            if (mPointerLocationView != null) {
                mPointerLocationView.addPointerEvent(motionEvent);
            }
        }
    }

    // Pointer location view state, only modified on the mHandler Looper.
    PointerLocationPointerEventListener mPointerLocationPointerEventListener;
    PointerLocationView mPointerLocationView;

    // The current size of the screen; really; extends into the overscan area of
@@ -1190,7 +1179,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (mPointerLocationView == null) {
            mPointerLocationView = new PointerLocationView(mContext);
            mPointerLocationView.setPrintCoords(false);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT);
@@ -1210,22 +1198,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mContext.getSystemService(Context.WINDOW_SERVICE);
            lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL;
            wm.addView(mPointerLocationView, lp);

            mPointerLocationPointerEventListener = new PointerLocationPointerEventListener();
            mWindowManagerFuncs.registerPointerEventListener(mPointerLocationPointerEventListener);
            mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView);
        }
    }

    private void disablePointerLocation() {
        if (mPointerLocationPointerEventListener != null) {
            mWindowManagerFuncs.unregisterPointerEventListener(
                    mPointerLocationPointerEventListener);
            mPointerLocationPointerEventListener = null;
        }

        if (mPointerLocationView != null) {
            WindowManager wm = (WindowManager)
                    mContext.getSystemService(Context.WINDOW_SERVICE);
            mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView);
            WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
            wm.removeView(mPointerLocationView);
            mPointerLocationView = null;
        }