JFLib

plat/web_system.rs#

Source: lib/plat/web_system.rs

web_system -- what the browser / Android host says about the system: the user's settings
(settings.rs), the permission for notifications and whether the screen can be kept on
(web_notify.rs, web_power.rs), the answers of the notifications

  jfgui_system(len) -> count   the inbox: "key=value" lines -> how many keys were taken; a
                               key that is missing keeps its value.  The host sends all of
                               them before jfgui_start and the changed ones after every
                               change; once the app runs, a change of what sys_settings()
                               answers is E_SETTINGS with its SET_* bits (dark, accent:
                               SET_THEME; contrast, forced, colors: SET_CONTRAST; scale:
                               SET_FONTS; motion: SET_OTHER).  Keys:
    dark=1|0|-        a dark / light scheme, "-" no preference (prefers-color-scheme;
                      Android: Configuration.uiMode, UI_MODE_NIGHT_YES)
    contrast=1|0      more contrast (prefers-contrast: more; Android: high-contrast text, the
                      contrast level of API 34 at "high")
    forced=1|0        the browser's forced colours (forced-colors: active, Windows' contrast
                      themes in the browser): high contrast with the colours of `colors`
    colors=RRGGBB,..  eight system colours of the forced scheme: Canvas, CanvasText,
                      Highlight, HighlightText, ButtonFace, ButtonText, GrayText, LinkText
                      (HcColors in that order); empty: none
    motion=1|0        fewer animations (prefers-reduced-motion: reduce; Android:
                      Settings.Global.ANIMATOR_DURATION_SCALE 0)
    scale=PERCENT     the text size (the browser's default font size against 16 px;
                      Android: Configuration.fontScale)
    accent=RRGGBB|-   the system's accent colour (Android 12+: the dynamic colours,
                      system_accent1_600); "-" none
    notify=granted|default|denied|unsupported   (browser) the Notification permission:
                      default = asked at the first notification (from the user's gesture)
    wakelock=1|0      (browser) navigator.wakeLock exists (Screen Wake Lock)
  jfgui_note(id, clicked) -> 1   a notification of tray::notify was clicked (1; the host
                               brought the tab / the activity to the front) or went away
                               unclicked (0: closed, swiped away, refused) -> TrayEvent
  sys_settings_host(&mut s)    (settings.rs) the host's values; the jfgui_* overrides follow
  dark() -> Option<bool>       (web.rs theme())
  notify_state() / wakelock()  (web_notify.rs, web_power.rs)
  back_trap(on)                (Android) the back key is Esc for the app while on (lib.rs)
  jfgui_touch_reached() -> 0|1  (Android, iOS) the last finger's gesture reached a widget (a tap, a
                               drag), not only a scroll: the keyboard may follow it

The lifecycle needs no export of its own: the host sends E_POWER through jfgui_event (data 2:
the tab was hidden / Android's onStop, 3: visible / started again) and the runtime turns it
into UIC_SUSPEND.
  • extern "C" fn jfgui_system(len: u32) -> u32 The host's system settings and states (inbox: "key=value" lines, see the module header) -> the keys taken. A change once the app runs is E_SETTINGS.

  • extern "C" fn jfgui_note(id: u32, clicked: u32) -> u32 A notification of tray::notify was clicked (clicked 1) or went away without a click (0) -> 1 taken (0: the app has not started).

  • extern "C" fn jfgui_touch_reached() -> u32 (Android, iOS) the last finger's gesture reached a widget -> 1

Source: docs/API.md in the JFLib repository.