From 7d2f344d4541588b482797d820d28c32947ab7d4 Mon Sep 17 00:00:00 2001 From: nabbisen Date: Mon, 10 Aug 2026 16:52:52 +0900 Subject: [PATCH] feat(desktop): make libxdo opt-in on Linux via `linux-libxdo` `libxdo` is a default feature of both `muda` and `tray-icon`, so every Dioxus desktop app links `libxdo.so` whether or not it uses menus. muda documents the feature as existing solely to make the predefined Copy, Cut, Paste and SelectAll menu items work on Linux. Because the soname is recorded at link time, a binary built on Ubuntu (libxdo.so.3) will not start on a distro shipping libxdo 4, even with xdotool installed. That makes prebuilt Linux artifacts non-portable for a library most apps never call. Disables default features on both crates, keeps `gtk` (which is what renders menus and tray icons on Linux), and adds an opt-in `linux-libxdo` feature for apps that do use the predefined items. Mirrors tauri's `linux-libxdo`, which resolves this the same way. Verified: libxdo is absent from the dependency graph by default and restored by `--features linux-libxdo`. --- Cargo.toml | 9 +++++++-- packages/desktop/Cargo.toml | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 03979fcee2..e385fc9438 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -346,12 +346,17 @@ tao = { version = "0.35.2", features = ["rwh_05"] } infer = "0.19.0" dunce = "1.0.5" percent-encoding = "2.3.2" -muda = "0.19.1" +# `libxdo` is a default feature of both `muda` and `tray-icon`. It is only used +# to make the predefined Copy/Cut/Paste/SelectAll menu items work on Linux, but +# enabling it links `libxdo.so` unconditionally into every Dioxus desktop app. +# Opt in via the `dioxus-desktop/linux-libxdo` feature instead. `gtk` is kept — +# it is what actually renders menus and tray icons on Linux. +muda = { version = "0.19.1", default-features = false, features = ["gtk"] } objc2 = { version = "0.6.4", features = ["exception"] } objc2-foundation = { version = "0.3.2", default-features = false } objc2-ui-kit = { version = "0.3.2", default-features = false } objc2-app-kit = { version = "0.3.2", default-features = false } -tray-icon = "0.24.0" +tray-icon = { version = "0.24.0", default-features = false, features = ["gtk"] } open = "5.3.5" webbrowser = "1.2.1" diff --git a/packages/desktop/Cargo.toml b/packages/desktop/Cargo.toml index 44ed73c71c..8c3c706ca4 100644 --- a/packages/desktop/Cargo.toml +++ b/packages/desktop/Cargo.toml @@ -100,6 +100,10 @@ fullscreen = ["wry/fullscreen"] devtools = ["wry/devtools", "dep:dioxus-devtools", "dioxus-signals"] transparent = ["wry/transparent"] gnu = [] +# Links `libxdo.so` on Linux, required only for the predefined Copy, Cut, Paste +# and SelectAll menu items. Off by default so apps that do not use them are not +# tied to the build machine's libxdo soname. Mirrors Tauri's `linux-libxdo`. +linux-libxdo = ["muda/libxdo", "tray-icon/libxdo"] [package.metadata.docs.rs] features = ["tokio_runtime", "devtools"]