From 4125e4138b4b5a4944ffb408280dd09552e049f2 Mon Sep 17 00:00:00 2001
From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com>
Date: Sat, 10 Oct 2026 19:12:25 +0900
Subject: [PATCH] #570: declare PMv2 DPI awareness in manifest (#725)
---
apps/pdfcraft/build.rs | 5 ++++
apps/pdfcraft/src/main.rs | 3 +++
apps/pdfcraft/src/windows_manifest.rs | 34 +++++++++++++++++++++++++++
3 files changed, 42 insertions(+)
create mode 100644 apps/pdfcraft/src/windows_manifest.rs
diff --git a/apps/pdfcraft/build.rs b/apps/pdfcraft/build.rs
index df73faa2a..2f61ed5c7 100644
--- a/apps/pdfcraft/build.rs
+++ b/apps/pdfcraft/build.rs
@@ -5,15 +5,20 @@
//! cross-compile from macOS or Linux still links, unless `PDFCRAFT_REQUIRE_WINRES=1` turns it
//! into an error (for release builds).
+#[path = "src/windows_manifest.rs"]
+mod windows_manifest;
+
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=../../assets/app-icon/pdfcraft.ico");
+ println!("cargo:rerun-if-changed=src/windows_manifest.rs");
println!("cargo:rerun-if-env-changed=PDFCRAFT_REQUIRE_WINRES");
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
return;
}
let mut res = winresource::WindowsResource::new();
res.set_icon("../../assets/app-icon/pdfcraft.ico")
+ .set_manifest(windows_manifest::WINDOWS_MANIFEST)
.set("ProductName", "PdfCraft")
.set("FileDescription", "PdfCraft PDF workbench")
.set("LegalCopyright", "Copyright (c) the PdfCraft contributors. MIT OR Apache-2.0.")
diff --git a/apps/pdfcraft/src/main.rs b/apps/pdfcraft/src/main.rs
index 74c03e367..4ce5ee668 100644
--- a/apps/pdfcraft/src/main.rs
+++ b/apps/pdfcraft/src/main.rs
@@ -29,6 +29,9 @@ use pdfcraft_ui_egui::PdfCraftApp;
mod apple_events;
mod logging;
mod updates;
+#[cfg(test)]
+#[path = "windows_manifest.rs"]
+mod windows_manifest;
/// Freedesktop app id: the `.desktop` file name and the hicolor icon name.
const APP_ID: &str = "ai.storyteller.pdfcraft";
diff --git a/apps/pdfcraft/src/windows_manifest.rs b/apps/pdfcraft/src/windows_manifest.rs
new file mode 100644
index 000000000..8c5c8a7fd
--- /dev/null
+++ b/apps/pdfcraft/src/windows_manifest.rs
@@ -0,0 +1,34 @@
+pub(crate) const WINDOWS_MANIFEST: &str = r#"
+
+
+
+ true/pm
+ PerMonitorV2, PerMonitor
+
+
+
+"#;
+
+#[cfg(test)]
+mod tests {
+ use super::WINDOWS_MANIFEST;
+
+ #[test]
+ fn declares_per_monitor_v2_with_per_monitor_fallback() {
+ assert!(
+ WINDOWS_MANIFEST
+ .contains("PerMonitorV2, PerMonitor")
+ );
+ }
+
+ #[test]
+ fn legacy_declaration_is_per_monitor_aware() {
+ assert!(WINDOWS_MANIFEST.contains("true/pm"));
+ }
+
+ #[test]
+ fn windows_resource_build_script_embeds_this_manifest() {
+ let build_script = include_str!("../build.rs");
+ assert!(build_script.contains("set_manifest(windows_manifest::WINDOWS_MANIFEST)"));
+ }
+}