Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
pkg-config libxkbcommon-dev libwayland-dev libx11-dev libxcursor-dev \
pkg-config libxkbcommon-dev libxkbcommon-x11-0 libwayland-dev libx11-dev libxcursor-dev \
libxrandr-dev libxi-dev libgl1-mesa-dev xvfb xdotool

- name: Formatting
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ cargo test
Linux needs the usual winit build dependencies:

```sh
sudo apt install pkg-config libxkbcommon-dev libwayland-dev libx11-dev \
sudo apt install pkg-config libxkbcommon-dev libxkbcommon-x11-0 libwayland-dev libx11-dev \
libxcursor-dev libxrandr-dev libxi-dev libgl1-mesa-dev
```

Expand Down
9 changes: 8 additions & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ use std::time::{Duration, Instant};

#[cfg(any(not(windows), test))]
use enigo::Coordinate;
use enigo::{Button, Direction, Enigo, InputResult, Mouse, Settings as EnigoSettings};
#[cfg(target_os = "linux")]
use enigo::Settings as EnigoSettings;
use enigo::{Button, Direction, Enigo, InputResult, Mouse};

use crate::config::{ClickStyle, JitterMode, MouseButton, PositionMode, Settings, TimingMode};

Expand Down Expand Up @@ -236,12 +238,14 @@ fn snapshot(settings: &Settings) -> Settings {
/// Display name that is not a parseable X11 display and not a Wayland socket.
/// Passing it forces that one backend to fail immediately, so the other is
/// the only connection enigo keeps.
#[cfg(any(target_os = "linux", test))]
const ISOLATED_DISPLAY: &str = "featherclick-no-display";

/// One attempt to open an input connection.
///
/// `None` leaves that server to the environment. `Some` forces the name enigo
/// will try, which is how a backend is kept out of the connection.
#[cfg(any(target_os = "linux", test))]
struct BackendAttempt {
wayland_display: Option<String>,
x11_display: Option<String>,
Expand Down Expand Up @@ -270,6 +274,9 @@ fn backend_attempts(wayland_is_set: bool) -> Vec<BackendAttempt> {
attempts
}

/// Only the Linux X11 pointer fallback opens a connection with forced
/// display names; other platforms connect through `crate::input`.
#[cfg(target_os = "linux")]
fn enigo_settings(attempt: &BackendAttempt) -> EnigoSettings {
EnigoSettings {
// Every extra millisecond of per-event delay is a millisecond off the
Expand Down
9 changes: 5 additions & 4 deletions tests/own_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn xdotool(display: &str, args: &[&str]) -> std::process::Output {
.unwrap_or_else(|err| panic!("xdotool {args:?} failed to start: {err}"))
}

fn search_window(display: &str) -> String {
fn search_window(display: &str, gui: &Gui) -> String {
let output = Command::new("timeout")
.args([
"15",
Expand All @@ -143,7 +143,8 @@ fn search_window(display: &str) -> String {
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
output.status.success(),
"FeatherClick window did not appear\n{stdout}{stderr}"
"FeatherClick window did not appear\n{stdout}{stderr}\n{}",
gui.output()
);
let mut best_area = i64::MIN;
let mut best_id = None;
Expand Down Expand Up @@ -494,7 +495,7 @@ fn pointer_mode_waits_on_the_window_then_clicks_where_the_pointer_moves() {
compile_catcher(&scratch.catcher_bin);

let mut gui = Gui::spawn(&display.name, &scratch.home);
let id = search_window(&display.name);
let id = search_window(&display.name, &gui);
assert!(
gui.alive(),
"featherclick exited before the test\n{}",
Expand Down Expand Up @@ -586,7 +587,7 @@ fn fixed_point_away_from_the_window_still_receives_clicks() {
compile_catcher(&scratch.catcher_bin);

let gui = Gui::spawn(&display.name, &scratch.home);
let id = search_window(&display.name);
let id = search_window(&display.name, &gui);
window_move(&display.name, &id, 40, 40);
thread::sleep(Duration::from_millis(200));
let window = geometry(&display.name, &id);
Expand Down
Loading