Skip to content

Commit

Permalink
fix: could not scroll down the unrolled candidates
Browse files Browse the repository at this point in the history
Revert the refactors "update context in rime engine lifecycle looper", which will cause unnecessary context update.
  • Loading branch information
WhiredPlanck committed Oct 4, 2024
1 parent 7920903 commit a83725d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
19 changes: 8 additions & 11 deletions app/src/main/java/com/osfans/trime/core/Rime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ class Rime :
lifecycleImpl.emitState(RimeLifecycle.State.READY)
}

override fun nativeScheduleTasks() {
requestRimeResponse()
}

override fun nativeFinalize() {
exitRime()
}
Expand All @@ -84,25 +80,25 @@ class Rime :
modifiers: UInt,
): Boolean =
withRimeContext {
processRimeKey(value, modifiers.toInt())
processRimeKey(value, modifiers.toInt()).also { if (it) requestRimeResponse() }
}

override suspend fun processKey(
value: KeyValue,
modifiers: KeyModifiers,
): Boolean =
withRimeContext {
processRimeKey(value.value, modifiers.toInt())
processRimeKey(value.value, modifiers.toInt()).also { if (it) requestRimeResponse() }
}

override suspend fun selectCandidate(idx: Int): Boolean =
withRimeContext {
selectRimeCandidate(idx)
selectRimeCandidate(idx).also { if (it) requestRimeResponse() }
}

override suspend fun forgetCandidate(idx: Int): Boolean =
withRimeContext {
forgetRimeCandidate(idx)
forgetRimeCandidate(idx).also { if (it) requestRimeResponse() }
}

override suspend fun availableSchemata(): Array<SchemaItem> = withRimeContext { getAvailableRimeSchemaList() }
Expand All @@ -123,11 +119,12 @@ class Rime :
schema ?: schemaItemCached
}

override suspend fun commitComposition(): Boolean = withRimeContext { commitRimeComposition() }
override suspend fun commitComposition(): Boolean = withRimeContext { commitRimeComposition().also { if (it) requestRimeResponse() } }

override suspend fun clearComposition() =
withRimeContext {
clearRimeComposition()
requestRimeResponse()
}

override suspend fun setRuntimeOption(
Expand Down Expand Up @@ -291,7 +288,7 @@ class Rime :
Timber.d("processKey: keyCode=$keycode, mask=$mask")
return processRimeKey(keycode, mask).also {
Timber.d("processKey ${if (it) "success" else "failed"}")
requestRimeResponse()
if (it) requestRimeResponse()
}
}

Expand All @@ -303,7 +300,7 @@ class Rime :
sequence.toString().replace("{}", "{braceleft}{braceright}"),
).also {
Timber.d("simulateKeySequence ${if (it) "success" else "failed"}")
requestRimeResponse()
if (it) requestRimeResponse()
}
}

Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/osfans/trime/core/RimeDispatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class RimeDispatcher(
interface RimeLooper {
fun nativeStartup(fullCheck: Boolean)

fun nativeScheduleTasks()

fun nativeFinalize()
}

Expand Down Expand Up @@ -94,7 +92,6 @@ class RimeDispatcher(
while (isActive && isRunning.get()) {
// TODO: because we have nothing to block currently,
// here we use a channel to wait for a signal.
looper.nativeScheduleTasks()
runBlocking { channel.receive() }
while (true) {
val block = queue.poll() ?: break
Expand Down

0 comments on commit a83725d

Please sign in to comment.