mirror of https://github.com/linebender/xilem
parent
15c0a5546c
commit
14f3dc2e3e
|
@ -53,11 +53,10 @@ fn run_targeted_update_pass(
|
||||||
|
|
||||||
fn run_single_update_pass(
|
fn run_single_update_pass(
|
||||||
root: &mut RenderRoot,
|
root: &mut RenderRoot,
|
||||||
target: Option<WidgetId>,
|
target: WidgetId,
|
||||||
mut pass_fn: impl FnMut(&mut dyn Widget, &mut UpdateCtx),
|
mut pass_fn: impl FnMut(&mut dyn Widget, &mut UpdateCtx),
|
||||||
) {
|
) {
|
||||||
if let Some(widget_id) = target {
|
let (widget_mut, state_mut) = root.widget_arena.get_pair_mut(target);
|
||||||
let (widget_mut, state_mut) = root.widget_arena.get_pair_mut(widget_id);
|
|
||||||
|
|
||||||
let mut ctx = UpdateCtx {
|
let mut ctx = UpdateCtx {
|
||||||
global_state: &mut root.global_state,
|
global_state: &mut root.global_state,
|
||||||
|
@ -66,9 +65,8 @@ fn run_single_update_pass(
|
||||||
widget_children: widget_mut.children,
|
widget_children: widget_mut.children,
|
||||||
};
|
};
|
||||||
pass_fn(widget_mut.item, &mut ctx);
|
pass_fn(widget_mut.item, &mut ctx);
|
||||||
}
|
|
||||||
|
|
||||||
let mut current_id = target;
|
let mut current_id = Some(target);
|
||||||
while let Some(widget_id) = current_id {
|
while let Some(widget_id) = current_id {
|
||||||
merge_state_up(&mut root.widget_arena, widget_id);
|
merge_state_up(&mut root.widget_arena, widget_id);
|
||||||
current_id = root.widget_arena.parent_of(widget_id);
|
current_id = root.widget_arena.parent_of(widget_id);
|
||||||
|
@ -471,16 +469,23 @@ pub(crate) fn run_update_focus_pass(root: &mut RenderRoot) {
|
||||||
|
|
||||||
// We send FocusChange event to widget that lost and the widget that gained focus.
|
// We send FocusChange event to widget that lost and the widget that gained focus.
|
||||||
// We also request accessibility, because build_access_node() depends on the focus state.
|
// We also request accessibility, because build_access_node() depends on the focus state.
|
||||||
|
if let Some(prev_focused) = prev_focused {
|
||||||
|
if root.widget_arena.has(prev_focused) {
|
||||||
run_single_update_pass(root, prev_focused, |widget, ctx| {
|
run_single_update_pass(root, prev_focused, |widget, ctx| {
|
||||||
widget.update(ctx, &Update::FocusChanged(false));
|
widget.update(ctx, &Update::FocusChanged(false));
|
||||||
ctx.widget_state.request_accessibility = true;
|
ctx.widget_state.request_accessibility = true;
|
||||||
ctx.widget_state.needs_accessibility = true;
|
ctx.widget_state.needs_accessibility = true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(next_focused) = next_focused {
|
||||||
|
// We know that this widget definitely exists because of the `is_still_interactive` check above.
|
||||||
run_single_update_pass(root, next_focused, |widget, ctx| {
|
run_single_update_pass(root, next_focused, |widget, ctx| {
|
||||||
widget.update(ctx, &Update::FocusChanged(true));
|
widget.update(ctx, &Update::FocusChanged(true));
|
||||||
ctx.widget_state.request_accessibility = true;
|
ctx.widget_state.request_accessibility = true;
|
||||||
ctx.widget_state.needs_accessibility = true;
|
ctx.widget_state.needs_accessibility = true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if prev_focused.is_some() && was_ime_active {
|
if prev_focused.is_some() && was_ime_active {
|
||||||
root.global_state.emit_signal(RenderRootSignal::EndIme);
|
root.global_state.emit_signal(RenderRootSignal::EndIme);
|
||||||
|
|
Loading…
Reference in New Issue