GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: conditionally enable UIAccess in manifest
Lars Berger1d29cc2f87d2
diff --git a/packages/wm/Cargo.toml b/packages/wm/Cargo.tomlindex 2e11d7d1..4ccd8a30 100644--- a/packages/wm/Cargo.toml+++ b/packages/wm/Cargo.toml@@ -16,6 +16,7 @@ path = "src\\main.rs"[features]no_console = []+ui_access = [][build-dependencies]tauri-winres = { workspace = true }diff --git a/packages/wm/build.rs b/packages/wm/build.rsindex b2340b04..70d031e6 100644--- a/packages/wm/build.rs+++ b/packages/wm/build.rs@@ -2,13 +2,28 @@ fn main() {let mut res = tauri_winres::WindowsResource::new();res.set_icon("../../resources/icon.ico");- // Enable UIAccess, which grants privilege to set the foreground window- // and to set the position of elevated windows.+ // When the `ui_access` feature is enabled, the `uiAccess` attribute is+ // set to `true`. UIAccess is disabled by default because it requires the+ // application to be signed and installed in a secure location.+ let ui_access = {+ #[cfg(feature = "ui_access")]+ {+ "true"+ }+ #[cfg(not(feature = "ui_access"))]+ {+ "false"+ }+ };++ // Conditionally enable UIAccess, which grants privilege to set the+ // foreground window and to set the position of elevated windows.//// Ref: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/user-account-control-only-elevate-uiaccess-applications-that-are-installed-in-secure-locations//- // Declare support for per-monitor DPI awareness.- let manifest_str = r#"+ // Additionally, declare support for per-monitor DPI awareness.+ let manifest_str = format!(+ r#"<assemblyxmlns="urn:schemas-microsoft-com:asm.v1"manifestVersion="1.0"@@ -17,7 +32,7 @@ fn main() {<asmv3:trustInfo><security><requestedPrivileges>- <requestedExecutionLevel level="asInvoker" uiAccess="false" />+ <requestedExecutionLevel level="asInvoker" uiAccess="{}" /></requestedPrivileges></security></asmv3:trustInfo>@@ -32,8 +47,10 @@ fn main() {</windowsSettings></asmv3:application></assembly>-"#;+"#,+ ui_access+ );- res.set_manifest(manifest_str);+ res.set_manifest(&manifest_str);res.compile().unwrap();}diff --git a/resources/scripts/package.ps1 b/resources/scripts/package.ps1index b3cb2f82..67ed567a 100644--- a/resources/scripts/package.ps1+++ b/resources/scripts/package.ps1@@ -25,11 +25,11 @@ foreach ($target in $rustTargets) {New-Item -ItemType Directory -Force -Path "out/$outDir/noconsole", "out/$outDir/console"Write-Output "Building for $target (windows subsystem)"- cargo build --locked --release --target $target --features no_console+ cargo build --locked --release --target $target --features no_console,ui_accessMove-Item -Path "$sourceDir/wm.exe", "$sourceDir/watcher.exe" -Destination "out/$outDir/noconsole"Write-Output "Building for $target (console subsystem)"- cargo build --locked --release --target $target+ cargo build --locked --release --target $target --features ui_accessMove-Item -Path "$sourceDir/wm.exe", "$sourceDir/watcher.exe" -Destination "out/$outDir/console"}