Files
qbz/crates/qbz-ui/ui/shell/KioskShell.slint
T
vicrodh f1eeaf9126 feat(steam-deck): game mode support (plan PR1-PR5)
- PR1: gamescope detection at boot — X11 backend, scale 1, kiosk
  fullscreen; tray + miniplayer suppressed (click-offset fix).
- PR2: full keyboard navigation for the kiosk (3 zones, focus ring,
  scroll-into-view; typing never navigates).
- PR3: native gamepad via gilrs — D-pad/stick/A/B to synthetic Slint
  keys with hysteresis, repeat and debounce; B suppresses Escape while
  a text field is focused (closes the Steam OSK).
- PR4: Steam OSK via the steam://open/keyboard deeplink on text focus.
- PR5: scripts/qbz-add-to-steam (stdlib-only, 19/19 unit tests) with
  artwork assets + pure-gamepad controller layout.

Spec: qbz-nix-docs/steam-deck/STEAM_DECK_GAME_MODE_PLAN.md

km
2026-07-25 12:04:58 -06:00

749 lines
35 KiB
Plaintext

// KioskShell — small-panel touch shell (2.0.2 frente #3, Axis B).
//
// A SIBLING of AppShell inside the same AppWindow, mounted when
// `AppScreen.kiosk` is active. It shares every `*State` global verbatim with the
// desktop shell (no mirroring), so it re-hosts the SAME view components; the
// only differences from AppShell are the chrome: a thin back bar + bottom
// NavRail replace the HeaderBar + Sidebar, the transport is forced to
// PlayerBarSmall, and there is no queue/lyrics side panel.
//
// The content-mount block below is a VERBATIM copy of AppShell's (every
// ContentView route + the offline placeholder), so navigation reaches the same
// views by construction. Keeping it in sync with AppShell is temporary debt: a
// shared `ShellContent` extraction is the DRY follow-up, deferred because the
// content-height arithmetic references `root.height` (= the shell/window height)
// and extracting it into a sub-component needs that height re-threaded — a
// change worth doing only once the kiosk shell is build-verified. Kept isolated
// here so the desktop shell is untouched and cannot regress.
import { LineEdit } from "std-widgets.slint";
import { Theme } from "../foundation/semantic-colors.slint";
import { Layout } from "../foundation/layout.slint";
import { Radius } from "../foundation/radius.slint";
import { NavState, ContentView, OfflineState, PlaylistState, PurchaseDetailState, SearchActions, UiFocusState, AppearanceState, ImmersiveState, NowPlayingState, KioskNavState } from "../state.slint";
import { ImmersiveView } from "../immersive/ImmersiveView.slint";
import { PlayerBarSmall } from "PlayerBarSmall.slint";
import { NavRail } from "NavRail.slint";
import { WindowControls } from "WindowControls.slint";
import { KioskDiscover } from "KioskDiscover.slint";
import { DiscoverBrowseView } from "../discover/DiscoverBrowseView.slint";
import { RecentAlbumsView } from "../discover/RecentAlbumsView.slint";
import { KioskAlbum } from "KioskAlbum.slint";
import { LocalAlbumView } from "../album/LocalAlbumView.slint";
import { KioskArtist } from "KioskArtist.slint";
import { KioskNowPlaying } from "KioskNowPlaying.slint";
import { ArtistReleasesView } from "../artist/ArtistReleasesView.slint";
import { MusicianPageView } from "../musician/MusicianPageView.slint";
import { LabelReleasesView } from "../label/LabelReleasesView.slint";
import { LabelPageView } from "../label/LabelPageView.slint";
import { AwardView } from "../award/AwardView.slint";
import { AwardAlbumsView } from "../award/AwardAlbumsView.slint";
import { PurchasesView } from "../purchases/PurchasesView.slint";
import { PurchaseDetailView } from "../purchases/PurchaseDetailView.slint";
import { ArtistsByLocationView } from "../location/ArtistsByLocationView.slint";
import { KioskLibrary } from "KioskLibrary.slint";
import { FavoritesOfflineRail } from "../favorites/FavoritesOfflineRail.slint";
import { MixView } from "../mix/MixView.slint";
import { PlaylistView } from "../playlist/PlaylistView.slint";
import { PlaylistManagerView } from "../playlist/PlaylistManagerView.slint";
import { KioskMyQBZ } from "KioskMyQBZ.slint";
import { MixtapeDetailView } from "../myqbz/MixtapeDetailView.slint";
import { DiscographyBuilderView } from "../myqbz/DiscographyBuilderView.slint";
import { OfflineManagerView } from "../offline/OfflineManagerView.slint";
import { BlacklistManagerView } from "../settings/BlacklistManagerView.slint";
import { OfflinePlaceholder } from "../offline/OfflinePlaceholder.slint";
import { KioskLocalLibrary } from "KioskLocalLibrary.slint";
import { SettingsView } from "../settings/SettingsView.slint";
import { KioskSearch } from "KioskSearch.slint";
export component KioskShell inherits Rectangle {
// Public interface mirrors AppShell 1:1 (app.slint forwards these to the
// AppWindow root callbacks handled in Rust).
callback open-album(string);
callback open-artist(string);
callback open-purchase-album(string);
callback media-action(string, string, string);
callback header-menu-navigate(string);
callback discover-view-all(string, string);
callback settings-bool(string, bool);
callback settings-select(string, int);
callback settings-slider(string, int);
callback settings-string(string, string);
callback settings-reset();
callback settings-release-device();
callback logout();
callback close-app();
callback recovery-login();
// Keyboard/gamepad nav (PR 2): emitted by the root FocusScope on Enter.
// The internal dispatch runs through nav-activate() below; this public
// seam exists so an outer layer (or a future gamepad driver) can observe
// or trigger the same "activate the focused item" request.
callback activate-focused();
// ---- Kiosk keyboard navigation (Steam Deck Game Mode plan, PR 2) ----
// One root FocusScope drives the whole kiosk: arrows move a focus ring
// through three zones — rail (bottom NavRail) → content (the mounted
// view's items) → player (the transport bar) — Enter activates the
// focused item, Esc goes back. The zone model lives in KioskNavState
// (state.slint); the mounted content view publishes its geometry there
// (tabs / columns / count / shelves) and mirrors `index` onto its focus
// rings. Pure Slint: PR 3's gamepad feeds this same path by injecting
// synthetic key events, so nothing here is keyboard-specific.
//
// Zone cycle (Down): rail → content → player → rail; Up reverses. The
// content index space is `tabs` leading tab-strip entries followed by
// the item rows (a `columns`-wide grid; columns == 1 = list/shelves).
function nav-left() {
KioskNavState.nav-active = true;
KioskNavState.dir = 0;
if (KioskNavState.zone == "rail") {
KioskNavState.index = Math.max(0, KioskNavState.index - 1);
} else if (KioskNavState.zone == "content") {
if (KioskNavState.index < KioskNavState.tabs) {
KioskNavState.index = Math.max(0, KioskNavState.index - 1);
} else if (KioskNavState.shelves) {
KioskNavState.hmove = -1;
} else if (Math.mod(KioskNavState.index - KioskNavState.tabs, KioskNavState.columns) > 0) {
KioskNavState.index = KioskNavState.index - 1;
}
}
}
function nav-right() {
KioskNavState.nav-active = true;
KioskNavState.dir = 0;
if (KioskNavState.zone == "rail") {
KioskNavState.index = Math.min(rail.tile-count - 1, KioskNavState.index + 1);
} else if (KioskNavState.zone == "content") {
if (KioskNavState.index < KioskNavState.tabs) {
KioskNavState.index = Math.min(KioskNavState.tabs - 1, KioskNavState.index + 1);
} else if (KioskNavState.shelves) {
KioskNavState.hmove = 1;
} else if (Math.mod(KioskNavState.index - KioskNavState.tabs, KioskNavState.columns) < KioskNavState.columns - 1
&& KioskNavState.index + 1 < KioskNavState.count) {
KioskNavState.index = KioskNavState.index + 1;
}
}
}
function nav-up() {
KioskNavState.nav-active = true;
KioskNavState.dir = -1;
if (KioskNavState.zone == "content") {
if (KioskNavState.index >= KioskNavState.tabs + KioskNavState.columns) {
KioskNavState.index = KioskNavState.index - KioskNavState.columns;
} else if (KioskNavState.index >= KioskNavState.tabs) {
// Grid row 0 → the tab strip above it (column → tab).
KioskNavState.index = Math.min(KioskNavState.tabs - 1, KioskNavState.index - KioskNavState.tabs);
} else {
// Tab strip (top of the cycle) → wrap down to the rail.
KioskNavState.zone = "rail";
KioskNavState.index = 0;
}
} else if (KioskNavState.zone == "rail") {
KioskNavState.zone = "player";
KioskNavState.index = 0;
} else {
KioskNavState.zone = "content";
KioskNavState.index = 0;
}
}
function nav-down() {
KioskNavState.nav-active = true;
KioskNavState.dir = 1;
if (KioskNavState.zone == "content") {
if (KioskNavState.index < KioskNavState.tabs) {
// Tab strip → the first item row (or the player bar when the
// view carries no items).
if (KioskNavState.count > KioskNavState.tabs) {
KioskNavState.index = KioskNavState.tabs;
} else {
KioskNavState.zone = "player";
KioskNavState.index = 0;
}
} else if (KioskNavState.index + KioskNavState.columns < KioskNavState.count) {
KioskNavState.index = KioskNavState.index + KioskNavState.columns;
} else {
KioskNavState.zone = "player";
KioskNavState.index = 0;
}
} else if (KioskNavState.zone == "player") {
KioskNavState.zone = "rail";
KioskNavState.index = 0;
} else {
KioskNavState.zone = "content";
KioskNavState.index = 0;
}
}
function nav-activate() {
KioskNavState.nav-active = true;
if (KioskNavState.zone == "player") {
// The transport is ONE focusable unit: Enter = play/pause.
if (NowPlayingState.has-track) {
NowPlayingState.toggle-play();
}
} else if (KioskNavState.zone == "rail") {
rail.activate-index(KioskNavState.index);
} else {
// Content views own their activation. They are conditionally
// mounted (can't be addressed from here), so the request goes
// out as a pulse the mounted view answers via a changed probe.
KioskNavState.activate-seq = KioskNavState.activate-seq + 1;
}
}
// Reset the nav model on every view switch: focus lands on the new
// view's content, parked at the first item.
property <ContentView> nav-view-probe: NavState.view;
changed nav-view-probe => {
KioskNavState.zone = "content";
KioskNavState.index = 0;
KioskNavState.dir = 0;
KioskNavState.hmove = 0;
}
// Kiosk chrome heights. The back bar + transport are one header-row tall
// each; the NavRail is a fat touch target.
property <length> navrail-height: 80px;
// Offline gate (verbatim from AppShell:110-130): Qobuz-only views mount only
// online; local-DB views (LocalLibrary, local album, offline manager, My QBZ,
// Settings) keep mounting offline.
property <bool> qobuz-view-blocked: OfflineState.offline && (
NavState.view == ContentView.home
|| NavState.view == ContentView.discover-browse
|| NavState.view == ContentView.search
|| NavState.view == ContentView.favorites
|| NavState.view == ContentView.album
|| NavState.view == ContentView.artist
|| NavState.view == ContentView.artist-releases
|| NavState.view == ContentView.musician
|| NavState.view == ContentView.label
|| NavState.view == ContentView.label-releases
|| NavState.view == ContentView.award
|| NavState.view == ContentView.award-albums
|| NavState.view == ContentView.purchases
|| NavState.view == ContentView.purchase-album
|| NavState.view == ContentView.location
|| NavState.view == ContentView.mix
|| (NavState.view == ContentView.playlist
&& !PlaylistState.is-local && !PlaylistState.offline-subset));
VerticalLayout {
spacing: 0px;
// --- Back bar: persistent global back (workstream B, wired to NavState
// history, ADR-004) + the kiosk search entry. The desktop search box
// lives in the HeaderBar, which the kiosk drops, so a persistent search
// field here is what makes Search functional; Enter submits through the
// same SearchActions seam the header uses and lands on the results view.
backbar := Rectangle {
height: Layout.header-height;
background: Theme.surface-card;
// The kiosk carries no HeaderBar, so it owns the window chrome too.
// macOS overlay leaves the native traffic-light inset; Linux frameless
// draws the custom WindowControls. OS-agnostic on purpose (the kiosk
// is not restricted to any platform).
property <length> mac-inset: AppearanceState.is-macos && !AppearanceState.system-title-bar-active ? 78px : 0px;
property <bool> lin-chrome: !AppearanceState.is-macos && !AppearanceState.system-title-bar-active && AppearanceState.show-window-controls;
HorizontalLayout {
padding-left: 6px + backbar.mac-inset;
padding-right: backbar.lin-chrome ? 118px : 8px;
padding-top: 4px;
padding-bottom: 4px;
spacing: 6px;
back-btn := Rectangle {
width: 44px;
border-radius: Radius.sm;
background: back-ta.has-hover && NavState.can-back ? Theme.alpha-8 : transparent;
opacity: NavState.can-back ? 1.0 : 0.32;
Image {
source: @image-url("../assets/icons/chevron-left.svg");
colorize: Theme.text-secondary;
width: 22px;
height: 22px;
}
back-ta := TouchArea {
enabled: NavState.can-back;
clicked => {
NavState.request-back();
}
}
}
fwd-btn := Rectangle {
width: 44px;
border-radius: Radius.sm;
background: fwd-ta.has-hover && NavState.can-forward ? Theme.alpha-8 : transparent;
opacity: NavState.can-forward ? 1.0 : 0.32;
Image {
source: @image-url("../assets/icons/chevron-right.svg");
colorize: Theme.text-secondary;
width: 22px;
height: 22px;
}
fwd-ta := TouchArea {
enabled: NavState.can-forward;
clicked => {
NavState.request-forward();
}
}
}
search-field := LineEdit {
horizontal-stretch: 1;
placeholder-text: @tr("Search");
// Suppress the global single-key hotkeys while typing (the
// desktop search box drives the same guard); without this,
// letters fire hotkeys instead of reaching the field.
// Probe property because a use-site `changed has-focus` on a
// std-widgets input never fires (has-focus is an alias into
// the inner TextInput) — #619.
property <bool> guard-focused: self.has-focus;
changed guard-focused => {
UiFocusState.text-input-focused = self.guard-focused;
}
accepted(text) => {
SearchActions.submit(text);
NavState.view = ContentView.search;
// Release focus so Slint sends text-input DISABLE → the OS
// on-screen keyboard (squeekboard) closes. Otherwise the
// search field keeps focus forever and the OSK never hides.
search-field.clear-focus();
// Hand keyboard focus back to the nav scope so arrows
// keep working after a search (PR 2).
keys.focus();
}
}
}
// Linux custom window controls at the right edge.
if backbar.lin-chrome: WindowControls {
x: backbar.width - self.preferred-width - 8px;
y: (backbar.height - self.preferred-height) / 2;
}
}
// --- Content frame (mirrors AppShell:237-279 arithmetic-height pattern).
// A conditionally-mounted view will not stretch to fill a layout cell, so
// the inner Rectangle takes an EXPLICIT height and the views fill it via
// clip — this is the documented layout-collapse footgun. --------------
Rectangle {
vertical-stretch: 1;
background: Theme.surface-card;
// Tap anywhere in the content area to dismiss the OS on-screen
// keyboard: release the search field's focus → Slint sends the
// text-input DISABLE → squeekboard closes. Declared FIRST so it sits
// BEHIND the views (which handle their own taps); it only catches
// empty-area taps.
dismiss-osk-ta := TouchArea {
clicked => {
search-field.clear-focus();
// Same hand-back as the accepted path (PR 2).
keys.focus();
}
}
VerticalLayout {
vertical-stretch: 1;
padding-left: 8px;
padding-right: 8px;
padding-top: 0px;
padding-bottom: 8px;
Rectangle {
// window - back bar - transport(PlayerBarSmall = one header
// row) - NavRail - this VL's bottom padding. The transport
// row is HIDDEN on Now Playing (redundant there), so DON'T
// subtract it then — otherwise the content stays short and the
// NavRail rides up, leaving dead space below the footer.
height: root.height - Layout.header-height
- (NavState.view == ContentView.now-playing ? 0px : Layout.header-height)
- root.navrail-height - 8px;
vertical-stretch: 1;
background: Theme.surface-main;
border-radius: Radius.md;
clip: true;
// --- Verbatim copy of AppShell's view mounts (286-526). ---
if root.qobuz-view-blocked && NavState.view != ContentView.favorites: OfflinePlaceholder { }
if root.qobuz-view-blocked && NavState.view == ContentView.favorites: OfflinePlaceholder {
FavoritesOfflineRail { }
}
if NavState.view == ContentView.home && !OfflineState.offline: KioskDiscover {
album-clicked(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
discover-view-all(e, t) => {
root.discover-view-all(e, t);
}
}
if NavState.view == ContentView.discover-browse && !OfflineState.offline: DiscoverBrowseView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.recent-albums: RecentAlbumsView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.album && !OfflineState.offline: KioskAlbum {
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.local-album: LocalAlbumView {
open-artist(name) => {
root.open-artist(name);
}
}
if NavState.view == ContentView.artist && !OfflineState.offline: KioskArtist {
open-album(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.artist-releases && !OfflineState.offline: ArtistReleasesView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.musician && !OfflineState.offline: MusicianPageView {
open-album(id) => {
root.open-album(id);
}
}
if NavState.view == ContentView.label && !OfflineState.offline: LabelPageView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.label-releases && !OfflineState.offline: LabelReleasesView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.award && !OfflineState.offline: AwardView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.award-albums && !OfflineState.offline: AwardAlbumsView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.location && !OfflineState.offline: ArtistsByLocationView {
open-artist(id) => {
root.open-artist(id);
}
}
if NavState.view == ContentView.favorites && !OfflineState.offline: KioskLibrary {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
}
if NavState.view == ContentView.purchases && !OfflineState.offline: PurchasesView {
open-album(id) => {
root.open-purchase-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.purchase-album
&& !OfflineState.offline
&& PurchaseDetailState.album-id != "": PurchaseDetailView { }
if NavState.view == ContentView.playlist-manager: PlaylistManagerView { }
if NavState.view == ContentView.mixtapes: KioskMyQBZ {
navigate(r) => {
root.header-menu-navigate(r);
}
}
if NavState.view == ContentView.collections: KioskMyQBZ {
navigate(r) => {
root.header-menu-navigate(r);
}
}
if NavState.view == ContentView.mixtape-detail: MixtapeDetailView { }
if NavState.view == ContentView.discography-builder: DiscographyBuilderView { }
if NavState.view == ContentView.offline-manager: OfflineManagerView { }
if NavState.view == ContentView.blacklist-manager: BlacklistManagerView { }
if NavState.view == ContentView.local-library: KioskLocalLibrary { }
if NavState.view == ContentView.mix && !OfflineState.offline: MixView {
play-track(id) => {
root.media-action("track", id, "play");
}
play-all => {
root.media-action("mix", "", "play-all");
}
shuffle => {
root.media-action("mix", "", "shuffle");
}
refresh => {
root.media-action("mix", "", "refresh");
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.playlist
&& (!OfflineState.offline
|| PlaylistState.is-local
|| PlaylistState.offline-subset): PlaylistView {
play-track(id) => {
root.media-action("track", id, "play");
}
play-all => {
root.media-action("playlist", "", "play-all");
}
shuffle => {
root.media-action("playlist", "", "shuffle");
}
toggle-favorite => {
root.media-action("playlist", "", "favorite");
}
edit => {
root.media-action("playlist", "", "edit");
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.settings: SettingsView {
settings-bool(k, v) => {
root.settings-bool(k, v);
}
settings-select(k, i) => {
root.settings-select(k, i);
}
settings-slider(k, v) => {
root.settings-slider(k, v);
}
settings-string(k, s) => {
root.settings-string(k, s);
}
settings-reset => {
root.settings-reset();
}
settings-release-device => {
root.settings-release-device();
}
}
if NavState.view == ContentView.search && !OfflineState.offline: KioskSearch {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.now-playing: KioskNowPlaying {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
}
// --- Persistent transport: force PlayerBarSmall (npb=2 seam). Reused
// verbatim; it self-heights to one header row and reads its own globals.
// Hidden on the Now Playing view — that view already carries the full
// transport, so the bar would be redundant there.
if NavState.view != ContentView.now-playing: PlayerBarSmall {
height: Layout.header-height;
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
settings-bool(k, v) => {
root.settings-bool(k, v);
}
}
// --- Bottom NavRail (net-new). Each tile maps to the real route the
// Sidebar/Rust dispatcher already uses. ------------------------------
rail := NavRail {
height: root.navrail-height;
discover => {
root.header-menu-navigate("discover-home");
}
library => {
root.header-menu-navigate("favorites-tracks");
}
local-library => {
root.header-menu-navigate("local-albums");
}
myqbz => {
root.header-menu-navigate("myqbz-mixtapes");
}
playing => {
NavState.view = ContentView.now-playing;
}
visualizer => {
root.media-action("npb-view", "", "immersive");
}
menu => {
NavState.request-settings();
}
}
}
// --- Player-zone focus ring (PR 2). The transport bar is ONE focusable
// unit (Enter toggles play/pause, handled in nav-activate). Drawn as an
// overlay on the bar's exact slot (above the NavRail); the Now Playing
// view hides PlayerBarSmall and draws its own ring on its in-page
// transport row instead.
if NavState.view != ContentView.now-playing
&& KioskNavState.nav-active
&& KioskNavState.zone == "player": Rectangle {
x: 0;
y: root.height - root.navrail-height - Layout.header-height;
width: root.width;
height: Layout.header-height;
border-width: 3px;
border-color: Theme.accent;
border-radius: Radius.sm;
background: Theme.accent.with-alpha(0.08);
}
// --- Root nav FocusScope (PR 2). Holds keyboard focus for the whole
// kiosk; TouchAreas never take focus, so it survives card/tile taps and
// only yields to the search LineEdit (which then sets
// UiFocusState.text-input-focused and every key is rejected here — typing
// must never navigate). Rejected keys keep their normal path.
keys := FocusScope {
key-pressed(event) => {
if (UiFocusState.text-input-focused) {
return reject;
}
// The immersive visualizer overlay owns its own keys while open.
if (ImmersiveState.open) {
return reject;
}
if (event.text == Key.LeftArrow) {
root.nav-left();
return accept;
}
if (event.text == Key.RightArrow) {
root.nav-right();
return accept;
}
if (event.text == Key.UpArrow) {
root.nav-up();
return accept;
}
if (event.text == Key.DownArrow) {
root.nav-down();
return accept;
}
if (event.text == Key.Return) {
root.activate-focused();
root.nav-activate();
return accept;
}
if (event.text == Key.Escape) {
if (NavState.can-back) {
NavState.request-back();
return accept;
}
return reject;
}
return reject;
}
}
// Deferred mount focus — synchronous focus during the initial layout
// races it; a one-shot timer grabs it a tick later (the desktop modal
// idiom, e.g. KeyboardShortcutsModal).
focus-timer := Timer {
interval: 30ms;
running: true;
triggered => {
self.running = false;
keys.focus();
}
}
// Immersive / visualizer overlay — the same app-level view the desktop
// mounts, but the desktop hangs it inside AppShell, so the kiosk shell must
// mount its own copy. Reached from the NavRail visualizer tile (which fires
// the "npb-view"/"immersive" action). Rendered last = on top of everything.
if ImmersiveState.open: ImmersiveView {
width: 100%;
height: 100%;
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}