mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-28 09:19:51 +01:00
accesskit_consumer's Node::controls() unwraps every id in the relation, so an update whose controls names a node it does not carry aborts the app once the host's UIA adapter applies it. In PhotoCraft on Windows, clicking Image, Edit or Layer in the menu bar did exactly that (photocraft#15597), and on one machine Filter too — an ordering difference per menu. emit.rs adds every open popup's id, and a menu reports its popup open on a frame where the popup's own node is not emitted. The runtime plugin now prunes the finished update in output_hook, keeping a controls id only when the same update carries its node. Other relations are untouched: they are built from nodes the pass wrote. The tests fail without the change: the relation keeps an id with no node.
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
//! The plugin impl, its registration and hook order, and the plugin lock.
|
|
|
|
use crate::runtime::frame;
|
|
use egui::{Context, FullOutput, Plugin, RawInput, Ui};
|
|
|
|
/// The runtime's plugin. egui holds a plugin's mutex while it calls a hook, so the struct holds no state:
|
|
/// every record lives in context data behind its own lock.
|
|
struct RuntimePlugin;
|
|
|
|
impl Plugin for RuntimePlugin {
|
|
fn debug_name(&self) -> &'static str {
|
|
"craft_ui.runtime"
|
|
}
|
|
|
|
fn input_hook(&mut self, ctx: &Context, input: &mut RawInput) {
|
|
crate::runtime::egui::input_filter::input_hook(ctx, input);
|
|
frame::input_hook(ctx, input);
|
|
}
|
|
|
|
fn output_hook(&mut self, ctx: &Context, output: &mut FullOutput) {
|
|
let _ = ctx;
|
|
crate::runtime::egui::access::drop_dangling_relations(output);
|
|
}
|
|
fn on_begin_pass(&mut self, ui: &mut Ui) {
|
|
frame::begin_pass(ui);
|
|
}
|
|
|
|
fn on_end_pass(&mut self, ui: &mut Ui) {
|
|
frame::end_pass(ui);
|
|
}
|
|
}
|
|
|
|
/// Whether the runtime plugin is on `ctx`.
|
|
pub(crate) fn is_registered(ctx: &Context) -> bool {
|
|
ctx.plugin_opt::<RuntimePlugin>().is_some()
|
|
}
|
|
|
|
/// Adds the runtime plugin to `ctx`.
|
|
pub(crate) fn register(ctx: &Context) {
|
|
ctx.add_plugin(RuntimePlugin);
|
|
}
|