JFLib

plat/taskbar.rs#

Source: lib/plat/taskbar.rs

taskbar -- the app's button in the taskbar or dock: progress, a badge, the jump list's tasks

  taskbar_progress(TaskbarProgress) -> bool   None, Normal(f), Paused(f), Error(f) or
                                   Indeterminate (f: 0.0 ..= 1.0)
  taskbar_badge(count, icon) -> bool   count 0 = no badge; icon: the overlay Windows shows on
                                   the button (straight ARGB, 16 x 16 at 100 %; ui draws one
                                   with the number), Linux docks show the count themselves
  taskbar_tasks(&[JumpTask]) -> bool   the "Tasks" of the button's jump list (Windows): each
                                   starts this program with its arguments -- with
                                   AF_SINGLE_INSTANCE they reach the running app as
                                   UIC_OPEN; empty = the jump list removed.  Linux: false
  taskbar_state() -> (TaskbarProgress, u32)   what was set last (progress, count)
  taskbar_badge_shown(count) -> bool   that badge (with its icon) is up already (ui skips
                                   drawing it again)
  taskbar_supported() -> bool      whether this system shows any of it
  app_user_model_id() -> Option<id>   (Windows) the explicit AppUserModelID the process runs
                                   under: the taskbar button and its pins, the jump list, the
                                   recent files and the notifications all go by it.  ui::main!
                                   sets PACKAGE's app id once the setup installed the program
                                   or --register registered it (assoc::app_id_boot); None:
                                   Windows derives an id from the program's path
  set_app_user_model_id(id) -> bool   (Windows) run under id from now on: before the first
                                   window.  false elsewhere, in an MSIX package (the
                                   package's id counts) and for an id Windows refuses (more
                                   than 128 characters, blanks)

The calls keep the state and return whether the system took it (Windows: also before the
window has its button -- it is applied when the button appears).  Setting what is already
shown does nothing (progress compared in per mille), so calling them every frame is cheap.
The tray's dry run
(tray::set_dry_run, jfgui_TRAY_DRYRUN=1; the UI's headless runs) prints "taskbar: ..."
instead.

Windows (win_taskbar.rs): ITaskbarList3 on the main window (SetProgressState,
SetProgressValue, SetOverlayIcon with the count as its text), applied again on the
registered message "TaskbarButtonCreated" (the first show, Explorer restarted);
ICustomDestinationList with IShellLinkW tasks (title through IPropertyStore PKEY_Title).
COM on the UI thread: call these from the UI thread.  Linux (linux_taskbar.rs): the signal
com.canonical.Unity.LauncherEntry.Update(application://<desktop id>.desktop, {progress,
progress-visible, count, count-visible}) on a session-bus connection kept open (docks drop
the state when it closes; Query is answered), understood by KDE Plasma, Ubuntu's dock /
Dash to Dock and Plank.  Linux knows no paused / error / indeterminate look (paused and
error show the bar, indeterminate none) and no jump list at run time (that is the .desktop
file's Actions).  macOS (apple_mac_services.rs): the Dock tile -- badgeLabel, the progress drawn
into the tile (blue, yellow paused, red error, grey busy), the tasks as the Dock menu (a chosen
one reaches the app as UIC_OPEN, without a second start).  Web and Android: nothing (false).
  • enum TaskbarProgress what the taskbar button's progress bar shows
    • None -- no bar
    • Normal(f32) -- done so far (0.0 ..= 1.0)
    • Paused(f32) -- paused at (Windows: yellow)
    • Error(f32) -- failed at (Windows: red)
    • Indeterminate -- busy without a known end (Windows: a moving bar)

impl TaskbarProgress

  • fn value(&self) -> f32 the fraction done, clamped to 0.0 ..= 1.0 (None / Indeterminate: 0.0)

  • struct JumpTask one task of the jump list: starts this program with args

    • title: String -- the row's text
    • args: Vec<String> -- the arguments after the program
    • desc: String -- its tooltip ("" = none)
  • fn taskbar_progress(p: TaskbarProgress) -> bool show progress on the app's taskbar button -> false: not shown here

  • fn taskbar_badge(count: u32, icon: Option<&TrayIcon>) -> bool a badge on the button: count (0 = none), icon = Windows' overlay (None: no overlay there)

  • fn taskbar_tasks(tasks: &[JumpTask]) -> bool the tasks of the button's jump list (empty: none) -> false: no jump list here

  • fn taskbar_badge_shown(count: u32) -> bool whether a badge with count is shown already (with its icon): the UI then need not draw it again

  • fn taskbar_state() -> (TaskbarProgress, u32) what was set last: the progress and the badge's count

  • fn taskbar_supported() -> bool whether this system shows the taskbar progress and badge

  • fn app_user_model_id() -> Option<String> (Windows) the process's explicit AppUserModelID (what the shell holds: GetCurrentProcessExplicitAppUserModelID); None: the one Windows derives from the program's path (other systems: always None)

  • fn set_app_user_model_id(id: &str) -> bool (Windows) run the process under the AppUserModelID id: before its first window -> false elsewhere, in an MSIX package and for an id Windows refuses

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