typedb / typedb-studio

TypeDB Studio (IDE)
https://typedb.com
Mozilla Public License 2.0
191 stars 43 forks source link

Long delay before a clicked vertex receives focus #540

Open alexjpwalker opened 2 years ago

alexjpwalker commented 2 years ago

Problem to Solve

It can take up to half a second for a clicked vertex to receive focus.

Proposed Solution

I wonder if Compose's pointerInput.onTap is laggy? But this worked fine in 2.4.0...

jamesreprise commented 2 years ago

https://github.com/vaticle/typedb-studio/blob/master/view/graph/GraphArea.kt#L305

Fairly certain tryAwaitRelease() on this line is causing this.

jamesreprise commented 2 years ago

Nevermind, passing a onDoubleTap lambda argument to detectTapGestures causes it to awaitSecondDown():

private suspend fun AwaitPointerEventScope.awaitSecondDown(
    firstUp: PointerInputChange
): PointerInputChange? = withTimeoutOrNull(viewConfiguration.doubleTapTimeoutMillis) {
    val minUptime = firstUp.uptimeMillis + viewConfiguration.doubleTapMinTimeMillis
    var change: PointerInputChange
    // The second tap doesn't count if it happens before DoubleTapMinTime of the first tap
    do {
        change = awaitFirstDown()
    } while (change.uptimeMillis < minUptime)
    change
}

meaning we're waiting until it is certainly not a double tap until registering it as a single tap.

We might want to move the double tap explain behaviour out of this entirely, or to find a way of lowering the times associated with waiting for a double tap.