push method
Push surface as the new top.
If a surface with the same ShortcutSurface.id already exists it is moved to the top (bring-to-front). Prefer replace to update config without reordering, or activate to only reorder.
Resets pending state on the previous top (surface switch cancels chords).
Implementation
void push(ShortcutSurface surface) {
final prevTop = top;
if (prevTop != null && prevTop.id != surface.id) {
prevTop.reset();
}
final existing = _indexOf(surface.id);
if (existing >= 0) {
_stack[existing].reset();
_stack[existing].interceptor?.onStop();
_stack[existing].attachSend(null);
_stack.removeAt(existing);
}
_stack.add(surface);
surface.attachSend(_send);
final send = _send;
if (send != null) {
surface.interceptor?.onStart(send);
}
_notifyStack();
onPendingChanged?.call();
}