added more contextual menu buttons

This commit is contained in:
Fabian Freund
2026-03-11 14:57:17 +01:00
parent a457d3dd24
commit 19ec600949
12 changed files with 1054 additions and 0 deletions
@@ -245,6 +245,28 @@ class GeckoSessionApiImpl : GeckoSessionApi {
}
}
override fun dispatchKeyEvent(keyCode: Long) {
try {
logger.debug("$TAG: Dispatching key event with keyCode: $keyCode")
val engineView = components.activeEngineView
?: throw IllegalStateException("No active engine view")
val view = engineView.asView()
val downEvent = android.view.KeyEvent(
android.view.KeyEvent.ACTION_DOWN, keyCode.toInt()
)
view.dispatchKeyEvent(downEvent)
val upEvent = android.view.KeyEvent(
android.view.KeyEvent.ACTION_UP, keyCode.toInt()
)
view.dispatchKeyEvent(upEvent)
} catch (e: Exception) {
logger.error("$TAG: Failed to dispatch key event", e)
throw e
}
}
override fun requestScreenshot(sendBack: Boolean, callback: (Result<ByteArray?>) -> Unit) {
try {
val tab = components.core.store.state.selectedTab
@@ -5401,6 +5401,7 @@ interface GeckoSessionApi {
fun purgeHistory()
fun updateLastAccess(tabId: String?, lastAccess: Long?)
fun requestScreenshot(sendBack: Boolean, callback: (Result<ByteArray?>) -> Unit)
fun dispatchKeyEvent(keyCode: Long)
companion object {
/** The codec used by GeckoSessionApi. */
@@ -5732,6 +5733,24 @@ interface GeckoSessionApi {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoSessionApi.dispatchKeyEvent$separatedMessageChannelSuffix", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val keyCodeArg = args[0] as Long
val wrapped: List<Any?> = try {
api.dispatchKeyEvent(keyCodeArg)
listOf(null)
} catch (exception: Throwable) {
GeckoPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
}
}
}