Embed application icons and prepare portable preview releases
Gitea/pdf-presenter/pipeline/head There was a failure building this commit Details

This commit is contained in:
Dandaedre 2026-11-19 18:34:12 +01:00
parent b2965f7207
commit 5d12b85b07
24 changed files with 447 additions and 9 deletions

3
.gitignore vendored
View File

@ -8,3 +8,6 @@ __pycache__/
.DS_Store
.env
*gitea-token*
# Private local presentation fixtures, never release inputs.
/test_pdf/

View File

@ -24,3 +24,5 @@
- [Native user guide](docs/user-guide.md).
- [Native settings v1](docs/interfaces/settings.md).
- [Private process protocol](docs/interfaces/process-protocol.md).
- [Manual release preparation](docs/development/releases.md).

49
Cargo.lock generated
View File

@ -2212,7 +2212,7 @@ dependencies = [
[[package]]
name = "pdf-presenter"
version = "0.1.16"
version = "0.1.17"
dependencies = [
"bytemuck",
"chrono",
@ -2232,8 +2232,9 @@ dependencies = [
"softbuffer",
"sys-locale",
"tempfile",
"toml",
"toml 0.8.23",
"winit",
"winresource",
"x11-dl",
]
@ -3125,6 +3126,18 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "toml"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime 0.6.11",
"toml_edit 0.19.15",
]
[[package]]
name = "toml"
version = "0.8.23"
@ -3155,6 +3168,19 @@ dependencies = [
"serde_core",
]
[[package]]
name = "toml_edit"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime 0.6.11",
"winnow 0.5.40",
]
[[package]]
name = "toml_edit"
version = "0.22.27"
@ -3839,6 +3865,15 @@ dependencies = [
"xkbcommon-dl",
]
[[package]]
name = "winnow"
version = "0.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
dependencies = [
"memchr",
]
[[package]]
name = "winnow"
version = "0.7.15"
@ -3857,6 +3892,16 @@ dependencies = [
"memchr",
]
[[package]]
name = "winresource"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77e2aaaf8cfa92078c0c0375423d631f82f2f57979c2884fdd5f604a11e45329"
dependencies = [
"toml 0.7.8",
"version_check",
]
[[package]]
name = "wit-bindgen"
version = "0.57.1"

View File

@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"]
resolver = "3"
[workspace.package]
version = "0.1.16"
version = "0.1.17"
edition = "2024"
license = "MIT"
repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter"

8
Cross.toml Normal file
View File

@ -0,0 +1,8 @@
[build.env]
passthrough = ["RUSTUP_TOOLCHAIN"]
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main"
[target.x86_64-pc-windows-gnu]
image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:main"

View File

@ -1792,6 +1792,12 @@ License expression: MIT
Source: https://github.com/tokio-rs/tokio
LICENSE: text 253cd04c6714889d
toml 0.7.8
License expression: MIT OR Apache-2.0
Source: https://github.com/toml-rs/toml
LICENSE-APACHE: text c6596eb7be8581c1
LICENSE-MIT: text 6efb0476a1cc0850
toml 0.8.23
License expression: MIT OR Apache-2.0
Source: https://github.com/toml-rs/toml
@ -1810,6 +1816,12 @@ Source: https://github.com/toml-rs/toml
LICENSE-APACHE: text 249fdb6694467dd6
LICENSE-MIT: text 6efb0476a1cc0850
toml_edit 0.19.15
License expression: MIT OR Apache-2.0
Source: https://github.com/toml-rs/toml
LICENSE-APACHE: text c6596eb7be8581c1
LICENSE-MIT: text 6efb0476a1cc0850
toml_edit 0.22.27
License expression: MIT OR Apache-2.0
Source: https://github.com/toml-rs/toml
@ -2200,6 +2212,11 @@ License expression: Apache-2.0
Source: https://github.com/rust-windowing/winit
LICENSE: text 6dc0e068dcf3a5bc
winnow 0.5.40
License expression: MIT
Source: https://github.com/winnow-rs/winnow
LICENSE-MIT: text cb5aedb296c5246d
winnow 0.7.15
License expression: MIT
Source: https://github.com/winnow-rs/winnow
@ -2210,6 +2227,11 @@ License expression: MIT
Source: https://github.com/winnow-rs/winnow
LICENSE-MIT: text cb5aedb296c5246d
winresource 0.1.17
License expression: MIT
Source: https://github.com/BenjaminRi/winresource
LICENSE: text 3564da09711c4756
wit-bindgen 0.57.1
License expression: Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
Source: https://github.com/bytecodealliance/wit-bindgen
@ -5434,6 +5456,34 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
END OF TERMS AND CONDITIONS
=== 3564da09711c4756 ===
Copyright 2016 Max Resch
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
=== 378f5840b258e277 ===
Copyright (c) 2014 Alex Crichton

View File

@ -33,3 +33,11 @@ libc = "0.2"
[target.'cfg(target_os = "linux")'.dependencies]
x11-dl = "=2.21.0"
[build-dependencies]
winresource = "=0.1.17"
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.tgz"
pkg-fmt = "tgz"
bin-dir = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }"

View File

@ -1,6 +1,15 @@
# Application artwork
`app-icon.png` is the generated master for the future desktop app and repository
avatar. The README consumes the same asset. Generate platform ICO/ICNS sizes during
packaging; no desktop bundle exists yet. Do not alter the master silently.
`app-icon.png` is the unchanged generated master and repository avatar.
`window-icon.png` is its 256-pixel derivative embedded in all native windows
and used by the optional Linux desktop launcher. `app-icon.ico` contains
16/24/32/48/64/128/256-pixel derivatives embedded in the Windows executable.
Artwork is decoded once per GUI process, with no runtime disk reads.
See [generation provenance](../../../docs/development/icon-prompts.json).
Regenerate with ImageMagick:
```sh
magick app-icon.png -resize 256x256 window-icon.png
magick app-icon.png -define icon:auto-resize=256,128,64,48,32,24,16 app-icon.ico
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -0,0 +1,9 @@
fn main() {
println!("cargo:rerun-if-changed=assets/app-icon.ico");
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
winresource::WindowsResource::new()
.set_icon("assets/app-icon.ico")
.compile()
.expect("Could not embed the Windows application icon");
}
}

View File

@ -0,0 +1,33 @@
//! Embedded window artwork and desktop identity shared by all native hosts.
use std::sync::OnceLock;
use winit::window::{Icon, Window, WindowAttributes};
pub(crate) fn window_attributes() -> WindowAttributes {
static ICON: OnceLock<Option<Icon>> = OnceLock::new();
let icon = ICON.get_or_init(|| {
let pixels = image::load_from_memory(include_bytes!("../assets/window-icon.png"))
.ok()?
.into_rgba8();
let (width, height) = pixels.dimensions();
Icon::from_rgba(pixels.into_raw(), width, height).ok()
});
let attributes = Window::default_attributes().with_window_icon(icon.clone());
#[cfg(target_os = "linux")]
let attributes = {
use winit::platform::{wayland::WindowAttributesExtWayland, x11::WindowAttributesExtX11};
let attributes =
WindowAttributesExtWayland::with_name(attributes, "pdf-presenter", "pdf-presenter");
WindowAttributesExtX11::with_name(attributes, "pdf-presenter", "pdf-presenter")
};
attributes
}
#[cfg(test)]
mod tests {
#[test]
fn embedded_icon_is_available_for_every_window() {
for _ in 0..2 {
assert!(super::window_attributes().window_icon.is_some());
}
}
}

View File

@ -78,7 +78,7 @@ impl NativeWindow {
fn create(event_loop: &ActiveEventLoop, title: &str) -> Result<Self, Failure> {
let window = Rc::new(
event_loop.create_window(
Window::default_attributes()
crate::artwork::window_attributes()
.with_title(title)
.with_visible(false)
.with_inner_size(PhysicalSize::new(960, 640)),

View File

@ -82,3 +82,5 @@ pub mod studio;
pub mod localization;
/// Standalone presenter palettes.
pub mod theme;
mod artwork;

View File

@ -55,7 +55,7 @@ impl NativeWindow {
};
let window = Rc::new(
el.create_window(
Window::default_attributes()
crate::artwork::window_attributes()
.with_title(title)
.with_window_level(if role == Role::Browser {
winit::window::WindowLevel::AlwaysOnTop

View File

@ -232,6 +232,35 @@ fn orphaned_output_holds_until_closed_then_exits_on_close_or_escape() {
}
}
let _display = DisplayGuard(&x, display);
// Other desktop clients can destroy windows between enumeration and property
// lookup. BadWindow is an expected race; other protocol errors still fail.
static X_ERROR: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(0);
unsafe extern "C" fn on_x_error(
_: *mut xlib::Display,
event: *mut xlib::XErrorEvent,
) -> std::os::raw::c_int {
let code = unsafe { (*event).error_code };
if code != xlib::BadWindow {
X_ERROR.store(code, std::sync::atomic::Ordering::Relaxed);
}
0
}
let previous_handler = unsafe { (x.XSetErrorHandler)(Some(on_x_error)) };
struct ErrorGuard<'a>(
&'a xlib::Xlib,
Option<
unsafe extern "C" fn(*mut xlib::Display, *mut xlib::XErrorEvent) -> std::os::raw::c_int,
>,
);
impl Drop for ErrorGuard<'_> {
fn drop(&mut self) {
unsafe {
(self.0.XSetErrorHandler)(self.1);
}
}
}
let _errors = ErrorGuard(&x, previous_handler);
let root = unsafe { (x.XDefaultRootWindow)(display) };
let pid_atom = unsafe { (x.XInternAtom)(display, c"_NET_WM_PID".as_ptr(), 0) };
fn find(
@ -338,6 +367,35 @@ fn orphaned_output_holds_until_closed_then_exits_on_close_or_escape() {
assert!(Instant::now() < deadline, "output window not created");
std::thread::sleep(Duration::from_millis(10));
};
// Verify the icon actually reached X11, not just WindowAttributes.
unsafe {
let icon_atom = (x.XInternAtom)(display, c"_NET_WM_ICON".as_ptr(), 0);
let (mut kind, mut format, mut count, mut after) = (0, 0, 0, 0);
let mut data = std::ptr::null_mut();
(x.XGetWindowProperty)(
display,
window,
icon_atom,
0,
2,
0,
xlib::XA_CARDINAL,
&mut kind,
&mut format,
&mut count,
&mut after,
&mut data,
);
assert!(!data.is_null());
let dimensions =
std::slice::from_raw_parts(data.cast::<std::os::raw::c_ulong>(), count as usize)
.to_vec();
(x.XFree)(data.cast());
assert_eq!(format, 32);
assert_eq!(dimensions, [256, 256]);
assert_eq!(after, 256 * 256 * 4);
}
assert_eq!(X_ERROR.load(std::sync::atomic::Ordering::Relaxed), 0);
// EOF models a vanished presenter. Keep the output alive until the operator closes it.
drop(input);
std::thread::sleep(Duration::from_millis(300));

View File

@ -2,6 +2,14 @@
## Unreleased
### 0.1.17
- Embed application icons in all native windows and the Windows executable.
Set Linux X11/Wayland identity and provide optional per-user desktop integration.
- Prepare rust_realease configuration for Linux/Windows executables, binstall
archives and portable bundles, with checksums and preview release instructions.
No tag, push or remote release is performed by this preparation.
### 0.1.16
- Ensure presenter shutdown can terminate/reap its output process even when the

View File

@ -32,7 +32,8 @@ Cleanup archives exactly `coverage/version.svg`, `coverage/test.svg` and
`coverage/coverage.svg`. Only main builds without CHANGE_ID publish badges under
`/mnt/assets/coverage/idle-org/pdf-presenter/main/`, including honest failed-test
or unavailable-coverage status. No shared asset root is synchronized or deleted.
There is no manual publisher, release job or binary upload in this pipeline.
There is no release job or binary upload in this pipeline.
Separate local packaging uses [rust_realease](releases.md).
The Jenkinsfile still requires a real Jenkins run; local tests cannot validate
worker configuration or prove the remote pipeline has run.

View File

@ -0,0 +1,18 @@
# PDF Presenter 0.1.17 preview
Portable PDF and image-folder presenter with fullscreen presenter/presentation
views, monitor routing/mirroring, notes, slide browser, themes and English/French.
Deck preparation reports progress, ETA and RAM use; prepared slides stay in memory.
This preview adds Linux/Windows application icons and release bundles. It includes
fixes for Windows file-dialog ownership/duplicate requests and output-host shutdown.
Windows embeds its Explorer/taskbar icon. Linux portable bundles include an optional
`python3 install-linux-launcher.py` for desktop menu and Wayland icon integration.
The executable runs without Python or a separately installed PDF renderer.
Use the Windows portable ZIP or Linux portable tarball, extract and run the binary.
Raw binaries and cargo-binstall archives are also provided. Verify SHA256SUMS.
Physical multi-monitor behavior, sleep prevention, clean-machine compatibility,
and sustained performance still require user acceptance. Windows binaries are
unsigned. macOS binaries are not part of this preview.

View File

@ -0,0 +1,55 @@
# Manual preview releases
The standalone `rust_realease` tool (sibling checkout `../rust_realease`) consumes
root `rust-release.toml` and `Cross.toml`. Jenkins still only validates/publishes
badges. The release configuration selects Linux x86_64 GNU and Windows x86_64 GNU.
macOS remains an implementation target, but is not advertised as a prepared release
artifact until a linked native build and runtime acceptance are available.
Build local artifacts without a token or contacting Gitea:
```sh
CROSS_CONTAINER_ENGINE=podman ../rust_realease/target/release/rust_realease . \
--package pdf-presenter --compile-only
```
Use the installed `rust_realease` command instead if preferred. Cross must have
access to its configured images. Outputs live under `dist/release-*/`, including
raw executables, binstall `.tgz` archives, a Linux portable `.tgz`, a Windows
portable `.zip`, and `SHA256SUMS`. The binaries themselves need no companion assets.
Portable bundles add the license, quickstart and optional Python Linux launcher.
Wayland shells resolve icons through the matching installed desktop entry;
X11 and Windows also receive the embedded native window icon directly.
The Windows PE icon is embedded at build time using winresource/windres.
Keep a clean committed checkout for reusable builds. Private local test PDFs are
ignored and never included in archives. Dependency notices are embedded (`--licenses`)
and regenerated with `python3 scripts/notices.py` after dependency changes.
Before publication, run all checks in [CI](ci.md), inspect bundle contents and
checksums, and test extracted binaries on clean Windows/Linux machines. Physical
multiscreen, sleep and performance acceptance remains in [the plan](plan.md).
Version 0.1.17 is prepared as a **preview**, not a production-readiness claim.
Publication is a separate explicit action: create local `v0.1.17` at the reviewed
commit, push that commit/tag, then run:
```sh
rust_realease . --package pdf-presenter --prerelease \
--message-file docs/development/release-notes/v0.1.17.md \
--token-file ../gitea-token.txt
```
`--dry-run` previews without remote mutation. Before tagging, its missing-tag
prerequisite is expected. Do not use automatic tag/push options as part of local
preparation. Never put credentials in configuration, artifacts or Git.
## Local validation for 0.1.17
Formatting, warnings-denied Clippy/rustdoc, 47 Rust tests (including native X11
icon-property checks), 12 Python tests, desktop-entry syntax validation and
macOS aarch64 compile-check pass. Whole-application line coverage is 84.05%.
The native test now tolerates BadWindow when unrelated desktop windows disappear
during enumeration; other X11 errors still fail. No production code is excluded.
Windows Explorer/taskbar appearance and Linux Wayland shell integration still
need native user confirmation.

View File

@ -0,0 +1,19 @@
PDF Presenter 0.1.17 — preview release
Windows: extract the ZIP and run pdf-presenter.exe. Its icon is embedded.
Linux: extract the tarball and run ./pdf-presenter. Optional menu/taskbar
integration: keep the extracted folder in a permanent location, then run
python3 install-linux-launcher.py. No root privileges are needed. Python is
only needed for this optional installer, never for running PDF Presenter.
To remove integration delete ~/.local/share/applications/pdf-presenter.desktop
(or the corresponding file under your XDG_DATA_HOME).
Wayland shells use that desktop entry to resolve the application icon.
The executable includes the renderer, image codecs, fonts and window icon.
No runtime downloads or separately installed PDF renderer are required.
Linux uses the system desktop services and X11/Wayland libraries.
Run --licenses for bundled dependency notices. Open PDFs or picture folders
from Menu. Both presenter and presentation windows start fullscreen.
Physical display, sleep prevention and clean-machine acceptance remain open.
This is a preview for testing, not a claim of production readiness.

31
rust-release.toml Normal file
View File

@ -0,0 +1,31 @@
[release]
tag-prefix = "v"
[build]
targets = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]
profile = "release"
locked = true
[package]
format = "both"
[[package.bundles]]
name = "portable"
targets = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]
formats = { x86_64-pc-windows-gnu = "zip", x86_64-unknown-linux-gnu = "tgz" }
archive-name = "{name}-{bundle}-{target}-v{version}"
root = "{name}-{bundle}-{target}-v{version}"
cargo-binaries = "all"
files = [
{ source = "assets/window-icon.png", destination = "pdf-presenter.png" },
{ source = "scripts/install-linux-launcher.py", destination = "install-linux-launcher.py", workspace-relative = true },
{ source = "LICENSE", destination = "LICENSE.txt", workspace-relative = true },
{ source = "docs/portable-quickstart.txt", destination = "README.txt", workspace-relative = true },
]
[[repository.fallbacks]]
origin = "https://git.dandaedre.com/idle-org/pdf-presenter"
fallback-url = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter"
[gitea]
token-env = "GITEA_TOKEN"

View File

@ -0,0 +1,39 @@
#!/usr/bin/env python3
"""Optional per-user Linux menu integration; keep the extracted bundle in place."""
import os
from pathlib import Path
import sys
def desktop_entry(binary, icon):
# Desktop Entry strings and Exec have different escaping rules.
def string(value):
return str(value).replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r")
command = str(binary).replace("%", "%%")
for char in ("\\", '"', "`", "$"):
command = command.replace(char, "\\" + char)
return ('[Desktop Entry]\nType=Application\nName=PDF Presenter\n'
'Comment=Multiscreen PDF and picture presenter\n'
f'Exec="{string(command)}" %f\nIcon={string(icon)}\n'
'Terminal=false\nCategories=Office;Presentation;\n'
'MimeType=application/pdf;\nStartupWMClass=pdf-presenter\n')
def main():
if not sys.platform.startswith("linux"):
raise SystemExit("This optional launcher is for Linux only.")
root = Path(__file__).resolve().parent
binary, icon = root / "pdf-presenter", root / "pdf-presenter.png"
if not binary.is_file() or not icon.is_file():
raise SystemExit("Run this script from the extracted portable Linux bundle.")
data = Path(os.environ.get("XDG_DATA_HOME") or Path.home() / ".local/share")
if not data.is_absolute():
raise SystemExit("XDG_DATA_HOME must be absolute.")
target = data / "applications/pdf-presenter.desktop"
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text(desktop_entry(binary, icon), encoding="utf-8")
print(f"Installed {target}. Keep the portable folder at {root}.")
if __name__ == "__main__":
main()

40
tests/test_launcher.py Normal file
View File

@ -0,0 +1,40 @@
import importlib.util
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
SCRIPT = Path(__file__).resolve().parents[1] / "scripts/install-linux-launcher.py"
spec = importlib.util.spec_from_file_location("launcher", SCRIPT)
launcher = importlib.util.module_from_spec(spec)
spec.loader.exec_module(launcher)
class LauncherTests(unittest.TestCase):
def test_exec_escapes_field_codes_and_shell_characters(self):
entry = launcher.desktop_entry('/tmp/a b%f/$x`y"/pdf-presenter', '/tmp/icon.png')
self.assertIn('%%f', entry)
self.assertIn('\\\\$', entry)
self.assertIn('\\\\`', entry)
self.assertIn('StartupWMClass=pdf-presenter', entry)
self.assertIn('" %f\n', entry)
def test_install_from_bundle_uses_xdg_location(self):
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
bundle = root / "portable folder"
bundle.mkdir()
script = bundle / SCRIPT.name
script.write_bytes(SCRIPT.read_bytes())
(bundle / 'pdf-presenter').touch()
(bundle / 'pdf-presenter.png').touch()
env = dict(os.environ, XDG_DATA_HOME=str(root / 'data'))
subprocess.run(['python3', str(script)], env=env, check=True, capture_output=True)
installed = root / 'data/applications/pdf-presenter.desktop'
self.assertEqual(installed.read_text(), launcher.desktop_entry(
bundle / 'pdf-presenter', bundle / 'pdf-presenter.png'))
(bundle / 'pdf-presenter').unlink()
result = subprocess.run(['python3', str(script)], env=env, capture_output=True)
self.assertNotEqual(result.returncode, 0)
self.assertTrue(installed.is_file())