Commit Graph
105 Commits
Author SHA1 Message Date
aiongg b1766bb698 Merge remote-tracking branch 'upstream/next' into fw/mac1 2026-11-16 19:42:31 +00:00
aiongg a293456ced Section headings in Canvas Size, Print, Export As and Save for Web: Current Size and New Size with their file sizes, Printer Setup and the app's sections, File Settings, all bold under a rule 2026-11-16 16:39:29 +00:00
aiongg 2df33d2f01 Merge remote-tracking branch 'upstream/main' into sync/main-1116
# Conflicts:
#	Cargo.lock
#	crates/audio/src/lib.rs
#	crates/exr/src/decode.rs
#	crates/font-catalog/src/lib.rs
#	crates/ps/src/lib.rs
#	crates/svg/Cargo.toml
#	crates/text/Cargo.toml
#	crates/text/src/lib.rs
#	crates/video/Cargo.toml
#	crates/video/src/lib.rs
2026-11-16 14:23:07 +00:00
aiongg fca840bcc5 Per-statement marks for the print marks; exception entries for the vec2 allows; slice number inset allow 2026-11-16 14:02:50 +00:00
aiongg 3bce302286 Allow markers for printer marks, print story page sizes and the Convert Point cursor tip 2026-11-16 14:01:16 +00:00
aiongg f647f41e82 Merge branch 'dl/api' into dl/all 2026-11-16 13:39:11 +00:00
aiongg fbe5a16ffe design-lint: api/non-exhaustive: #[non_exhaustive] on public types and variants, constructors where other crates build them 2026-11-16 13:31:29 +00:00
aiongg 183d99f0c2 design-lint: props: derive the setters of print components (#[prop]) and drop the hand setters 2026-11-16 13:27:45 +00:00
Dylan M. Taylor e409e74333 fix(print): opt-in bounded discovery for larger CUPS fleets (#1734)
* fix(print): allow explicitly bounded fleet discovery

* print: frame fleet discovery fixture as an HTTP reply
2026-11-16 06:49:02 -05:00
aiongg 3ceff195c7 Sync follow-ups: upstream's new tests in crates whose test executable runs trials are trials (print cups, ticket and windows_native, timeline interchange, update); craft-print's cups module documented (missing_docs), its tests under cfg(test) 2026-11-16 02:02:00 +00:00
aiongg dffc61a7e0 Merge storytold main 832883b5 (sync 16 Nov)
961 upstream commits since 7bb6c900. Resolutions:
- Test-only conflicts: upstream tests from before the base that our side
  cut stay cut; tests new upstream are kept (audio aac/config, layout,
  encode_format; cms lutfile; media mux; print windows_native, ticket;
  update self_update; xml hostile).
- Code our side moved, with upstream's change carried to the new place:
  craft-media mux roll sample groups (mux/boxes.rs) and writer-start
  offsets with overflow checks (mux/progressive.rs); craft-print's
  shrink-to-fit scale guard (sheets/plan.rs); craft-update's nextest
  archive detection (self_update/detect.rs); craft-vectorcraft-format's
  Tail::write_to_with (container.rs); craft-i18n's pedantic fixes
  (bidi.rs, negotiation.rs).
- craft-ui: the old crate's modules stay removed; gpu_test_lock guarded
  their per-test wgpu renderers, which the snapshot kit does not have.
- New upstream tests in crates that build their integration tests into
  the library's test executable are modules of tests/main.rs (audio
  flac_decode and qoa_oracle, cms, docpath, pcraft-format,
  vectorcraft-format).
- The 22 new crates are optional members of the craft facade.
2026-11-16 01:52:09 +00:00
aiongg 9b93aacce2 tfix5-f11: number rows follow a shared Units choice (Param::number_in_units); HostedPrint::json_form; the preview is named Print preview image 2026-11-16 00:44:29 +00:00
Dylan M. Taylor ac7586ed9f Merge pull request #1507 from storytold/dot/photo-ipp-shared
print: reuse direct CUPS transport with explicit app parity API
2026-11-15 08:01:42 -05:00
aiongg 14d5ec609a cargo fmt 2026-11-15 10:23:21 +00:00
.CooCoo 600fc71614 print: winprint 8ae097ef: from_dev_mode at its merge commit on main (#1474)
craft-print took PrintTicket::from_dev_mode (winprint.rs#24) at the pull request's earlier head
72951d74, which is not on winprint.rs's main. #24 merged as 8ae097ef, and the pin moves there.

The only code difference between the two revisions is in from_dev_mode's own size check: it now
accepts a DEVMODE whose public part reaches dmFields (76 bytes) instead of requiring 156 bytes.
craft-print passes it only settings that craft-winprint-gdi's DevMode::from_bytes accepted, which
still requires 156 bytes, so craft-print's behavior does not change. The API craft-print uses is
unchanged; only the rev and the lockfile move.
2026-11-15 00:12:37 -06:00
aiongg 2fde380ed6 dialogs-w16: net change of 8 commits
- dialogs-w16: written from its sheet
- dialogs-w16: repair 1
- dialogs-w16: review fixes (review-1)
- dialogs-w16: review fixes (item 1, 6)
- dialogs-w16: review fixes (item 6)
- dialogs-w16: the print preview's style is as visible as the preview (combine)
- dialogs-w16: the preview's release ends only a running drag; its output reports its edits to the suite (dialogs run round)
- dialogs-w16: the print preview's value is the image box position, which a drag moves from the gesture's start and a host check can refuse (dialogs run round)
2026-11-15 04:46:07 +00:00
Dylan M. Taylor 9053f5389f Merge pull request #1225 from Bra1nZ/fix/7230-legacy-v3-driver-zero-media-side
fix(print): trust one side of a legacy V3 driver's paper metric
2026-11-14 11:43:38 -05:00
aiongg 0e216b6257 Contract stubs: decision pass 2026-11-14 16:07:24 +00:00
midasmatterhorn 08c206f4ae Merge remote-tracking branch 'upstream/main' into r4-print-shrink-147 2026-11-14 16:55:58 +03:00
Bra1nZ 05c2e38271 fix(print): reject a partial record whose known name contradicts the sheet
A review finding on #1225: a single agreeing partial record was taken on
its known side alone, so a Legal request could take a keyword entry
named Letter reporting (215_900, 0) - the ticket then selects Letter
while the layout assumes Legal. A single partial record now refuses when
its known name doesn't match the requested standard sheet; an unnamed
one is still taken on agreement alone.

The name check exposed names_paper accepting a word modifier as a
dimension: "A4 Extra" matched "A4" because the suffix rule only looked
at the first character, a space. The rule now reads the word after the
separator: a letter is a modifier ("A4 Extra" is another paper), a digit
is the sheet's dimensions ("A4 210 x 297 mm"), a digit or letter right
against the name is a different name ("ARCH E1", "A4Extra").
2026-11-14 13:16:41 +03:00
Bra1nZ 82e3341018 fix(print): match the requested paper identity among partial records and resolve parameter references
Two review findings on #1225:

A partial paper record was accepted as a candidate of last resort on its
known side alone, so a partial Letter and a partial Legal sharing a
width both agreed with a Legal request and the first one in the driver's
order won - the ticket could select Letter while the layout assumed
Legal. Partial candidates now resolve ambiguity the way full ones do:
one whose name matches the requested standard sheet wins; an ambiguity
that leaves more than one (or none) is not resolved and nothing is
selected.

integer() read only a direct Value, so a paper dimension supplied
through a ParameterRef read as missing and the fallback silently
substituted the requested size for a ticket that named a different one.
The resolution logic the driver's ticket reader already had moves into a
shared resolved_value() helper, and integer() uses it: a referenced
dimension now either agrees or refuses.
2026-11-14 12:55:59 +03:00
aiongg e9e3a961f4 Merge next (CI lint fixes) into phase2/stubs
# Conflicts:
#	crates/color/src/ui/swatches/menu.rs
2026-11-14 03:13:33 +00:00
aiongg deeb91802f Lints: doc links, test lint allowances, struct update in tests, wildcard imports, dead code 2026-11-14 02:35:35 +00:00
aiongg b12d6387c5 Contract stubs: craft-automation, craft-layers, craft-font-manager, craft-timeline, craft-print 2026-11-14 02:34:37 +00:00
aiongg acdacefe1a Lints: import the names the split-out modules use from where they are defined 2026-11-14 00:18:37 +00:00
aiongg e8663f6c72 Lints: replace wildcard imports of split-out modules with explicit imports 2026-11-14 00:15:29 +00:00
aiongg a17171af48 Lints: drop the workspace missing_docs lint and warn on it in the framework crates that document every public item 2026-11-14 00:15:29 +00:00
Bra1nZ ef03e1b1df fix(print): trust one side of a legacy V3 driver's paper metric
Legacy V3 GDI drivers (HP LaserJet P1102) keep the paper metric in their
DEVMODE extension and report MediaSizeWidth = 0 while the height is right,
so verify_ticket refused with "a paper without a size (a roll?)" and
nothing was sent (storytold/craft-libs#7230).

verify_ticket now fails closed only when neither side is known or the
request itself names no sheet; otherwise it goes on with the requested
size, but only while the side the driver did report agrees with the
request to a quarter of a millimetre. matching_paper gains a partial
record as a candidate of last resort, and driver_ticket takes the wanted
size from the sheet the job asked for, not from the zero record.
The fallback is logged; log moves to the common dependencies so the
warning compiles on Windows too (caught by the windows-gnu check).
2026-11-14 01:19:29 +03:00
aiongg 577055bc34 Merge storytold main 3c59a2aa5 into craft-framework (sync 13 Nov)
202 upstream commits since 6cb00467a. Resolutions:
- craft-window, craft-platform: ours. Upstream's frame policy v2, restore
  store and GNOME light/wait_first are the versions carried on 28 Oct;
  ours moved place() to craft-behavior and kept LayoutWatch and the
  appearance/portal.rs split.
- craft-timeline: ours. craft-time (crates/time) lands as upstream wrote
  it and is not yet used by craft-timeline.
- Old crates/ui modules stay removed. Upstream's frosted backdrops, shape
  gallery, dialog tabs and the iconic flyout top-edge rendering are not
  carried. The #1094 model half is in craft-behavior's dock:
  Group::flyout_offset and Action::MoveFlyoutTop.
- craft-update: #586 Save and Update, the install probe on the check
  thread and quiet per-user MSI self-updates, carried into updater.rs,
  stack_dialogs.rs, install/windows.rs and self_update/helper.rs.
- craft-jpeg: progressive Huffman decoding, carried into huffman.rs,
  parse.rs and scan.rs.
- craft-print: the driver settings dialog's new tests and the bounded
  XML parse's tests, as trials.
- Test-only conflicts: upstream tests from before the base that our side
  cut stay cut; tests new upstream are kept.
2026-11-13 17:11:48 +00:00
Dylan M. Taylor bdba99322e Use canonical winprint repository URL 2026-11-13 01:28:04 -05:00
midasmatterhorn 88271c006c print: cover the 1% scale tolerance boundary in shrink-to-fit
The bound had only the zero-scale side tested. Add the other edge: a scale
whose four-decimal serialization is more than 1% off. A 118 750 pt wide
sheet on Letter with an 18 pt margin scales by 576 / 118 750 = 0.00485053,
written 0.0049 -- 1.02% off -- and the plan refuses as an error before
anything is sent. Just inside the bound (118 700 pt: 0.98% off) still
prints, its matrix carrying the written 0.0049.
2026-11-12 23:43:32 +03:00
.CooCoo cb9d29c913 print: a Windows driver's own settings dialog for one job
* print: driver_settings_dialog sets a Windows driver's own options for one job

A Windows print job could take a driver's own options, such as media type
and print quality, only from the printer's saved Printing Preferences
(open_printer_preferences), so choosing them for one job changed the
printer's defaults for every later job.

driver_settings_dialog(&mut job, parent) shows the driver's dialog
(DocumentProperties) for the job's printer. It opens on the job's earlier
choices for that printer, without the ones the job decides, when the
driver still reads them, else on the settings the driver gives a new job,
with the job's copies and collation. OK stores the settings in the new
Job::driver_settings. Cancel leaves the job as it was, and so do settings
the dialog returns exactly as it opened on them, since some drivers
return OK from Cancel with the settings they were given. craft-print does
not save the settings as the printer's defaults.

When the job prints, Windows converts the settings to a PrintTicket
(PrintTicket::from_dev_mode). craft-print removes the features the job's
own ticket decides: copies, collation, paper, orientation and scaling,
pages per sheet, binding and posters, two-sided when the job sets it, and
color when it asks for grayscale. It then merges the job's ticket after
the rest. The driver's private settings are kept, so a driver that also
keeps pages per sheet there can still apply it. The existing paper,
orientation and option checks run on the ticket the driver validates.
Settings are used only on the printer whose name they were chosen for,
and command_preview marks them as not used when the job, or the default
printer, is another one. Other platforms return an error, and CUPS jobs
ignore the settings.

winprint is pinned to dotCooCoo/winprint.rs 72951d7, which adds
from_dev_mode on top of storytold/winprint.rs main, until that change is
merged there. examples/driver_settings_dialog.rs opens the dialog and
prints a test sheet.

* print: the hand-run driver test accepts zeroed settings read as defaults

the_driver_dialogs_settings_leave_the_jobs_own_options expected every
driver to refuse a DEVMODE of zeros. Two drivers read it as the settings
they give a new job instead. The test now accepts either outcome: settings
the driver refuses are replaced by the dialog, settings it reads are kept,
and either way the dialog opens as if the job had no settings. The README
says such settings stay on the job after Cancel and print as the driver's
defaults.

* print: the README and hand-run test describe settings with no fields set

The hand-run Windows test compares the seed's replaces_unreadable with
whether the driver refused the settings, in place of a branch whose
check always passed, and describes its input as a DEVMODE with only its
size set. The README says such settings stay on the job after Cancel
and after OK with nothing changed, links the DEVMODE dmFields
description, and no longer says how the job prints with them.

* print: refuse a job whose driver replaced the dialog's media type, resolution or quality

A driver that validates the job's ticket can replace a media type, resolution or
print quality chosen in its dialog when it conflicts with the job's paper, and
Windows reports that as a success. The validated ticket is now compared with the
dialog's settings, by option name and scored values, and the job is refused when
one of them changed.

The Windows preview lists two-sided printing and color that the job leaves open as
"driver settings or queue default" and "driver settings or driver default": it
matches the settings to the printer by name and does not ask the driver to read them.

* print: the driver dialog opens without earlier settings the driver reads but refuses to merge

Earlier settings that a driver still converts to a ticket but then refuses to merge, or to convert back to its DEVMODE, are left out, as unreadable ones already are, so the dialog opens and can replace them.

---------

Co-authored-by: dotCooCoo <RobertLeeLW@gmail.com>
2026-11-12 10:05:25 -05:00
Ken MantleandKenM76 83d5ad516c print: bound the printer XML parse, and respell values where they are
* print: bound the printer XML parse; respell values where they are

Every non-test parse of the driver's PrintTicket and PrintCapabilities in
ticket.rs goes through one bounded parse (new xml.rs): at most 16 MiB,
1,000,000 nodes, 256 attributes and 64 namespace declarations on an
element, and 256 levels of nesting. roxmltree's work grows with the square
of an element's attributes and namespaces, so a broken or hostile driver
document could stall Print. The attribute, namespace and depth limits are
checked by a scan that skips comments, CDATA, processing instructions and
quoted values; the node limit is roxmltree's own nodes_limit. A document
past a limit is refused the way an unparseable one already was.

The PrintTicket respell now finds each attribute's value from the
attribute's full range (the quote after its `=`) instead of
`range_value()`, which roxmltree computes from a name length kept in 16
bits and a space count kept in 8, so it pointed elsewhere past a 64 KiB
name or 255 spaces around `=`.

Closes #630. Closes #631.

* print: bound the two parses #411 added

---------

Co-authored-by: KenM76 <KenM76>
2026-11-12 09:51:56 -05:00
aiongg 8735a8b1c5 Document and app crates on the framework: text, pages, table, review, timeline, menu, browse, dialogs, print, font manager, theme store, update, automation 2026-11-12 14:32:38 +00:00
Dylan M. Taylor 4559fe4171 print: run lpoptions with a timeout and capped output (#871) 2026-11-11 19:19:57 -05:00
FredApps 60ede99985 print: xps_driver says whether a Windows printer's driver renders XPS itself (#804)
* print: xps_driver says whether a Windows printer's driver renders XPS itself

craft_print::xps_driver(printer) reads PRINTER_DRIVER_XPS through winprint's new
PrinterDevice::is_xps_driver (storytold/winprint.rs#21): Some(true) for v4 drivers and v3
drivers with an XPS rendering filter, Some(false) for GDI drivers, None when it can't be read and
on other systems. On a GDI driver, reached through Windows' XPS-to-GDI conversion, a page with
transparency prints with halos, as black boxes or not at all (storytold/pdfcraft#6155, #5838,
#5940), so PdfCraft will flatten it for those drivers only.

The Windows end-to-end test checks the CI queue's "Generic / Text Only" driver reads as GDI.

* Test: the GDI-driver check in a helper (keeps the end-to-end test under the complexity limit)

* winprint bc06a7c48b768eb27a828c7986f6d2868b245ee0: storytold/winprint.rs main with #21 (PrinterDevice::is_xps_driver)
2026-11-11 07:48:44 +01:00
Juan JuradoandFredApps 1ee01a4c58 craft-print: ask macOS for Auto Select when a job names no tray (#232)
* craft-print: ask macOS for Auto Select when a job names no tray

CUPS gives a job that names no tray the PPD's default tray. On a queue
whose default tray is empty (a Xerox AltaLink defaulting to Tray 1), the
printer holds every job ("Tray 1 is empty") while CUPS reports it
completed, so nothing prints. Preview prints because the macOS Print
dialog's Paper Feed: Auto Select sends AP_D_InputSlot with an empty value,
which drops the PPD's default tray (storytold/pdfcraft#3752).

- lp_args sends `-o AP_D_InputSlot=` on macOS when the job's options name
  no InputSlot. A tray the job names wins; checked with cupsfilter on a
  synthetic PPD: with both, CUPS emits the InputSlot's code.
- apply_queue_defaults (now shared with apps that read options
  themselves, such as PdfCraft) gives the driver's tray option an
  AUTO_SELECT choice, labelled "Auto Select", first and as the default,
  so a dialog shows what lp_args sends. It is left out when the user's
  lpoptions defaults name another tray, since lp adds that tray to every
  job and it wins.

Linux jobs are unchanged: AP_D_InputSlot is Apple's.

* craft-print: match queue defaults to the PPD without regard to case

CUPS treats PPD option and choice names as case-insensitive. A queue
default spelled otherwise than the PPD (inputslot=tray2 for InputSlot
Tray2) was ignored, so on macOS apply_queue_defaults showed Auto Select
although lp would send Tray2. Keys and choices now match case-
insensitively and keep the PPD's spelling. lpoptions -l prints the PPD's
spelling, so this matters for callers passing defaults from elsewhere.

Review: storytold/craft-libs#232 (CodeRabbit).

* README: keep both the macOS tray and the Flatpak notes (the merge left the conflict markers in)

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-10 19:15:15 +01:00
FredApps 1146cdc4f9 print: grey pages print on a Windows driver with no grey option; ask for the one it lists (#774)
storytold/pdfcraft#5806: Print in grayscale was refused ("the printer's driver did not retain
the requested grayscale; nothing was sent") on drivers that list no grey option the ticket can
name: Microsoft Print to PDF lists only Color, and an HP Photosmart driver has only its own
ns0000:JobHPPrintInGrayScale.

- Job::grey_pages: the caller has already made the pages grey. Grayscale is still asked of the
  driver, but a driver that has no grey option, or doesn't keep it, prints the job instead of
  refusing it. Off (the default), such a driver is refused as before, since the pages would
  come out in colour.
- The ticket asks for psk:Grayscale when the driver lists that and not psk:Monochrome
  (grey_option); Windows dropped the Monochrome it didn't list and colour came back.
- Offered::grey records whether PageOutputColor has a grey option at all.
2026-11-10 15:16:57 +01:00
FredApps 3edc157a2c print: the CUPS printer list waits at most 15 s for lpstat, 10 s for discovery (#773)
printers() ran `lpstat -l -p -d` and `lpstat -e` with no time limit. When the CUPS scheduler
stops answering (macOS cupsd stopped serving its local socket in storytold/pdfcraft#6761), both
block forever and the Print dialog looks for printers until the app is closed.

Both now run through output_within (the bounded wait pdfcraft's lpoptions read already uses):
the queues get 15 s, network discovery 10 s. A scheduler that doesn't answer gives an empty list
and a warning naming cupsd; discovery that hangs only loses the driverless printers.
2026-11-10 15:16:51 +01:00
FredApps 0e4943cb5e print: winprint 3c978dfc: pages at the job's resolution, QName ticket values, padded integers (#761)
winprint.rs#19 draws each page at the resolution the job's ticket asks for instead of ~96 dpi
(storytold/pdfcraft#4941, #2676). #12 writes QName property values as prefix:local, which
drivers such as the Microsoft IPP Class Driver otherwise reject when merging the ticket
(storytold/pdfcraft#3823). #3 accepts whitespace around xsd:integer values in
PrintCapabilities (Toshiba Universal Printer 2, storytold/pdfcraft#2430).

The public API craft-print uses is unchanged; only the rev and the lockfile move.
2026-11-10 01:55:59 +01:00
art804andFredApps b6b8a55b2c craft-print: two_sided(printer) reads one printer's two-sided support (#133)
printer_queues() (#618) lists the queues without asking any driver, so
every printer's two_sided is unknown there. A Print dialog listing from it
still needs to know whether the printer the user picks takes two-sided
settings, without asking every other driver as printers() does: Windows
takes about 48 s to give up on a printer it can't reach, such as a WSD
printer on another network (storytold/pdfcraft#2192).

two_sided(printer) finds that queue and reads its driver's capabilities
with the same check printers() makes, so the answers match. It is None
when there is no such queue, when the capabilities can't be read, and off
Windows, as printers() reports there.

The paused-printer test now checks that two_sided(name) gives printers()'s
answer for the test queue from exactly one driver query, and a new test
checks that a name no queue has is unknown. The query counting moves into
a small helper, which keeps windows_jobs_reach_the_spooler under the
cognitive-complexity limit.

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-10 00:03:35 +01:00
robertobulltechandrobertobulltech 92451193ba fix(print): honor DocumentDuplex-only Windows drivers (#411)
* fix(print): honor DocumentDuplex-only Windows drivers (#5130)

* fix(print): select duplex scope by two-sided options (#5130)

* docs(print): clarify duplex ticket selection and validation

* fix(print): select duplex scope for the requested option

* fix(print): require standard namespace for duplex options

* docs(print): document duplex regression

* docs(print): describe both offered duplex scopes

---------

Co-authored-by: robertobulltech <341520377+robertobulltech@users.noreply.github.com>
2026-11-09 23:48:52 +01:00
Zhihui Song 7ee35a9fbd chore(print): refresh internal winprint pin after bounded stream test repair 2026-11-08 19:07:09 +08:00
Zhihui Song e6489d9226 print: preserve the public GDI dependency identity while updating the PDF loader 2026-11-08 11:05:10 +08:00
Zhihui Song 45b7ededd9 Merge main after #605 and adopt the reviewed Windows stream test repairs 2026-11-08 10:29:10 +08:00
058b047760 print: winprint 64e7afd4, whose Direct2D factory is multi-threaded (#605)
Windows.Data.Pdf draws a page on several of its own worker threads, which
share the print control's device context. With winprint 5f80b9b's
single-threaded factory Direct2D takes no locks, so those threads race in
d2d1.dll and the app closes while printing, most often on pages with Type 3
fonts (storytold/pdfcraft#5006, storytold/pdfcraft#2684).
storytold/winprint.rs#11 made the factory multi-threaded; it was merged as
64e7afd4.

craft-winprint-gdi moves to the same revision, so one checkout of
winprint.rs serves both; crates/gdi is unchanged between 417ac3c and
64e7afd4.

Co-authored-by: mertan-wq <235487900+mertan-wq@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 19:42:38 -06:00
Zhihui Song 93d7c7b57a print: adopt on-demand file loading without whole-job buffering 2026-11-07 15:06:10 +08:00
Zhihui Song e398084b63 print: take stream loading alongside the multithreaded Direct2D fix 2026-11-07 14:44:13 +08:00
ashandClaude Opus 5.5 a3e0b5a944 craft-print: a job can be cancelled until it starts reaching the spooler (#622)
* craft-print: a job can be cancelled until it starts reaching the spooler

On Windows a job asks the printer's driver for its capabilities before
anything is sent. A networked printer in power save can hold that query
for a long time, and an app had no way to give up on the job without
risking it printing later (storytold/wordcraft#5710; CodeRabbit on
storytold/wordcraft#5732).

A Cancel token, passed to the new submit_cancellable, moves a job from
pending to cancelled or to sending. The job checks it at the last point
before anything reaches the spooler: on Windows after the driver has
answered, before the job file is written; on macOS and Linux before lp
starts. A cancelled job returns an error and is never sent; a job already
being sent completes. submit and submit_with_progress are unchanged, and
Error keeps its one variant so callers that match on it still compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-print: a job turns to sending with the provider held; the job file waits for it

Review: marked as sending before it took the PrintTicket provider, a job
could then wait behind another job's driver call that a sleeping printer
held, and an app that waits only for jobs being sent would wait on it.
The job now turns to sending only once it holds the provider, right
before printing, and writes its file only after that, so a cancelled job
leaves no copy of the document behind.

A test-only hold in the driver call lets the Windows spooler test cancel
a job while its driver doesn't answer: the cancel wins and, once the
driver answers, the job stops instead of reaching the paused queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-print: the DEVMODE conversion comes before a job turns to sending

CodeRabbit on #622: winprint converts the ticket to a DEVMODE, a driver
call a sleeping printer can stall, before it creates the native job, so
a job stalled there had already turned to sending and couldn't be
cancelled. The conversion now runs first, with the provider held, while
the job can still be cancelled; the provider stays held until the first
copy's own conversion, so no other job comes between them.

Tests: the Windows spooler test also cancels a job held in that
conversion; the CUPS test gives a spooler that can't start, so any
attempt to start it would change the error. README: cancellation in the
progress section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-print: clarify cancellation during winprint conversion repeat

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 21:32:35 -05:00
arnav-hiwarkarandClaude Opus 5.5 81c2488a09 craft-print: document spooler_list
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 05:07:25 +05:30