Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: replace use of `embedded-resource` crate with `tauri-winres`

Lars Berger25a4ed0bf0d3
diff --git a/Cargo.lock b/Cargo.lock
index 48f0bcee..790cdc6e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -437,7 +437,7 @@ dependencies = [
"cc",
"memchr",
"rustc_version",
- "toml",
+ "toml 0.8.2",
"vswhom",
"winreg",
]
@@ -1594,7 +1594,7 @@ dependencies = [
"cfg-expr",
"heck 0.5.0",
"pkg-config",
- "toml",
+ "toml 0.8.2",
"version-compare",
]
@@ -1604,6 +1604,16 @@ version = "0.12.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
+[[package]]
+name = "tauri-winres"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5993dc129e544393574288923d1ec447c857f3f644187f4fbf7d9a875fbfc4fb"
+dependencies = [
+ "embed-resource",
+ "toml 0.7.8",
+]
+
[[package]]
name = "thiserror"
version = "1.0.61"
@@ -1722,6 +1732,18 @@ dependencies = [
"tungstenite",
]
+[[package]]
+name = "toml"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
+dependencies = [
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_edit 0.19.15",
+]
+
[[package]]
name = "toml"
version = "0.8.2"
@@ -1750,6 +1772,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
+ "serde",
+ "serde_spanned",
"toml_datetime",
"winnow",
]
@@ -1999,8 +2023,8 @@ name = "watcher"
version = "0.0.0"
dependencies = [
"anyhow",
- "embed-resource",
"serde_json",
+ "tauri-winres",
"tokio",
"tracing",
"tracing-subscriber",
@@ -2236,7 +2260,6 @@ version = "0.0.0"
dependencies = [
"anyhow",
"clap",
- "embed-resource",
"enum-as-inner",
"enum_dispatch",
"futures-util",
@@ -2245,6 +2268,7 @@ dependencies = [
"serde",
"serde_json",
"serde_yaml",
+ "tauri-winres",
"tokio",
"tokio-tungstenite",
"tracing",
diff --git a/Cargo.toml b/Cargo.toml
index 43b90b56..51c019f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,8 +5,8 @@ default-members = ["packages/wm", "packages/watcher"]
[workspace.dependencies]
anyhow = { version = "1", features = ["backtrace"] }
-embed-resource = "2"
serde_json = { version = "1", features = ["raw_value"] }
tokio = { version = "1", features = ["full"] }
+tauri-winres = "0.1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
diff --git a/packages/watcher/Cargo.toml b/packages/watcher/Cargo.toml
index c4d8df9d..dd5bd356 100644
--- a/packages/watcher/Cargo.toml
+++ b/packages/watcher/Cargo.toml
@@ -8,7 +8,7 @@ name = "watcher"
path = "src/main.rs"
[build-dependencies]
-embed-resource = { workspace = true }
+tauri-winres = { workspace = true }
[dependencies]
wm = { path = "../wm" }
diff --git a/packages/watcher/build.rs b/packages/watcher/build.rs
index 22a500d1..4cd1b088 100644
--- a/packages/watcher/build.rs
+++ b/packages/watcher/build.rs
@@ -1,3 +1,5 @@
fn main() {
- embed_resource::compile("resources/watcher.rc", embed_resource::NONE);
+ let mut res = tauri_winres::WindowsResource::new();
+ res.set_icon("../../resources/icon.ico");
+ res.compile().unwrap();
}
diff --git a/packages/watcher/resources/watcher.rc b/packages/watcher/resources/watcher.rc
deleted file mode 100644
index 6961ba6b..00000000
--- a/packages/watcher/resources/watcher.rc
+++ /dev/null
@@ -1,3 +0,0 @@
-#define IDI_ICON 0x101
-
-IDI_ICON ICON "../../resources/icon.ico"
diff --git a/packages/wm/Cargo.toml b/packages/wm/Cargo.toml
index 89950e15..2e11d7d1 100644
--- a/packages/wm/Cargo.toml
+++ b/packages/wm/Cargo.toml
@@ -18,7 +18,7 @@ path = "src\\main.rs"
no_console = []
[build-dependencies]
-embed-resource = { workspace = true }
+tauri-winres = { workspace = true }
[dependencies]
anyhow = { workspace = true }
diff --git a/packages/wm/build.rs b/packages/wm/build.rs
index 3ca61343..b2340b04 100644
--- a/packages/wm/build.rs
+++ b/packages/wm/build.rs
@@ -1,3 +1,39 @@
fn main() {
- embed_resource::compile("resources/wm.rc", embed_resource::NONE);
+ 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.
+ //
+ // 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#"
+<assembly
+ xmlns="urn:schemas-microsoft-com:asm.v1"
+ manifestVersion="1.0"
+ xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
+>
+ <asmv3:trustInfo>
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level="asInvoker" uiAccess="false" />
+ </requestedPrivileges>
+ </security>
+ </asmv3:trustInfo>
+
+ <asmv3:application>
+ <windowsSettings
+ xmlns:ws2005="http://schemas.microsoft.com/SMI/2005/WindowsSettings"
+ xmlns:ws2016="http://schemas.microsoft.com/SMI/2016/WindowsSettings"
+ >
+ <ws2005:dpiAware>true</ws2005:dpiAware>
+ <ws2016:dpiAwareness>PerMonitorV2</ws2016:dpiAwareness>
+ </windowsSettings>
+ </asmv3:application>
+</assembly>
+"#;
+
+ res.set_manifest(manifest_str);
+ res.compile().unwrap();
}
diff --git a/packages/wm/resources/wm.manifest b/packages/wm/resources/wm.manifest
deleted file mode 100644
index b77e285b..00000000
--- a/packages/wm/resources/wm.manifest
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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">
- <!--
- 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
- -->
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
- <security>
- <requestedPrivileges>
- <!-- <requestedExecutionLevel level="asInvoker" uiAccess="true" /> -->
- </requestedPrivileges>
- </security>
- </trustInfo>
-
- <!-- Declare support for per-monitor DPI awareness. -->
- <asmv3:application>
- <asmv3:windowsSettings>
- <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
- <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
- </asmv3:windowsSettings>
- </asmv3:application>
-</assembly>
diff --git a/packages/wm/resources/wm.rc b/packages/wm/resources/wm.rc
deleted file mode 100644
index 6ba811c6..00000000
--- a/packages/wm/resources/wm.rc
+++ /dev/null
@@ -1,8 +0,0 @@
-#define IDI_ICON 0x101
-
-IDI_ICON ICON "../../resources/icon.ico"
-
-#define RT_MANIFEST 24
-#define APP_MANIFEST 1
-
-APP_MANIFEST RT_MANIFEST wm.manifest
diff --git a/packages/wm/src/sys_tray.rs b/packages/wm/src/sys_tray.rs
index c6db01c2..b8bccd1f 100644
--- a/packages/wm/src/sys_tray.rs
+++ b/packages/wm/src/sys_tray.rs
@@ -10,8 +10,8 @@ use tray_icon::{
use crate::common::platform::Platform;
-/// Ordinal to IDI_ICON definition from `resources.rc` file.
-const IDI_ICON: u16 = 0x101;
+/// Ordinal to IDI_ICON definition in embedded resource file.
+const IDI_ICON: u16 = 32512;
pub struct SystemTray {
pub config_reload_rx: mpsc::UnboundedReceiver<()>,