docs: clarify presentation state and window resource lifecycle
This commit is contained in:
+9
-1
@@ -283,6 +283,8 @@ impl NativeCallable for Method {
|
||||
}
|
||||
}
|
||||
/// 把合法窗口操作追加到所属窗口的待发布命令,不能直接在 VM 线程操作 OS。
|
||||
/// Method::invoke 先检查尺寸/标题/只读规则;工具激活和 close 也直接调用本入口,因此 closed 与动作参数并不在这里重验。
|
||||
/// 返回成功只表示 outbox 已排队;worker 成功发布并封装 session 后,shell::app 才可能执行动作。
|
||||
pub fn enqueue(
|
||||
cx: &mut NativeContext<'_>,
|
||||
owner: ObjectRef,
|
||||
@@ -314,12 +316,14 @@ pub fn enqueue(
|
||||
// 必须先成功经过 VM 写屏障,才修改不可回滚的原生 outbox;只读调用不能先留下待发命令再报错。
|
||||
cx.replace_payload(owner, data)?;
|
||||
// 同窗口同动作只保留最后请求,其他类别保持先后;此处只入队,GUI 是否执行取决于后续成功发布。
|
||||
// 例如 Resize(seq1)、Focus(seq2)、Resize(seq3) 会留下 Focus(seq2)、Resize(seq3),不能保留首次 Resize 的旧序号。
|
||||
queue.retain(|old| !old.same_kind(&command));
|
||||
queue.push(command);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 将页面登记到其窗口,维护托管所有权与页面顺序。
|
||||
/// UiBridge::show_in 在调用前处理跨窗撤登记;本入口只保证该窗口内不重复,不负责查找或迁移其他窗口的同一 Page。
|
||||
pub fn register_page(
|
||||
cx: &mut NativeContext<'_>,
|
||||
window: ObjectRef,
|
||||
@@ -443,6 +447,7 @@ pub fn pages(store: &ObjectStore, window: ObjectRef) -> Result<&[ObjectRef], VmE
|
||||
Ok(&store.payload::<ManagedWindow>(window, "Window")?.pages)
|
||||
}
|
||||
/// 取走当前窗口累积的命令,后续由成功发布结果携带到 GUI。
|
||||
/// 正常发布路径会封装返回值;故障清理路径也调用本函数但直接丢弃结果,所以 drain 本身不能视为发布成功。
|
||||
pub fn take_commands(vm: &Vm, window: ObjectRef) -> Result<Vec<Command>, VmError> {
|
||||
// 读取 payload 只取得共享 transport outbox;drain 不应制造业务依赖写入。
|
||||
let data = vm.payload::<ManagedWindow>(window, "Window")?;
|
||||
@@ -546,7 +551,8 @@ pub fn install(
|
||||
|
||||
/// Create a managed native-window resource. The GUI creates the OS resource only
|
||||
/// after the owning candidate/input publishes its immutable projection.
|
||||
/// 建立托管窗口、desktop 与页面容器;原生窗口通过命令发布后出现。
|
||||
/// 建立托管窗口、desktop 与页面容器;桥接强制生成该窗口的首帧,GUI 根据成功发布的窗口投影创建 OS 资源。
|
||||
/// Action 没有 Create 变体;这里返回的三元组由 ui_bridge::create_window 用于建立独立 Presentation。
|
||||
pub fn create(
|
||||
cx: &mut NativeContext<'_>,
|
||||
master: ObjectRef,
|
||||
@@ -609,6 +615,7 @@ pub fn close(cx: &mut NativeContext<'_>, window: ObjectRef) -> Result<(), VmErro
|
||||
return Ok(());
|
||||
}
|
||||
// 真实关闭边界先取消窗口与所有页面 owner 的任务,再撤销页面登记,防止晚到结果继续更新已关闭资源。
|
||||
// cancel_owner 只取消传入 owner 的作用域;具体 Mount 的任务随后在桥接刷新卸载出现时清理,不在此遍历 Mount 表。
|
||||
crate::tasks::cancel_owner(cx, window)?;
|
||||
// 遍历旧页顺序副本,unregister_page 可以安全更新真实集合;每页 owner 任务先取消。
|
||||
for page in data.pages.clone() {
|
||||
@@ -628,6 +635,7 @@ pub fn close(cx: &mut NativeContext<'_>, window: ObjectRef) -> Result<(), VmErro
|
||||
|
||||
/// Host teardown for a stopped VM: no binding, dispatch or source execution.
|
||||
/// 撤销已失效窗口的托管资源关系,不重新执行源关闭请求。
|
||||
/// UiBridge::shutdown/retire_window 先处理任务或 Mount,再调用这里断 Page 拥有边;不等同于源 close 的排队关闭流程。
|
||||
pub fn retire(vm: &mut Vm, window: ObjectRef) -> Result<(), VmError> {
|
||||
// 已停止域的宿主路径只解除托管页面拥有边并标记 closed,任务/OS 清理由外层退役流程负责。
|
||||
let mut data = vm.payload::<ManagedWindow>(window, "Window")?.clone();
|
||||
|
||||
Reference in New Issue
Block a user