feat: add libxdo feature flag (#67)

* feat: add `libxdo` feature flag

* Update .changes/linux-libxdo-feature-flag.md
This commit is contained in:
Amr Bashir 2023-06-19 20:59:10 +03:00 committed by GitHub
parent 6e59ec71f6
commit 7af4477896
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"muda": "minor"
---
Add `libxdo` feature flag, enabled by default, to control whether to link `libxdo` on Linux or not.

View file

@ -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"

View file

@ -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:

View file

@ -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);
}