Skip to content

Commit

Permalink
Merge pull request #273 from pentamassiv/libei
Browse files Browse the repository at this point in the history
Add experimental libei support
  • Loading branch information
pentamassiv authored Apr 17, 2024
2 parents fb59ea7 + 203d67e commit efb5676
Show file tree
Hide file tree
Showing 8 changed files with 851 additions and 41 deletions.
64 changes: 35 additions & 29 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,35 @@ jobs:
rust:
- stable
- nightly
- "1.71.0"
- "1.75.0"
platform:
- ubuntu-latest
- windows-latest
- macos-latest
features:
- default
- default,serde
- wayland
- xdo
- x11rb
- "--all-features"
- "--features default"
- "--features libei"
- "--features wayland"
- "--features xdo"
- "--features x11rb"
exclude:
- platform: windows-latest
features: "--features libei"
- platform: windows-latest
features: "--features wayland"
- platform: windows-latest
features: "--features xdo"
- platform: windows-latest
features: "--features x11rb"
- platform: macos-latest
features: "--features libei"
- platform: macos-latest
features: "--features wayland"
- platform: macos-latest
features: "--features xdo"
- platform: macos-latest
features: "--features x11rb"
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
Expand All @@ -44,46 +62,34 @@ jobs:
run: cargo fmt -- --check

- name: Check clippy lints
run: cargo clippy --all-targets --all-features -- -D clippy::pedantic
run: cargo clippy --no-default-features ${{ matrix.features }} -- -D clippy::pedantic
- name: Check clippy lints for the examples
run: cargo clippy --all-targets --all-features --examples -- -D clippy::pedantic
run: cargo clippy --no-default-features ${{ matrix.features }} --examples -- -D clippy::pedantic

- name: Build the code
run: cargo build --no-default-features --features ${{ matrix.features }}
- name: Build the code with all features enabled
run: cargo build --all-features
run: cargo build --no-default-features ${{ matrix.features }}

- name: Build the docs
run: cargo doc --no-deps --no-default-features --features ${{ matrix.features }}
- name: Build the docs with all features enabled
run: cargo doc --no-deps --all-features
run: cargo doc --no-deps --no-default-features ${{ matrix.features }}

- name: Build the examples
run: cargo check --examples --no-default-features --features ${{ matrix.features }}
- name: Build the examples with all features enabled
run: cargo check --examples --all-features
run: cargo check --examples --no-default-features ${{ matrix.features }}

- name: Build the examples in release mode
run: cargo check --release --examples --no-default-features --features ${{ matrix.features }}
- name: Build the examples in release mode with all features enabled
run: cargo check --release --examples --all-features
run: cargo check --release --examples --no-default-features ${{ matrix.features }}

- name: Test the code
run: cargo test --no-default-features --features ${{ matrix.features }}
- name: Test the code with all features enabled
run: cargo test --all-features
run: cargo test --no-default-features ${{ matrix.features }}

- name: Test the code in release mode
run: cargo test --release --no-default-features --features ${{ matrix.features }}
- name: Test the code in release mode with all features enabled
run: cargo test --release --all-features
run: cargo test --release --no-default-features ${{ matrix.features }}

- name: Setup headless display for integration tests
if: runner.os == 'Linux' # The integration tests only work on Linux right now
uses: ./.github/actions/headless_display
- name: Run integration tests
if: runner.os == 'Linux' # The integration tests only work on Linux right now
run: cargo test --all-features -- --include-ignored --nocapture
if: runner.os == 'Linux' && matrix.features == 'xdo' # The integration tests only work on Linux and x11 right now
run: cargo test --no-default-features ${{ matrix.features }} -- --include-ignored --nocapture

- name: Install Miri
if: matrix.rust == 'nightly' # Miri only works on Nightly
Expand All @@ -94,4 +100,4 @@ jobs:
cargo miri setup
- name: Run Miri to check unsafe code
if: matrix.rust == 'nightly' # Miri only works on Nightly
run: cargo miri test --verbose --all-features
run: cargo miri test --verbose --no-default-features ${{ matrix.features }}
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Changed
- All: A new Enigo struct is now always created with some settings
- Rust: MSRV is 1.71
- Rust: MSRV is 1.75
- All held keys are released when Enigo is dropped
- win: Don't panic if it was not possible to move the mouse
- All: Never panic! All functions return Results now
Expand All @@ -20,6 +20,7 @@
- DSL: The DSL was removed and replaced with the `Agent` trait. Activate the `serde` feature to use it. Have a look at the `serde` example to get an idea how to use it

## Added
- Linux: Partial support for `libei` was added. Use the experimental feature `libei` to test it. This works on GNOME 46 and above. Entering text often simulates the wrong characters.
- Linux: Support X11 without `xdotools`. Use the experimental feature `x11rb` to test it
- Linux: Partial support for Wayland was added. Use the experimental feature `wayland` to test it. Only the virtual_keyboard and input_method protocol can be used. This is not going to work on GNOME, but should work for example with phosh
- Linux: Added `MicMute` key to enter `XF86_AudioMicMute` keysym
Expand Down
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
"Dustin Bensing <[email protected]>",
]
edition = "2021"
rust-version = "1.71"
rust-version = "1.75"
description = "Cross-platform (Linux, Windows & macOS) library to simulate keyboard and mouse events"
documentation = "https://docs.rs/enigo/"
homepage = "https://github.com/enigo-rs/enigo"
Expand All @@ -27,7 +27,8 @@ exclude = [".github", "examples", ".gitignore", "rustfmt.toml"]
all-features = true

[features]
default = ["xdo"]
default = ["libei"]
libei = ["dep:reis", "dep:ashpd", "dep:pollster", "dep:once_cell"]
serde = ["dep:serde"]
wayland = [
"dep:wayland-client",
Expand Down Expand Up @@ -59,6 +60,10 @@ foreign-types-shared = "0.3"

[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
libc = "0.2"
reis = { version = "0.2.0", optional = true }
ashpd = { version = "0.8.1", optional = true }
pollster = { version = "0.3.0", optional = true }
once_cell = { version = "1.19.0", optional = true }
wayland-protocols-misc = { version = "0.2", features = [
"client",
], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Docs](https://docs.rs/enigo/badge.svg)](https://docs.rs/enigo)
[![Dependency status](https://deps.rs/repo/github/enigo-rs/enigo/status.svg)](https://deps.rs/repo/github/enigo-rs/enigo)

![Rust version](https://img.shields.io/badge/rust--version-1.71+-brightgreen.svg)
![Rust version](https://img.shields.io/badge/rust--version-1.75+-brightgreen.svg)
[![Crates.io](https://img.shields.io/crates/v/enigo.svg)](https://crates.io/crates/enigo)

# enigo
Expand Down
8 changes: 4 additions & 4 deletions src/keycodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ impl TryFrom<Key> for windows::Win32::UI::Input::KeyboardAndMouse::VIRTUAL_KEY {
}

#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(any(feature = "wayland", feature = "x11rb"))]
#[cfg(any(feature = "wayland", feature = "x11rb", feature = "libei"))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) enum Modifier {
Expand All @@ -1043,7 +1043,7 @@ pub(crate) enum Modifier {
}

#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(any(feature = "wayland", feature = "x11rb"))]
#[cfg(any(feature = "wayland", feature = "x11rb", feature = "libei"))]
impl Modifier {
/// Returns the bitflag of the modifier that is usually associated with it
/// on Linux
Expand Down Expand Up @@ -1079,7 +1079,7 @@ impl Modifier {
}

#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(any(feature = "wayland", feature = "x11rb"))]
#[cfg(any(feature = "wayland", feature = "x11rb", feature = "libei"))]
/// Converts a Key to a modifier
impl TryFrom<Key> for Modifier {
type Error = &'static str;
Expand All @@ -1101,5 +1101,5 @@ impl TryFrom<Key> for Modifier {
}

#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(any(feature = "wayland", feature = "x11rb"))]
#[cfg(any(feature = "wayland", feature = "x11rb", feature = "libei"))]
pub(crate) type ModifierBitflag = u32;
Loading

0 comments on commit efb5676

Please sign in to comment.