Merge commit '5ae19f3035' into red/t3c

This commit is contained in:
aiongg
2026-11-16 22:56:53 +00:00
6 changed files with 23 additions and 10 deletions
+3
View File
@@ -72,6 +72,9 @@ pub(crate) struct FocusedRecord {
pub(crate) claims: Vec<craft_keymap::Chord>,
/// The component of the focused stop: only its state-dependent claims hold.
pub(crate) focused: Option<Id>,
/// The arena root of the focused stop when the stop is a non-text member of an arena (a part of a canvas's frame
/// overlay): the root's state-dependent claims hold too, so a canvas tool's keys work with a part focused.
pub(crate) root: Option<Id>,
/// The focused stop switches pages with Ctrl+Tab.
pub(crate) pages: bool,
pub(crate) menu_bar: bool,
@@ -678,6 +678,7 @@ pub(super) fn end(state: &mut State, focused: Option<Id>, on_app_widget: bool, f
state.record = super::FocusedRecord {
claims: keys.map(|keys| keys.claims.to_vec()).unwrap_or_default(),
focused: stop.as_ref().map(|stop| stop.id),
root: stop.as_ref().filter(|stop| stop.root != stop.id && !stop.text).map(|stop| stop.root),
pages: stop.as_ref().is_some_and(|stop| stop.role.pages),
keys,
menu_bar: std::mem::take(&mut state.menu_bar),
+3 -3
View File
@@ -37,11 +37,11 @@ pub(crate) use intents::lent_taken;
#[doc(hidden)]
pub use intents::settle;
#[doc(hidden)]
pub use intents::take_cancel;
#[doc(hidden)]
pub use intents::take_submit;
pub use intents::with_window_intents;
pub(crate) use intents::{
Lent, context_part, context_request, give_back, lend, request_context, route_whole_reset, scope_escape, take_cancel, take_window_cancel,
};
pub(crate) use intents::{Lent, context_part, context_request, give_back, lend, request_context, route_whole_reset, scope_escape, take_window_cancel};
pub(crate) use nodes::{redirect_node, register_expanded, register_node};
pub use route::focus_holds;
pub(crate) use route::{activated_member, begin, layout_of, owner_at, pasted_text, queue_edit, take_shortcuts};
+1 -1
View File
@@ -344,7 +344,7 @@ enum PressUse {
/// bare End where it declares `EndKey::EndMode`.
pub(super) fn focused_claims(record: &focus::FocusedRecord, stage: &Stage) -> Vec<Chord> {
let mut claims = record.claims.clone();
claims.extend(stage.claims.iter().filter(|(owner, _)| Some(*owner) == record.focused).map(|(_, chord)| *chord));
claims.extend(stage.claims.iter().filter(|(owner, _)| Some(*owner) == record.focused || Some(*owner) == record.root).map(|(_, chord)| *chord));
// A bare End belongs to a stop that declares `EndKey::EndMode`: it reads the key as a claimed chord and toggles its
// mode, so no collection navigation or scroll owner takes it as a move to the end.
if record.keys.is_some_and(|keys| keys.end == EndKey::EndMode) {
@@ -437,8 +437,11 @@ pub fn take_submit(ctx: &Context) -> bool {
take_untaken(ctx, &Intent::Submit)
}
/// Takes an untaken `Cancel` (Escape) for the focused stop, without deciding what the scope does with it.
pub(crate) fn take_cancel(ctx: &Context) -> bool {
/// Takes an untaken `Cancel` (Escape) for the focused stop, without deciding what the scope does with it. An app
/// that opens a modal layer in the pass an Escape arrives in takes it with this, so the focused component (a frame
/// part of a canvas, say) does not act on it beneath the layer.
#[doc(hidden)]
pub fn take_cancel(ctx: &Context) -> bool {
take_untaken(ctx, &Intent::Cancel)
}
+10 -4
View File
@@ -22,15 +22,15 @@ use std::sync::Arc;
pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting {
let os = crate::runtime::windows::os_of(ctx);
let target = focus::focused_rec(ctx);
let (batch, nodes, captures) = current(ctx, |stage| {
let (batch, nodes, captures, held_claims) = current(ctx, |stage| {
stage.routed.clear();
stage.contexts.clear();
stage.claimed.clear();
stage.activated.clear();
stage.claims.clear();
let held_claims = std::mem::take(&mut stage.claims);
stage.last_open_edits = std::mem::take(&mut stage.open_edits);
stage.last_nodes = std::mem::take(&mut stage.nodes);
(std::mem::take(&mut stage.batch), stage.last_nodes.clone(), std::mem::take(&mut stage.captures))
(std::mem::take(&mut stage.batch), stage.last_nodes.clone(), std::mem::take(&mut stage.captures), held_claims)
});
let modal = overlay::any_open(ctx, overlay::OpenFilter::Modal);
let stale_repeat = |stale: &mut bool, press: &Press| {
@@ -96,6 +96,7 @@ pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting {
}
}
let focused = target.as_ref().map(|rec| rec.stop.id);
let root = target.as_ref().filter(|rec| rec.stop.root != rec.stop.id && !rec.stop.text).map(|rec| rec.stop.root);
// The web sends a chord's key press and its clipboard event: the command reaches the component once.
let mut clips = batch.clips.clone();
clips.dedup();
@@ -125,7 +126,12 @@ pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting {
for chord in &batch.claimed {
match driven.and_then(|driven| driven.intent_of(chord)) {
Some(intent) => push(&mut routed, driven.map(|driven| driven.list), intent, false),
None => claimed.extend(captures.iter().find(|(_, held)| held == chord).map(|(owner, _)| *owner).or(focused).map(|id| (id, *chord))),
None => {
// A capture's owner, else the claim's: the focused component's own, then its arena root's.
let held = |owner: Option<Id>| held_claims.iter().find(|(id, held)| Some(*id) == owner && held == chord).map(|(id, _)| *id);
let owner = captures.iter().find(|(_, held)| held == chord).map(|(owner, _)| *owner);
claimed.extend(owner.or_else(|| held(focused)).or_else(|| held(root)).or(focused).map(|id| (id, *chord)));
}
}
}
for request in &batch.access {