Repository navigation
fix(linux): enable Flatpak printing through XDG Print Portal (#1905) - #3066
Open
robertobulltech wants to merge 1 commit into
Open
robertobulltech wants to merge 1 commit into
robertobulltech wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Flatpak has neither the CUPS client commands nor the CUPS socket, so discovery returned no printers and PdfCraft offered only Save as PDF. Linux Flatpak printing now uses
org.freedesktop.portal.Printwithout additional sandbox permissions. Native Linux retains CUPS; Windows, macOS and browser backends retain their existing paths.Fixes #1905.
Architecture and workflow
default-features = falseandasync-io; the other dependencies already existed in the lockfile. ashpd was evaluated; using zbus directly keeps the request handle, response subscription, cancellation and bounded cleanup under the application's control without another portal-client dependency. craft-print itself and its pin are unchanged./.flatpak-infoor a nonemptyFLATPAK_IDselects the portal. Flatpak does not enumerate or query CUPS, and the system dialog is a separate destination rather than a fabricated printer.reverse: "no"response is accepted alongside"false"./proc/self/fd; no pathname is given to the host. Descriptors are dropped on every outcome.UI and automation
Flatpak offers System print dialog… even with zero enumerated printers, plus the existing Save as PDF. Preview, page selection, orientation, sizing, N-up, booklet, poster, comments/forms and Print as image retain the existing composition path. Grayscale uses the existing image renderer. Driver Properties/copies/collate/duplex are disabled/delegated, and paper is labelled as the PDF sheet size. The system dialog should keep All pages, one page per sheet and 100% scale. The progress card can cancel a pending request.
printersreportssystem_dialog: truewith an empty printer list.doc_printacceptsprinter: "system-dialog"or"default", returnsstatus: "accepted"/"cancelled", and rejects physical-option arguments that must be selected in the host dialog. Atomic PDF saving and automation root confinement remain intact.How you verified it
Functional tests: 139 passed, scoped to the changed printing paths:
--lib print--lib print_uiprintingThe private dbus-daemon/mock service receives the actual imposed PDF through a read-only Unix FD and tests early responses, both-phase cancellation, malformed/failed responses and tokens, incompatible settings, unavailable/disappearing services, timeout/Close, cleanup and consecutive requests. These are functional tests, not compilation-only checks.
flatpak_offers_system_printing_without_cupswas copied unchanged into an archive of base924c4da4ac2879ac9107c6c82e20ac6be5570f0a: it compiled and failed because the system dialog option was absent. The same test passes with the fix, including saving a valid PDF.cargo fmt --check-j 2 --all-targets -- -D warnings: print, engine, automation, ui-egui, desktop appcargo xtask layers,assets,paritycargo check -p pdfcraft-web --target wasm32-unknown-unknown -j 2, Rust 1.95 (existing render/UI dead-code warnings)Remote CI: GitHub Actions currently reports
action_requiredwith no jobs started (CI run); upstream access for this contributor is READ. A maintainer must unblock the upstream workflows. The passing results above are local checks, not a claim that remote CI ran.Real KDE/Wayland and Flatpak evidence
On CachyOS, Plasma/Wayland, xdg-desktop-portal 1.22.1, KDE portal 6.7.5 and Freedesktop Platform 25.08.18:
--control. The native CUPS/Save dialog is retained; this host has no CUPS queues.lp,lpstat,lpoptions, CUPS socket or/etc/cups.83213200b1525b8f30e8498e09aaa41a90e22537c6677ae2bffba1170197512e. External PDF inspection/rendering confirmed green/blue on sheet 1 and magenta on sheet 2; source page 1 is excluded.doc_printtool. The output path was outside the sandbox's visible filesystem, demonstrating portal delivery rather than direct host filesystem access./tmp/#… (deleted)PDF descriptor while waiting and none after the response.Detailed validation and reproducible command scopes. Private logs and synthetic outputs are retained locally; no third-party desktop screenshots, PDF binaries or fonts are committed.
Security, provenance and limitations
Limits: physical printer output, duplex, paper calibration, collation and driver compatibility are not hardware-validated. A portal cancellation cannot guarantee recalling a physical job already handed to the host. Windows/macOS runtime printing was not rerun. Wayland uses an unparented, nonmodal dialog because eframe cannot safely export an xdg-foreign handle; X11 identifiers are supplied where available. Physical paper/scale choices remain the host driver's responsibility; PostScript/SVG file output is unsupported.
The local test bundle used stripped debug binaries linked against the runtime's libm because CachyOS's newer glibc exports symbols absent in runtime 25.08. No linker workaround or bundled glibc is committed; release binaries already target Ubuntu 22.04. The full offline Flathub source build and optional release OCR/Japanese-font inputs were not exercised by this printing validation. No physical printer was required.