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

Commit 5a86d8be authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Move global touch handling from SceneContainer to SceneWindowRootView

SceneContainer isn't the best place to forward touches to the
FalsingCollector and other code that needs to know about all touches --
it doesn't see all touches on NSSL, but it does see some touches that
NSSL explicitly chooses to forward, and some of those have a synthetic
ACTION_DOWN instead of their original ACTION_MOVE.

SceneWindowRootView, however, is a great place -- it sees every touch
before NSSL or SceneContainer gets a hand on them, and can thus call
FalsingCollector.onTouchEvent and .onMotionEventComplete before and
after all other touch handling.

Bug: 330492016
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Test: manual: post many notifs and tap notif shelf on LS, generally monkey around on LS
Change-Id: Ifc2e2f9a2b65df96d012093112ea51ce34172845
parent 402f8f20
Loading
Loading
Loading
Loading
+1 −18
Original line number Diff line number Diff line
@@ -30,9 +30,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.PointerEventPass
import androidx.compose.ui.input.pointer.motionEventSpy
import androidx.compose.ui.input.pointer.pointerInput
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.scene.MutableSceneTransitionLayoutState
import com.android.compose.animation.scene.SceneKey
@@ -94,21 +91,7 @@ fun SceneContainer(
    Box(
        modifier = Modifier.fillMaxSize(),
    ) {
        SceneTransitionLayout(
            state = state,
            modifier =
                modifier
                    .fillMaxSize()
                    .motionEventSpy { event -> viewModel.onMotionEvent(event) }
                    .pointerInput(Unit) {
                        awaitPointerEventScope {
                            while (true) {
                                awaitPointerEvent(PointerEventPass.Final)
                                viewModel.onMotionEventComplete()
                            }
                        }
                    }
        ) {
        SceneTransitionLayout(state = state, modifier = modifier.fillMaxSize()) {
            sceneByKey.forEach { (sceneKey, composableScene) ->
                scene(
                    key = sceneKey,
+14 −0
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@ package com.android.systemui.scene.ui.view

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.WindowInsets
import com.android.systemui.scene.shared.model.Scene
import com.android.systemui.scene.shared.model.SceneContainerConfig
import com.android.systemui.scene.shared.model.SceneDataSourceDelegator
import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
import com.android.systemui.shade.TouchLogger
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import kotlinx.coroutines.flow.MutableStateFlow

@@ -60,4 +62,16 @@ class SceneWindowRootView(
        this.windowInsets.value = windowInsets
        return windowInsets
    }

    override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
        viewModel.onMotionEvent(ev)
        return super.dispatchTouchEvent(ev).also {
            TouchLogger.logDispatchTouch(TAG, ev, it)
            viewModel.onMotionEventComplete()
        }
    }

    companion object {
        private const val TAG = "SceneWindowRootView"
    }
}