docs: explain Tessera modules and execution flows in Chinese
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
//! 原生窗口输入到执行 worker 的纯数据传输。Input 只含窗口/会话/版本/Mount 身份及有限坐标。
|
||||
//! 连续相机和滚动输入出队时可更新帧版本,但不改变捕获目标和所属 VM;离散点击仍保留严格的过期帧语义。
|
||||
//! 队列有界且当前逐项经本地 HTTP 发送;这不意味着输入已经按显示帧合并,也不是无损无限队列。
|
||||
//!
|
||||
//! Native input transport. Frame/mount identities and optional logical pointer positions cross to the VM worker.
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
@@ -14,6 +18,7 @@ use winit::event_loop::EventLoopProxy;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
/// 拖放目标窗口、目标布局版本和插入位置,源标签身份由外层 Input 保存。
|
||||
pub struct TabDrop {
|
||||
pub window: u64,
|
||||
pub layout_version: u64,
|
||||
@@ -22,6 +27,7 @@ pub struct TabDrop {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
/// 原生或 HTTP 输入的纯数据报文;身份与坐标必须同时通过 worker 和能力校验。
|
||||
pub struct Input {
|
||||
#[serde(default = "default_window")]
|
||||
pub window: u64,
|
||||
@@ -41,11 +47,13 @@ pub struct Input {
|
||||
pub screen_position: Option<[i32; 2]>,
|
||||
}
|
||||
|
||||
/// 返回默认主窗口身份,供省略窗口字段的兼容输入使用。
|
||||
fn default_window() -> u64 {
|
||||
crate::window::MAIN_WINDOW
|
||||
}
|
||||
|
||||
impl Input {
|
||||
/// 检查当前输入或发布值的不变量,调用方据校验结果决定是否继续。
|
||||
pub fn validate(&self) -> Result<(), &'static str> {
|
||||
if self.window == 0 {
|
||||
return Err("window identity must be nonzero");
|
||||
@@ -154,8 +162,10 @@ impl Input {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
/// 原生输入的有界发送端,后台线程串行发往本地 API;所有窗口共享权威发布状态。
|
||||
pub struct Client(SyncSender<Input>);
|
||||
impl Client {
|
||||
/// 构造本类型并初始化其状态;资源建立和默认字段以函数体为准。
|
||||
pub fn new(
|
||||
proxy: EventLoopProxy<crate::app::AppEvent>,
|
||||
namespace: Arc<RwLock<crate::document::NamespaceState>>,
|
||||
@@ -181,6 +191,7 @@ impl Client {
|
||||
})?;
|
||||
Ok(Self(sender))
|
||||
}
|
||||
/// 通过有界原生输入客户端或本地 HTTP 发送纯数据事件;过期版本按既定协议处理。
|
||||
pub fn send(&self, input: Input) -> bool {
|
||||
self.0.try_send(input).is_ok()
|
||||
}
|
||||
@@ -189,6 +200,7 @@ impl Client {
|
||||
// Native gestures retain the captured Mount across publications. Refresh only
|
||||
// the version at dequeue, never session, window or target. HTTP callers and
|
||||
// discrete actions still receive strict stale-frame rejection.
|
||||
/// 连续手势出队时只更新有效目标的帧版本;保留原 session、窗口和 Mount,离散事件不自动重试。
|
||||
fn refresh_continuous_input(input: &mut Input, current: &crate::document::NamespaceState) -> bool {
|
||||
if !matches!(
|
||||
input.kind.as_str(),
|
||||
@@ -228,6 +240,7 @@ fn refresh_continuous_input(input: &mut Input, current: &crate::document::Namesp
|
||||
true
|
||||
}
|
||||
|
||||
/// 通过有界原生输入客户端或本地 HTTP 发送纯数据事件;过期版本按既定协议处理。
|
||||
fn send(input: &Input) -> anyhow::Result<()> {
|
||||
let body = serde_json::to_string(input)?;
|
||||
let mut stream =
|
||||
|
||||
Reference in New Issue
Block a user