diff --git a/.changes/linux-libxdo-feature-flag.md b/.changes/linux-libxdo-feature-flag.md new file mode 100644 index 0000000..0b06b30 --- /dev/null +++ b/.changes/linux-libxdo-feature-flag.md @@ -0,0 +1,5 @@ +--- +"muda": "minor" +--- + +Add `libxdo` feature flag, enabled by default, to control whether to link `libxdo` on Linux or not. diff --git a/Cargo.toml b/Cargo.toml index 806f489..ca62584 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,10 @@ repository = "https://github.com/amrbashir/muda" documentation = "https://docs.rs/muda" categories = [ "gui" ] +[features] +default = [ "libxdo" ] +libxdo = [ "dep:libxdo" ] + [dependencies] crossbeam-channel = "0.5" keyboard-types = "0.6" @@ -32,7 +36,7 @@ features = [ gtk = "0.16" gdk = "0.16" gdk-pixbuf = "0.16" -libxdo = "0.6.0" +libxdo = { version = "0.6.0", optional = true } [target."cfg(target_os = \"macos\")".dependencies] cocoa = "0.24" diff --git a/README.md b/README.md index ad4cd14..3895641 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ muda is a Menu Utilities library for Desktop Applications. [`TranslateAcceleratorW`](https://docs.rs/windows-sys/latest/windows_sys/Win32/UI/WindowsAndMessaging/fn.TranslateAcceleratorW.html). See [`Menu::init_for_hwnd`](https://docs.rs/muda/latest/muda/struct.Menu.html#method.init_for_hwnd) for more details +### Cargo Features + +- `libxdo` (enabled by default): Enables linking to `libxdo` which is used for the predfined `Copy`, `Cut`, `Paste` and `SelectAll` menu item. + ## Dependencies (Linux Only) `gtk` is used for menus and `libxdo` is used to make the predfined `Copy`, `Cut`, `Paste` and `SelectAll` menu items work. Be sure to install following packages before building: diff --git a/src/platform_impl/gtk/mod.rs b/src/platform_impl/gtk/mod.rs index c670ff0..914cd0d 100644 --- a/src/platform_impl/gtk/mod.rs +++ b/src/platform_impl/gtk/mod.rs @@ -946,6 +946,7 @@ impl PredefinedMenuItem { .set_accel(key, mods); item.connect_activate(move |_| { // TODO: wayland + #[cfg(feature = "libxdo")] if let Ok(xdo) = libxdo::XDo::new(None) { let _ = xdo.send_keysequence(predefined_item_type.xdo_keys(), 0); }