fix(touch): give each tap to the layer that acts on it

On a coarse pointer the dispatcher can name a contact near the tap instead
of the exact pick. Only flights, military, vessels, radio and Street Level
act on such a contact, so they now register as expanded pick owners, and a
quake card or label yields only to them. A FIRMS fire or CCTV camera reached
only as a nearby contact no longer swallows a quake card, a quake label or
a vessel's own card tap, and FIRMS and CCTV cards yield to a contact whose
layer does act on it.

Radio and Street Level also pick through their own windows. A station or
Street Level item found only there, not as the touch contact, yields to
another layer's card painted over it, and Street Level takes its own touch
contact beyond its narrower window.

Fire, CCTV and vessel cards now act over a passive owner's pick (a flight
trail, the directions route), as the quake card does. The Context panel
leaves a passive route, or a fire or camera reached only as a nearby
contact, to the card painted over it.
This commit is contained in:
manjunath22466 committed 2026-11-17 13:18:32 +05:30
1 parent 4804097ca1
commit 830c980ca6
26 files changed
+1095 -69

No files matched your search

+23 -2
View File
@@ -24,7 +24,23 @@ export function createSelection({ state, parts }) {
function onClick(event) {
if (!state.viewer || !state.enabled) return;
const hit = event.windowHit(CLICK_PICK_WINDOW_PX, CLICK_PICK_WINDOW_PX);
const route = parts.router.resolve(pickIdOf(hit));
const windowId = pickIdOf(hit);
// A coarse tap's touch contact (event.hit) reaches farther than this
// window; a card or label over it yields to our item there, so it is ours.
const contact = event.hit;
const contactId =
contact && !contact.surface
? pickIdOf({ drawHit: contact.set ? contact : null, id: event.id })
: null;
let route = parts.router.resolve(windowId);
// Found only through our window, not as the contact (which is the exact
// hit whenever there is one): another layer's card or label painted here
// is that layer's click, since its handler never sees this window.
if (route && windowId !== contactId) {
const at = event.screenPosition;
if (state.services.overlayHit?.(at?.x, at?.y)) return;
}
if (!route && contactId) route = parts.router.resolve(contactId);
// Not ours: the ground handler decides whether it is the map itself.
if (!route) {
parts.openAtGround?.({ surface: hit.surface, ground: groundOf(event) });
@@ -71,7 +87,12 @@ export function createSelection({ state, parts }) {
if (state.clickSubscription) return;
state.clickSubscription = inputFor(viewer).onClick(onClick);
document.addEventListener('keydown', onKeyDown);
picking?.registerPickOwner?.(STREET_LEVEL_LAYER_ID, parts.router.ownsPick);
picking?.registerPickOwner?.(STREET_LEVEL_LAYER_ID, parts.router.ownsPick, {
expanded: true,
// The core's position marker is ours but selects nothing: a card over
// it keeps the tap.
passive: (id) => !parts.router.resolve(id)?.instance,
});
}
function uninstall() {