PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
#570: declare PMv2 DPI awareness in manifest (#725)
cyfung10314125e4138b4b
diff --git a/apps/pdfcraft/build.rs b/apps/pdfcraft/build.rsindex 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.rsindex 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.rsnew file mode 100644index 000000000..8c5c8a7fd--- /dev/null+++ b/apps/pdfcraft/src/windows_manifest.rs@@ -0,0 +1,34 @@+pub(crate) const WINDOWS_MANIFEST: &str = r#"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">+ <asmv3:application>+ <asmv3:windowsSettings>+ <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>+ <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>+ </asmv3:windowsSettings>+ </asmv3:application>+</assembly>+"#;++#[cfg(test)]+mod tests {+ use super::WINDOWS_MANIFEST;++ #[test]+ fn declares_per_monitor_v2_with_per_monitor_fallback() {+ assert!(+ WINDOWS_MANIFEST+ .contains("<dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">PerMonitorV2, PerMonitor</dpiAwareness>")+ );+ }++ #[test]+ fn legacy_declaration_is_per_monitor_aware() {+ assert!(WINDOWS_MANIFEST.contains("<dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true/pm</dpiAware>"));+ }++ #[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)"));+ }+}