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

Commit 59f532ef authored by chaviw's avatar chaviw
Browse files

Fix drag and drop (1/3)

Add transferTouchFoucus API in SurfaceControl to pass info to native.

Test: Builds
Bug: 120463595
Change-Id: Ifb20a135c13de7380176e285dac273eef776ee19
parent 36d3b7a0
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -165,7 +165,8 @@ public class SurfaceControl implements Parcelable {

    private static native void nativeSetInputWindowInfo(long transactionObj, long nativeObject,
            InputWindowHandle handle);

    private static native void nativeTransferTouchFocus(long transactionObj, IBinder fromToken,
            IBinder toToken);

    private final CloseGuard mCloseGuard = CloseGuard.get();
    private final String mName;
@@ -1541,6 +1542,21 @@ public class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Transfers touch focus from one window to another. It is possible for multiple windows to
         * have touch focus if they support split touch dispatch
         * {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH} but this
         * method only transfers touch focus of the specified window without affecting
         * other windows that may also have touch focus at the same time.
         * @param fromToken The token of a window that currently has touch focus.
         * @param toToken The token of the window that should receive touch focus in
         * place of the first.
         */
        public Transaction transferTouchFocus(IBinder fromToken, IBinder toToken) {
            nativeTransferTouchFocus(mNativeObject, fromToken, toToken);
            return this;
        }

        @UnsupportedAppUsage
        public Transaction setMatrix(SurfaceControl sc,
                float dsdx, float dtdx, float dtdy, float dsdy) {
+12 −1
Original line number Diff line number Diff line
@@ -348,6 +348,15 @@ static void nativeSetInputWindowInfo(JNIEnv* env, jclass clazz, jlong transactio
    transaction->setInputWindowInfo(ctrl, *handle->getInfo());
}

static void nativeTransferTouchFocus(JNIEnv* env, jclass clazz, jlong transactionObj,
        jobject fromTokenObj, jobject toTokenObj) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);

    sp<IBinder> fromToken(ibinderForJavaObject(env, fromTokenObj));
    sp<IBinder> toToken(ibinderForJavaObject(env, toTokenObj));
    transaction->transferTouchFocus(fromToken, toToken);
}

static void nativeSetColor(JNIEnv* env, jclass clazz, jlong transactionObj,
        jlong nativeObject, jfloatArray fColor) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -1033,6 +1042,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeCaptureLayers },
    {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V",
            (void*)nativeSetInputWindowInfo },
    {"nativeTransferTouchFocus", "(JLandroid/os/IBinder;Landroid/os/IBinder;)V",
            (void*)nativeTransferTouchFocus },
    {"nativeGetDisplayedContentSamplingAttributes",
            "(Landroid/os/IBinder;)Landroid/hardware/display/DisplayedContentSamplingAttributes;",
            (void*)nativeGetDisplayedContentSamplingAttributes },