Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

test(cua-driver): prune redundant Linux adapter tests (#4117)

Francesco Bonacci953828ae50b5
diff --git a/.github/workflows/ci-rust-linux.yml b/.github/workflows/ci-rust-linux.yml
index b163a43276..6eeebeeb4b 100644
--- a/.github/workflows/ci-rust-linux.yml
+++ b/.github/workflows/ci-rust-linux.yml
@@ -159,6 +159,12 @@ jobs:
cargo test -p platform-linux \
x11_overlay_owner_stays_click_through_across_cursor_lifecycle_and_randr \
--locked -- --ignored --nocapture
+ - name: Run X11 clipboard round-trip regression
+ working-directory: libs/cua-driver/rust
+ run: |
+ xvfb-run -a cargo test -p platform-linux --lib \
+ clipboard::tests::native_clipboard_round_trips_text_on_x11 \
+ --locked -- --ignored --exact --nocapture
- name: Run X11 MIT-SHM capture correctness and performance regression
working-directory: libs/cua-driver/rust
run: |
diff --git a/libs/cua-driver/docs/action-support.md b/libs/cua-driver/docs/action-support.md
index c86d1a4d2e..f66f3b00e5 100644
--- a/libs/cua-driver/docs/action-support.md
+++ b/libs/cua-driver/docs/action-support.md
@@ -77,7 +77,7 @@ are capabilities, not one uniform API.
| X11/Openbox | Exact run `29254936043` passed all 116 declared outcomes: 75 deliveries and 41 exact refusals. GTK3 AT-SPI actions and values, foreground XTest pointer/keyboard routes, capture, desktop scope, and the complete Electron/Tauri catalog all reached fixture-owned oracles. | Xvfb does not prove the real-Xorg MPX/uinput background pointer route. Toolkits that reject XSendEvent retain exact refusals. |
| Sway/wlroots | Runs `29255208927` and `29257961614` passed the complete 116 outcomes: native and capture 36/36, then shared 80/80. The Electron, Tauri, GTK3, capture, and desktop-scope catalogs use live Sway identity/geometry and external fixture oracles. | Stock Wayland cannot target raw focus-bound input at an occluded surface. Those rows retain exact refusals; another wlroots compositor is not assumed equivalent until a material divergence is reported and tested. Exact cursor preservation remains unproven and is tracked in [issue #2194](https://github.com/trycua/cua/issues/2194). |
| GNOME/Mutter | A real GNOME 46 Wayland run passed the full GTK3 matrix, 31/31. The WinRects helper supplies stable window ids, frame and buffer geometry, stacking, verified activation, stage capture, and the compositor cursor. AT-SPI handles semantic actions; persistent portal/libei sessions deliver foreground PX click, right/double click, drag, scroll, type, key, and hotkey. Background rows either deliver through AT-SPI with focus and leak guards or return the declared exact refusal. | The helper requires installation plus one Shell-session restart. Without it, target-bound foreground input refuses. Portal video and a shared Electron/Tauri GNOME run remain open. |
-| KDE/KWin | A Plasma 6 Wayland session has a live-validated Cua-owned native KWin identity adapter: trusted in-process helper, opaque KWin-lifetime tokens, PID/geometry correlation, active/minimized metadata, and live-window token pruning. | Raw target-addressed keyboard and pointer actions are intentionally refused. KWin portal/libei delivery is focus-bound, so activation plus read-back cannot prevent focus changing before compositor EIS processing. Delivery remains disabled until a KWin input path binds the mutation itself to the target token/window. The ABI-specific helper remains optional and is currently obtained by a host build. |
+| KDE/KWin | A Plasma 6 Wayland session has a live-validated Cua-owned native KWin identity adapter: trusted in-process helper, opaque KWin-lifetime tokens, exact PID-and-token window lookup, active/minimized metadata, and live-window token pruning. | Raw target-addressed keyboard and pointer actions are intentionally refused. KWin portal/libei delivery is focus-bound, so activation plus read-back cannot prevent focus changing before compositor EIS processing. Delivery remains disabled until a KWin input path binds the mutation itself to the target token/window. The ABI-specific helper remains optional and is currently obtained by a host build. |
| Nested `cua-compositor` | The optional backend owns its nested session and is covered by typed shared, native, and capture catalogs. Run `29197643541` passed native GTK3 31/31; run `29197887387` passed capture/scope 5/5. Full shared run `29199596935` passed 26/36 Electron rows before the occluded-subtree and wheel-frame repairs. | The lane remains experimental. The accepted full shared run still has 10 failures; focused replacement runs reduce that set but do not promote the environment. Unicode text and a canonical parallel-drag row remain unproven. This private route is not evidence of a stock-Wayland capability. |
PX background left-click rows may resolve the screen point to an actionable
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/atspi/cache.rs b/libs/cua-driver/rust/crates/platform-linux/src/atspi/cache.rs
index defdcc8475..a0c4d5fec1 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/atspi/cache.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/atspi/cache.rs
@@ -176,12 +176,6 @@ pub(crate) fn hit_test(pid: u32, xid: u64, sx: i32, sy: i32) -> Option<(usize, C
Some((*idx, element.clone()))
}
-/// Drop every side-index snapshot for `pid` (e.g. after the process exited).
-#[allow(dead_code)]
-pub(crate) fn forget_pid(pid: u32) {
- store().lock().unwrap().retain(|key, _| key.pid != pid);
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -318,34 +312,6 @@ mod tests {
));
}
- #[test]
- fn compositor_window_ids_do_not_alias_their_low_bits() {
- let cache = ElementCache::new();
- let window = (1_u64 << 40) | 7;
- let low = cache.publish(42, 7, CachedSnapshot::from_nodes(&[node(7)]));
- let high = cache.publish(42, window, CachedSnapshot::from_nodes(&[node(11)]));
- let target = cache
- .resolve_element_args(
- 42,
- None,
- Some(&token_for(high, 11)),
- None,
- Some(window),
- "click",
- )
- .unwrap();
- assert!(
- matches!(target, ResolvedElement::Element { window_id: Some(id), element, .. } if id == window && element.identity.path == "/node/11")
- );
- assert!(cache
- .resolve_element_args(42, None, Some(&token_for(high, 11)), None, Some(7), "click")
- .is_err());
- cache.remove(42, window);
- assert!(cache
- .resolve_element_args(42, None, Some(&token_for(low, 7)), None, Some(7), "click")
- .is_ok());
- }
-
#[test]
fn empty_linux_snapshot_has_no_element_zero() {
let cache = ElementCache::new();
@@ -386,8 +352,5 @@ mod tests {
assert!(cached_element(pid, Some(78), 2).is_none());
forget_window(pid, 77);
assert!(cached_element(pid, None, 0).is_none());
- update_snapshot(pid, 77, &nodes, &[]);
- forget_pid(pid);
- assert!(cached_element(pid, None, 0).is_none());
}
}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/atspi/native.rs b/libs/cua-driver/rust/crates/platform-linux/src/atspi/native.rs
index fccd6cdcca..2d6fae1074 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/atspi/native.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/atspi/native.rs
@@ -6317,24 +6317,6 @@ mod coord_tests {
assert_eq!(selection.into_selected(), Ok(Some("live-tree")));
}
- #[test]
- fn foreign_empty_application_before_target_is_ignored() {
- let target_pid = 4242;
- let candidates = [
- (Some(9000), "foreign-empty", false),
- (Some(target_pid), "target-live-tree", true),
- ];
- let mut selection = ApplicationSelection::new(target_pid);
-
- for (pid, app, has_children) in candidates {
- if selection.matches_pid(pid) {
- selection.consider_matching(app, has_children);
- }
- }
-
- assert_eq!(selection.into_selected(), Ok(Some("target-live-tree")));
- }
-
#[test]
fn childless_exact_pid_application_remains_the_fallback() {
let mut selection = ApplicationSelection::new(4242);
@@ -6651,7 +6633,15 @@ mod coord_tests {
#[test]
fn point_hit_projection_rejects_unrealized_extents_before_offsets() {
- for raw in [(i32::MIN, 0, 40, 20), (0, i32::MIN, 40, 20), (0, 0, 1, 1)] {
+ // The -16390 rows fall below the -16384 sentinel floor only before
+ // the offsets are applied, so they fail if the check moves after them.
+ for raw in [
+ (i32::MIN, 0, 40, 20),
+ (0, i32::MIN, 40, 20),
+ (-16390, 0, 40, 20),
+ (0, -16390, 40, 20),
+ (0, 0, 1, 1),
+ ] {
assert_eq!(project_screen_extents(raw, (108, 79), Some((0, 47))), None);
}
}
@@ -6871,20 +6861,6 @@ mod coord_tests {
assert_eq!(parse_gtk_frame_extents(&[61, 61, 55]), None);
}
- #[test]
- fn screen_reconstruction_matches_live_gnome_calculator() {
- // Regression anchor for the whole GTK4 fix, from a live-verified capture:
- // gnome-calculator button "7" = x11_window_origin (55,27)
- // + _GTK_FRAME_EXTENTS inset (61,55) + atspi WINDOW coords (16,293)
- // = screen (132,375).
- let (fl, ft) = parse_gtk_frame_extents(&[61, 61, 55, 67]).unwrap();
- let origin = (55, 27); // x11_window_origin
- let window = (16, 293); // atspi CoordType::Window
- let offset = (origin.0 + fl, origin.1 + ft); // window_to_screen_offset
- let screen = (offset.0 + window.0, offset.1 + window.1);
- assert_eq!(screen, (132, 375));
- }
-
#[test]
fn plain_activation_names_are_recognised() {
for name in [
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/atspi/native/hit_test.rs b/libs/cua-driver/rust/crates/platform-linux/src/atspi/native/hit_test.rs
index ec699ffcf0..95b97aa6f8 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/atspi/native/hit_test.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/atspi/native/hit_test.rs
@@ -302,17 +302,13 @@ mod tests {
#[test]
fn no_display_is_unknown_not_an_error() {
- let prior = std::env::var_os("DISPLAY");
- std::env::set_var("DISPLAY", ":9999999");
let observed = ObjectRef {
bus: ":1.9".into(),
path: "/org/a11y/atspi/accessible/1".into(),
};
+ let display = crate::test_env::unreachable_x11_display();
let ownership = point_ownership(1, 0x1234, &observed, 10, 10);
- match prior {
- Some(v) => std::env::set_var("DISPLAY", v),
- None => std::env::remove_var("DISPLAY"),
- }
+ drop(display);
assert_eq!(ownership, PointOwnership::Unknown);
}
}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/clipboard.rs b/libs/cua-driver/rust/crates/platform-linux/src/clipboard.rs
index af0e8be551..792a79c0bb 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/clipboard.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/clipboard.rs
@@ -100,15 +100,11 @@ mod tests {
.contains("absolute"));
}
+ /// Needs an X server; CI runs it under `xvfb-run` in ci-rust-linux.yml.
#[test]
- fn native_clipboard_round_trips_text_when_ci_has_a_display() {
- if std::env::var_os("CI").is_none() {
- return;
- }
+ #[ignore = "requires an X11 display (run under xvfb-run)"]
+ fn native_clipboard_round_trips_text_on_x11() {
let backend = LinuxClipboard::new();
- if backend.available_formats().is_err() {
- return;
- }
backend
.write_text("cua-driver clipboard test".into())
.unwrap();
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/health_report.rs b/libs/cua-driver/rust/crates/platform-linux/src/health_report.rs
index d92013910f..f19300fef8 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/health_report.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/health_report.rs
@@ -663,19 +663,6 @@ mod tests {
assert_eq!(entry.status, CheckStatus::Pass);
}
- #[test]
- fn tcc_and_bundle_are_skipped_with_canonical_message() {
- for name in [
- NAME_TCC_ACCESSIBILITY,
- NAME_TCC_SCREEN_RECORDING,
- NAME_BUNDLE_IDENTITY,
- ] {
- let entry = skip_not_applicable(name);
- assert_eq!(entry.status, CheckStatus::Skip, "{name} must be skipped");
- assert_eq!(entry.message, "not applicable on Linux");
- }
- }
-
#[test]
fn wayland_backend_passes_on_non_wlroots_when_portal_libei_backend_is_reachable() {
let snap = WaylandManagers {
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/input/focus_guard.rs b/libs/cua-driver/rust/crates/platform-linux/src/input/focus_guard.rs
index 78d2959874..4e0581d9e5 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/input/focus_guard.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/input/focus_guard.rs
@@ -943,13 +943,9 @@ mod tests {
#[test]
fn capture_without_display_degrades_to_none() {
- let prior = std::env::var_os("DISPLAY");
- std::env::set_var("DISPLAY", ":9999999");
+ let display = crate::test_env::unreachable_x11_display();
let snapshot = FocusSnapshot::capture();
- match prior {
- Some(v) => std::env::set_var("DISPLAY", v),
- None => std::env::remove_var("DISPLAY"),
- }
+ drop(display);
assert!(snapshot.is_none());
}
}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/input/foreground.rs b/libs/cua-driver/rust/crates/platform-linux/src/input/foreground.rs
index bf4322fd79..4968f60f3a 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/input/foreground.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/input/foreground.rs
@@ -879,14 +879,9 @@ mod tests {
#[test]
fn unavailable_display_is_structured() {
- // Force a failing connect regardless of the host environment.
- let prior = std::env::var_os("DISPLAY");
- std::env::set_var("DISPLAY", ":9999999");
+ let display = crate::test_env::unreachable_x11_display();
let result = with_x11_foreground_opts(0x1234, ForegroundOptions::pointer(), || Ok(()));
- match prior {
- Some(v) => std::env::set_var("DISPLAY", v),
- None => std::env::remove_var("DISPLAY"),
- }
+ drop(display);
let error = result.err().expect("connect must fail");
assert!(error_code(&error).is_some(), "{error}");
}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs b/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs
index 2aba7cd014..d6b21ce240 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs
@@ -116,26 +116,6 @@ fn tap_steps(keycode: u8, needs_shift: bool, shift: Option<u16>, steps: &mut Vec
}
}
-/// Plan the evdev transitions that type `text` under `mapping`. Characters
-/// with no keycode in the map are returned in the second tuple element (the
-/// caller may remap a spare keycode for them or report them as skipped).
-pub(super) fn plan_text(
- mapping: &GetKeyboardMappingReply,
- shift_x_keycode: Option<u8>,
- text: &str,
-) -> (Vec<KeyStep>, Vec<char>) {
- let shift = shift_x_keycode.and_then(evdev_code_for_x_keycode);
- let mut steps = Vec::with_capacity(text.len() * 2);
- let mut missing = Vec::new();
- for ch in text.chars() {
- match char_to_keycode_shift(mapping, keysym_for_char(ch)) {
- Some((keycode, needs_shift)) => tap_steps(keycode, needs_shift, shift, &mut steps),
- None => missing.push(ch),
- }
- }
- (steps, missing)
-}
-
/// Plan the evdev transitions that type `text` under `mapping`, resolving
/// characters missing from the keymap through `remap` (a spare-keycode
/// allocator) INLINE, one character at a time, so a mixed-script string
@@ -807,7 +787,7 @@ mod tests {
#[test]
fn text_plan_taps_keys_and_wraps_shifted_glyphs_in_shift() {
- let (steps, missing) = plan_text(&mapping(), Some(50), "a!\n");
+ let (steps, missing) = plan_text_with_fallback(&mapping(), Some(50), "a!\n", |_| None);
assert!(missing.is_empty());
assert_eq!(
steps,
@@ -824,18 +804,11 @@ mod tests {
);
}
- #[test]
- fn text_plan_reports_characters_the_keymap_lacks() {
- let (steps, missing) = plan_text(&mapping(), Some(50), "aé€");
- assert_eq!(steps.len(), 2);
- assert_eq!(missing, vec!['é', '€']);
- }
-
#[test]
fn text_plan_without_a_shift_keycode_types_the_unshifted_level() {
// No Shift in the modifier map: the keycode is still tapped (the
// server types the base glyph) rather than the character being lost.
- let (steps, _) = plan_text(&mapping(), None, "A");
+ let (steps, _) = plan_text_with_fallback(&mapping(), None, "A", |_| None);
assert_eq!(steps, vec![step(30, true), step(30, false)]);
}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/lib.rs b/libs/cua-driver/rust/crates/platform-linux/src/lib.rs
index d8f3f39392..391e19849e 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/lib.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/lib.rs
@@ -78,6 +78,54 @@ pub mod xauth;
#[cfg(target_os = "linux")]
pub mod session_bus;
+/// Process-environment overrides for unit tests. Every lib test that changes
+/// display variables must go through [`test_env::unreachable_x11_display`] so
+/// writers are serialized and the prior values are restored even on panic.
+#[cfg(all(test, target_os = "linux"))]
+pub(crate) mod test_env {
+ use std::ffi::OsString;
+ use std::sync::{Mutex, MutexGuard};
+
+ static ENV_LOCK: Mutex<()> = Mutex::new(());
+
+ pub(crate) struct DisplayOverride {
+ display: Option<OsString>,
+ wayland_display: Option<OsString>,
+ _lock: MutexGuard<'static, ()>,
+ }
+
+ /// Point `DISPLAY` at a server that cannot exist and hide
+ /// `WAYLAND_DISPLAY`, so the X11 path is taken and its connect fails
+ /// regardless of the host session.
+ pub(crate) fn unreachable_x11_display() -> DisplayOverride {
+ let lock = ENV_LOCK
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner());
+ let guard = DisplayOverride {
+ display: std::env::var_os("DISPLAY"),
+ wayland_display: std::env::var_os("WAYLAND_DISPLAY"),
+ _lock: lock,
+ };
+ std::env::set_var("DISPLAY", ":9999999");
+ std::env::remove_var("WAYLAND_DISPLAY");
+ guard
+ }
+
+ impl Drop for DisplayOverride {
+ fn drop(&mut self) {
+ for (name, value) in [
+ ("DISPLAY", self.display.take()),
+ ("WAYLAND_DISPLAY", self.wayland_display.take()),
+ ] {
+ match value {
+ Some(value) => std::env::set_var(name, value),
+ None => std::env::remove_var(name),
+ }
+ }
+ }
+ }
+}
+
/// Pure WSL-detection predicate, split out from [`is_wsl`] so both branches
/// are unit-testable without the process-global env / `OnceLock` cache.
/// `wsl_env` mirrors `$WSL_DISTRO_NAME`/`$WSL_INTEROP` being set; `osrelease`
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
index 1b6f169fe1..b7d4296ec4 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
@@ -3271,11 +3271,6 @@ mod tests {
})
}
- #[test]
- fn send_command_for_keeps_unit_returning_api() {
- let _: fn(CursorKey, OverlayCommand) = send_command_for;
- }
-
#[test]
fn session_removal_drops_the_cursor_and_rejects_late_commands() {
let mut map = default_render_map();
@@ -3385,26 +3380,6 @@ mod tests {
assert!(!ARRIVAL_DEGRADED.load(std::sync::atomic::Ordering::Relaxed));
}
- #[test]
- fn clearing_arrivals_releases_waiters() {
- let (tx, mut rx) = tokio::sync::oneshot::channel();
- let mut arrivals = Some(HashMap::from([("default".to_owned(), tx)]));
-
- clear_arrivals(&mut arrivals);
-
- assert!(matches!(
- rx.try_recv(),
- Err(tokio::sync::oneshot::error::TryRecvError::Closed)
- ));
- }
-
- #[test]
- fn disabling_render_map_marks_overlay_unavailable() {
- let mut render = Some(default_render_map());
- disable_render_map(&mut render);
- assert!(render.is_none());
- }
-
#[test]
fn active_frame_wake_does_not_consume_queued_command() {
let (tx, rx) = std::sync::mpsc::channel();
@@ -3634,13 +3609,6 @@ mod tests {
assert!(classify_x11_overlay_event(&error, 7).is_err());
}
- #[test]
- fn geometry_update_sets_render_bounds() {
- let mut map = default_render_map();
- update_render_map_geometry(&mut map, 1920, 2160);
- assert_eq!((map.scr_w, map.scr_h), (1920, 2160));
- }
-
#[test]
fn geometry_shrink_reclips_cursor_tiles() {
let mut map = default_render_map();
@@ -3650,6 +3618,7 @@ mod tests {
assert_eq!(render_x11_tiles(&map).len(), 1);
update_render_map_geometry(&mut map, 1920, 1080);
+ assert_eq!((map.scr_w, map.scr_h), (1920, 1080));
assert!(render_x11_tiles(&map).is_empty());
}
@@ -3660,21 +3629,9 @@ mod tests {
assert!(!render_map_needs_z_order_tick(&map));
}
- // The idle-park contract now applies to reduced-motion sessions: with the
+ // The idle-park contract applies to reduced-motion sessions: with the
// float bob active (the default), a visible cursor keeps ticking so it
// levitates at rest, and only a hidden or reduced-motion cursor parks.
- #[test]
- fn resting_visible_cursor_only_requires_cheap_z_order_ticks() {
- let mut map = default_render_map();
- let cursor = map.cursors.get_mut("default").unwrap();
- cursor.core.pos = (100.0, 100.0);
- cursor.core.motion.idle_hide_ms = 0.0;
- cursor.core.visual.reduced_motion = cursor_overlay::ReducedMotion::On;
-
- assert!(!render_map_needs_frame_tick(&map));
- assert!(render_map_needs_z_order_tick(&map));
- }
-
#[test]
fn resting_visible_cursor_keeps_ticking_for_the_float_bob() {
let mut map = default_render_map();
@@ -4184,29 +4141,6 @@ mod tests {
assert!(bgra.chunks_exact(4).all(|pixel| pixel[3] == 255));
}
- #[test]
- fn composited_tile_reproduces_the_backdrop_where_the_cursor_is_transparent() {
- let pixmap = composite_test_pixmap();
- let backdrop = composite_test_backdrop();
-
- let (bgra, _) = composited_bgra_and_visible_shape(&pixmap, &backdrop).unwrap();
-
- assert_eq!(&bgra[0..3], &backdrop[0..3]);
- }
-
- #[test]
- fn composited_tile_output_depends_on_the_backdrop() {
- let pixmap = composite_test_pixmap();
-
- let (over_white, _) = composited_bgra_and_visible_shape(&pixmap, &[0xFF; 16]).unwrap();
- let (over_black, _) = composited_bgra_and_visible_shape(&pixmap, &[0x00; 16]).unwrap();
-
- assert_ne!(&over_white[4..8], &over_black[4..8]);
- assert_ne!(&over_white[8..12], &over_black[8..12]);
- // The opaque core hides whatever is beneath it.
- assert_eq!(&over_white[12..16], &over_black[12..16]);
- }
-
#[test]
fn composited_tile_keeps_the_bloom_the_cutoff_path_drops() {
let pixmap = composite_test_pixmap();
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/session_bus.rs b/libs/cua-driver/rust/crates/platform-linux/src/session_bus.rs
index 8b231ca8a5..bf901bcaa8 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/session_bus.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/session_bus.rs
@@ -171,14 +171,6 @@ mod tests {
assert!(!is_session_process(""));
}
- #[test]
- fn standard_socket_address_is_unix_path() {
- // Pure formatting check — the discovery itself is environment-dependent.
- let uid = current_uid();
- let socket = format!("/run/user/{uid}/bus");
- assert!(format!("unix:path={socket}").starts_with("unix:path=/run/user/"));
- }
-
#[test]
fn parses_dbus_address_from_environ_blob() {
// Realistic NUL-separated /proc/<pid>/environ.
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/terminal.rs b/libs/cua-driver/rust/crates/platform-linux/src/terminal.rs
index fe43e5bd0b..34a34d8fed 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/terminal.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/terminal.rs
@@ -91,11 +91,13 @@ mod tests {
use super::*;
#[test]
- fn process_names_match_documented_terminals() {
- for n in TERMINAL_PROCESS_NAMES {
+ fn known_terminal_process_names_match() {
+ // Literal names, not the helper's own table: Ghostty was the report's
+ // primary regression.
+ for n in ["ghostty", "alacritty", "kitty", "konsole", "xterm"] {
assert!(
is_terminal_process_name(n),
- "documented terminal process {n:?} must match"
+ "terminal process {n:?} must match"
);
}
}
@@ -117,6 +119,8 @@ mod tests {
("alacritty", "Alacritty"),
("kitty", "kitty"),
("ghostty", "Ghostty"),
+ ("Ghostty", ""),
+ ("", "ghostty"),
("Konsole", "konsole"),
("gnome-terminal-server", "Gnome-terminal"),
("xterm", "XTerm"),
@@ -146,14 +150,4 @@ mod tests {
);
}
}
-
- #[test]
- fn ghostty_matches() {
- // Spot-check Ghostty across casing / field positions — that was
- // the report's primary regression.
- assert!(wm_class_matches_terminal("ghostty", "Ghostty"));
- assert!(wm_class_matches_terminal("Ghostty", ""));
- assert!(wm_class_matches_terminal("", "ghostty"));
- assert!(is_terminal_process_name("ghostty"));
- }
}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
index 2f2d51878a..caffb5228d 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
@@ -1939,25 +1939,6 @@ fn surface_identity_unproven_error(xid: u64, reason: String) -> Value {
// ── launch_app ───────────────────────────────────────────────────────────────
-#[cfg(test)]
-mod get_window_state_capture_tests {
- use super::*;
-
- #[test]
- fn surface_identity_failure_is_a_typed_screenshot_error() {
- let error = surface_identity_unproven_error(
- 0x2962,
- "surface_identity_unproven: fixture".to_owned(),
- );
-
- assert_eq!(error["code"], "surface_identity_unproven");
- assert_eq!(error["window_id"], 0x2962);
- assert!(error["reason"]
- .as_str()
- .is_some_and(|reason| reason.contains("surface_identity_unproven")));
- }
-}
-
#[cfg(test)]
mod get_window_state_actions_tests {
use super::*;
@@ -1983,13 +1964,6 @@ mod get_window_state_actions_tests {
}
}
- #[test]
- fn element_entry_includes_actions_when_present() {
- let n = node(vec!["Press".to_owned(), "Open".to_owned()]);
- let entry = build_element_entry(&n, None, None).unwrap();
- assert_eq!(entry["actions"], json!(["Press", "Open"]));
- }
-
#[test]
fn element_entry_omits_actions_when_empty() {
let n = node(Vec::new());
@@ -5213,44 +5187,6 @@ fn coordinate_drag_keeps_wayland_background_refusal_ahead_of_screenshot_context(
);
}
-#[cfg(test)]
-#[test]
-fn zoom_schema_keeps_pid_optional_for_window_owned_lookup() {
- let tool = ZoomTool {
- state: ToolState::new(),
- };
- let required = tool.def().input_schema["required"].as_array().unwrap();
- assert!(!required.iter().any(|field| field == "pid"));
- assert!(tool.def().input_schema["properties"].get("pid").is_some());
-
- tool.state.element_cache.publish_for_session(
- 42,
- 7,
- crate::atspi::cache::CachedSnapshot::from_nodes(&[]),
- Some("zoom-optional-pid-linux"),
- Some(2.0),
- );
- let (pid, context) = tool
- .state
- .element_cache
- .screenshot_context_for_zoom(None, 7, Some("zoom-optional-pid-linux"))
- .unwrap();
- assert_eq!(pid, 42);
- assert_eq!(context.window_id, 7);
- tool.state.element_cache.publish_for_session(
- 43,
- 7,
- crate::atspi::cache::CachedSnapshot::from_nodes(&[]),
- Some("zoom-optional-pid-linux"),
- Some(1.0),
- );
- assert!(tool
- .state
- .element_cache
- .screenshot_context_for_zoom(None, 7, Some("zoom-optional-pid-linux"))
- .is_err());
-}
-
#[cfg(test)]
#[test]
fn coordinate_less_mouse_button_up_survives_snapshot_replacement() {
@@ -8499,14 +8435,6 @@ mod press_key_tests {
Some(vec!["ctrl".to_owned(), "shift".to_owned(), "t".to_owned()])
);
}
-
- #[test]
- fn the_requested_key_is_last_so_partition_modifiers_can_find_it() {
- // `wayland::hotkey` splits the array with `partition_modifiers`, which
- // takes the last non-modifier as the key. Appending keeps that true.
- let chord = press_key_chord(&["ctrl".to_owned()], "s").expect("chord");
- assert_eq!(chord.last().map(String::as_str), Some("s"));
- }
}
#[async_trait]
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rs b/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rs
index f84fc313b5..d46a6e479d 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rs
@@ -566,15 +566,6 @@ impl Client {
}
}
- fn execute_routed(
- &mut self,
- action: Action,
- started: Option<tokio::sync::oneshot::Sender<()>>,
- route: DeliveryRoute,
- ) -> Result<Value> {
- self.execute_routed_with_attest(action, started, route, Self::attest)
- }
-
fn execute_routed_with_attest(
&mut self,
action: Action,
@@ -644,26 +635,6 @@ impl Client {
unreachable!("bounded stale geometry retry loop always returns")
}
- #[cfg(test)]
- fn dispatch(
- &self,
- packet: &str,
- is_drag: bool,
- started: Option<tokio::sync::oneshot::Sender<()>>,
- ) -> Result<Value> {
- self.dispatch_routed(packet, is_drag, started, DeliveryRoute::Background)
- }
-
- fn dispatch_routed(
- &self,
- packet: &str,
- is_drag: bool,
- mut started: Option<tokio::sync::oneshot::Sender<()>>,
- route: DeliveryRoute,
- ) -> Result<Value> {
- self.dispatch_routed_with_started(packet, is_drag, &mut started, route)
- }
-
fn dispatch_routed_with_started(
&self,
packet: &str,
@@ -722,11 +693,6 @@ impl Client {
Ok(reply)
}
- #[cfg(test)]
- fn target_packet(&self, action: &Action) -> String {
- self.target_packet_routed(action, DeliveryRoute::Background)
- }
-
fn check_route(&self, route: DeliveryRoute) -> Result<()> {
ensure!(
route == DeliveryRoute::Background
@@ -1341,6 +1307,18 @@ mod tests {
);
}
+ /// Send one raw packet through the production dispatch path.
+ fn dispatch(
+ client: &Client,
+ packet: &str,
+ is_drag: bool,
+ started: Option<tokio::sync::oneshot::Sender<()>>,
+ route: DeliveryRoute,
+ ) -> Result<Value> {
+ let mut started = started;
+ client.dispatch_routed_with_started(packet, is_drag, &mut started, route)
+ }
+
fn dispatch_production_key(slot: &mut Option<Client>, route: DeliveryRoute) -> Result<Value> {
dispatch_actions_in_slot(
slot,
@@ -1387,33 +1365,28 @@ mod tests {
.unwrap();
}
});
- let mut attestations = 0;
+ let mut handshake_attestations = 0;
assert!(client
.attest_and_handshake(0, |_| {
- attestations += 1;
+ handshake_attestations += 1;
Ok(())
})
.unwrap());
- assert_eq!(attestations, 1);
+ assert_eq!(handshake_attestations, 1);
+ reset_test_attestations();
let mut slot = Some(client);
for (call, text) in ["abc", "de"].into_iter().enumerate() {
- let result = dispatch_in_slot(
+ let result = dispatch_actions_in_slot(
&mut slot,
- |_| {
- attestations += 1;
- Ok(())
- },
- |client| {
- execute_text_actions(
- text_actions(text).unwrap(),
- DeliveryRoute::Foreground,
- |action| client.execute_routed(action, None, DeliveryRoute::Foreground),
- )
- },
+ text_actions(text).unwrap(),
+ None,
+ DeliveryRoute::Foreground,
+ true,
+ record_test_attestation,
)
.unwrap();
assert_eq!(result["delivery"]["delivered_count"], text.len());
- assert_eq!(attestations, call + 2);
+ assert_eq!(test_attestations(), call + 1);
assert!(slot.is_some());
}
server.join().unwrap();
@@ -1545,16 +1518,13 @@ mod tests {
);
});
let mut slot = Some(client);
- let result = dispatch_in_slot(
+ let result = dispatch_actions_in_slot(
&mut slot,
- |_| Ok(()),
- |client| {
- execute_text_actions(
- text_actions("abc").unwrap(),
- DeliveryRoute::Foreground,
- |action| client.execute_routed(action, None, DeliveryRoute::Foreground),
- )
- },
+ text_actions("abc").unwrap(),
+ None,
+ DeliveryRoute::Foreground,
+ true,
+ record_test_attestation,
)
.unwrap();
assert_eq!(result["code"], "desktop_changed");
@@ -1598,16 +1568,13 @@ mod tests {
);
});
let mut slot = Some(client);
- let result = dispatch_in_slot(
+ let result = dispatch_actions_in_slot(
&mut slot,
- |_| Ok(()),
- |client| {
- execute_text_actions(
- text_actions("abc").unwrap(),
- DeliveryRoute::Foreground,
- |action| client.execute_routed(action, None, DeliveryRoute::Foreground),
- )
- },
+ text_actions("abc").unwrap(),
+ None,
+ DeliveryRoute::Foreground,
+ true,
+ record_test_attestation,
)
.unwrap();
assert_eq!(result["code"], "target_changed");
@@ -1623,13 +1590,14 @@ mod tests {
client.lane = Some(0);
// This socket's peer is the test process, never the Wayland compositor.
assert!(client
- .execute_routed(
+ .execute_routed_with_attest(
Action::Key {
key: "a".into(),
modifiers: vec![]
},
None,
DeliveryRoute::Background,
+ Client::attest,
)
.is_err());
drop(client);
@@ -1815,14 +1783,14 @@ mod tests {
.unwrap();
});
let (started, acknowledgement) = tokio::sync::oneshot::channel();
- let reply = client
- .dispatch_routed(
- "DRAG synthetic",
- true,
- Some(started),
- DeliveryRoute::Foreground,
- )
- .unwrap();
+ let reply = dispatch(
+ &client,
+ "DRAG synthetic",
+ true,
+ Some(started),
+ DeliveryRoute::Foreground,
+ )
+ .unwrap();
assert!(acknowledgement.blocking_recv().is_ok());
assert_eq!(reply["effect"], "partial");
assert_eq!(
@@ -1840,10 +1808,15 @@ mod tests {
peer.send(br#"{"ok":true,"effect":"unverifiable","route":"synthetic_events"}"#)
.unwrap();
});
- assert!(client
- .dispatch_routed("KEY synthetic", false, None, DeliveryRoute::Foreground)
- .unwrap_err()
- .is::<DispatchUnknown>());
+ assert!(dispatch(
+ &client,
+ "KEY synthetic",
+ false,
+ None,
+ DeliveryRoute::Foreground
+ )
+ .unwrap_err()
+ .is::<DispatchUnknown>());
server.join().unwrap();
}
@@ -1868,9 +1841,8 @@ mod tests {
0
);
});
- let error = client
- .dispatch_routed(packet, started, None, DeliveryRoute::Foreground)
- .unwrap_err();
+ let error =
+ dispatch(&client, packet, started, None, DeliveryRoute::Foreground).unwrap_err();
assert_eq!(
error
.downcast_ref::<DispatchUnknown>()
@@ -1901,7 +1873,15 @@ mod tests {
let error = execute_text_actions(
text_actions("abc").unwrap(),
DeliveryRoute::Foreground,
- |_| client.dispatch_routed("KEY synthetic", false, None, DeliveryRoute::Foreground),
+ |_| {
+ dispatch(
+ &client,
+ "KEY synthetic",
+ false,
+ None,
+ DeliveryRoute::Foreground,
+ )
+ },
)
.unwrap_err();
assert_eq!(
@@ -1922,7 +1902,14 @@ mod tests {
assert_eq!(read_packet(&peer), "KEY synthetic");
peer.send(br#"{"ok":false,"code":"foreground_partial_unknown","detail":"foreground_partial_unknown"}"#).unwrap();
});
- let reply = client.dispatch("KEY synthetic", false, None).unwrap();
+ let reply = dispatch(
+ &client,
+ "KEY synthetic",
+ false,
+ None,
+ DeliveryRoute::Background,
+ )
+ .unwrap();
assert_eq!(reply["ok"], false);
assert_eq!(reply["code"], "foreground_partial_unknown");
server.join().unwrap();
@@ -1985,32 +1972,6 @@ mod tests {
}
}
- #[test]
- fn foreground_text_unknown_delivery_keeps_only_acknowledged_key_count() {
- let mut calls = 0;
- let error = execute_text_actions(
- text_actions("abc").unwrap(),
- DeliveryRoute::Foreground,
- |_| {
- calls += 1;
- if calls == 1 {
- Ok(json!({"ok":true}))
- } else {
- Err(unknown_dispatch(anyhow::anyhow!("peer closed"), 0))
- }
- },
- )
- .unwrap_err();
- assert_eq!(calls, 2);
- assert_eq!(
- error
- .downcast_ref::<DispatchUnknown>()
- .unwrap()
- .acknowledged_phases,
- 1
- );
- }
-
#[test]
fn cancelled_foreground_target_sends_no_input() {
let (mut client, peer) = test_connection();
@@ -2258,7 +2219,13 @@ mod tests {
|_| Ok(()),
|client| {
client.request("TARGET synthetic")?;
- client.dispatch("CLICK synthetic", false, None)
+ dispatch(
+ client,
+ "CLICK synthetic",
+ false,
+ None,
+ DeliveryRoute::Background,
+ )
},
)
.unwrap();
@@ -2300,7 +2267,13 @@ mod tests {
|_| Ok(()),
|client| {
dispatches += 1;
- client.dispatch("CLICK synthetic", false, None)
+ dispatch(
+ client,
+ "CLICK synthetic",
+ false,
+ None,
+ DeliveryRoute::Background,
+ )
},
)
.unwrap_err();
@@ -2641,7 +2614,15 @@ mod tests {
let result = dispatch_in_slot(
&mut slot,
|_| Ok(()),
- |client| client.dispatch("DRAG synthetic", true, Some(started)),
+ |client| {
+ dispatch(
+ client,
+ "DRAG synthetic",
+ true,
+ Some(started),
+ DeliveryRoute::Background,
+ )
+ },
);
assert!(slot.is_none());
finished.send(result).unwrap();
@@ -2713,9 +2694,7 @@ mod tests {
let (guard, cancellation) = ActionCancellation::invocation();
client.cancellation = cancellation;
drop(guard);
- let error = client
- .dispatch_routed("CLICK synthetic", false, None, route)
- .unwrap_err();
+ let error = dispatch(&client, "CLICK synthetic", false, None, route).unwrap_err();
assert!(error.is::<ActionCancelled>());
assert!(!error.is::<DispatchUnknown>());
let mut byte = [0u8];
@@ -2778,9 +2757,7 @@ mod tests {
std::io::ErrorKind::WouldBlock
);
});
- let error = client
- .dispatch_routed(packet, is_drag, Some(started), route)
- .unwrap_err();
+ let error = dispatch(&client, packet, is_drag, Some(started), route).unwrap_err();
let unknown = error.downcast_ref::<DispatchUnknown>().unwrap();
assert_eq!(unknown.acknowledged_phases, u32::from(is_drag));
assert_eq!(unknown.detail, ActionCancelled.to_string());
@@ -2810,7 +2787,13 @@ mod tests {
}
});
let (started, acknowledged) = tokio::sync::oneshot::channel();
- let result = client.dispatch("DRAG synthetic", true, Some(started));
+ let result = dispatch(
+ &client,
+ "DRAG synthetic",
+ true,
+ Some(started),
+ DeliveryRoute::Background,
+ );
assert!(acknowledged.blocking_recv().is_ok());
if expected_cancel {
let reply = result.unwrap();
@@ -2839,7 +2822,14 @@ mod tests {
let server = std::thread::spawn(move || {
assert_eq!(read_packet(&peer), "CLICK synthetic");
});
- let result = client.dispatch("CLICK synthetic", false, None).unwrap_err();
+ let result = dispatch(
+ &client,
+ "CLICK synthetic",
+ false,
+ None,
+ DeliveryRoute::Background,
+ )
+ .unwrap_err();
assert_eq!(
result
.downcast_ref::<DispatchUnknown>()
@@ -2936,10 +2926,15 @@ mod tests {
8,
),
] {
- assert_eq!(
- client.target_packet(&action),
- format!("TARGET 1 1 {capability}")
- );
+ for (route, command) in [
+ (DeliveryRoute::Background, "TARGET"),
+ (DeliveryRoute::Foreground, "FOREGROUND_TARGET"),
+ ] {
+ assert_eq!(
+ client.target_packet_routed(&action, route),
+ format!("{command} 1 1 {capability}")
+ );
+ }
}
for lane in 0..MAX_LANES {
assert_ne!(
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/wayland/kwin_helper.rs b/libs/cua-driver/rust/crates/platform-linux/src/wayland/kwin_helper.rs
index 2c94e567a1..480731ffd4 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/wayland/kwin_helper.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/wayland/kwin_helper.rs
@@ -27,7 +27,6 @@ const DBUS_PATH: &str = "/org/freedesktop/DBus";
const DBUS_IFACE: &str = "org.freedesktop.DBus";
pub const PROTOCOL_VERSION: u32 = 1;
const CALL_TIMEOUT: Duration = Duration::from_secs(3);
-const GEOMETRY_DELTA_PX: i32 = 64;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct KwinWindow {
@@ -44,25 +43,6 @@ pub struct KwinWindow {
pub stacking: usize,
}
-#[derive(Clone, Copy, Debug, Eq, PartialEq)]
-pub enum CorrelationError {
- NoMatch,
- Ambiguous,
- WrongActiveTarget,
-}
-
-impl std::fmt::Display for CorrelationError {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- match self {
- Self::NoMatch => f.write_str("no exact KWin window matches the AT-SPI target"),
- Self::Ambiguous => f.write_str("multiple KWin windows match the AT-SPI target"),
- Self::WrongActiveTarget => f.write_str("KWin reports a different active target"),
- }
- }
-}
-
-impl std::error::Error for CorrelationError {}
-
/// Whether KWin currently offers a target-bound raw-input capability that can
/// safely authorize portal/libei foreground mutations.
///
@@ -104,33 +84,6 @@ pub fn trusted_window_for_id(pid: u32, token: u64) -> Option<KwinWindow> {
.find(|window| window.pid == pid && window.token == token)
}
-pub fn correlate_atspi_window(
- atspi: &WindowInfo,
- windows: &[KwinWindow],
-) -> Result<KwinWindow, CorrelationError> {
- let pid = atspi.pid.ok_or(CorrelationError::NoMatch)?;
- let matches: Vec<_> = windows
- .iter()
- .filter(|window| window.pid == pid && !window.minimized)
- .filter(|window| geometry_matches(atspi, window))
- .cloned()
- .collect();
- match matches.as_slice() {
- [window] => Ok(window.clone()),
- [] => Err(CorrelationError::NoMatch),
- _ => Err(CorrelationError::Ambiguous),
- }
-}
-
-pub fn require_active_target(windows: &[KwinWindow], token: u64) -> Result<(), CorrelationError> {
- windows
- .iter()
- .find(|window| window.active)
- .filter(|window| window.token == token)
- .map(|_| ())
- .ok_or(CorrelationError::WrongActiveTarget)
-}
-
/// Refuse a focus-bound KWin foreground transaction.
///
/// `body` is deliberately never invoked. The current helper can identify an
@@ -149,25 +102,6 @@ pub fn with_focused_window<T>(
)
}
-fn geometry_matches(atspi: &WindowInfo, kwin: &KwinWindow) -> bool {
- let right = atspi
- .x
- .saturating_add(atspi.width.min(i32::MAX as u32) as i32);
- let bottom = atspi
- .y
- .saturating_add(atspi.height.min(i32::MAX as u32) as i32);
- let kwin_right = kwin
- .x
- .saturating_add(kwin.width.min(i32::MAX as u32) as i32);
- let kwin_bottom = kwin
- .y
- .saturating_add(kwin.height.min(i32::MAX as u32) as i32);
- (atspi.x - kwin.x).abs() <= GEOMETRY_DELTA_PX
- && (atspi.y - kwin.y).abs() <= GEOMETRY_DELTA_PX
- && (right - kwin_right).abs() <= GEOMETRY_DELTA_PX
- && (bottom - kwin_bottom).abs() <= GEOMETRY_DELTA_PX
-}
-
fn helper_owner() -> Option<String> {
let owner_raw = dbus_call("GetNameOwner", &[DEST.to_owned()]);
let owner = parse_quoted_string(&owner_raw?)?;
@@ -420,23 +354,3 @@ fn is_trusted_kwin(pid: u32, helper_owner: &str) -> bool {
None => true,
}
}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn raw_input_capability_is_fail_closed() {
- assert!(!available());
-
- let called = std::cell::Cell::new(false);
- let error = with_focused_window(42, 7, || {
- called.set(true);
- Ok(())
- })
- .expect_err("focus-bound KWin input must refuse");
-
- assert!(!called.get());
- assert!(error.to_string().contains("target-bound KWin input path"));
- }
-}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/x11/mod.rs b/libs/cua-driver/rust/crates/platform-linux/src/x11/mod.rs
index c94c24ba48..7c8acc578f 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/x11/mod.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/x11/mod.rs
@@ -135,7 +135,9 @@ fn list_windows_inner(filter_pid: Option<u32>) -> Result<Vec<WindowInfo>> {
app_name,
title,
is_on_screen,
- z_index: Some(z_index_from_bottom_to_top(z_index)),
+ // EWMH stacking lists are bottom-to-top, so the enumeration index
+ // already follows the shared "higher z_index is frontmost" contract.
+ z_index: Some(z_index),
x,
y,
width: w,
@@ -146,10 +148,6 @@ fn list_windows_inner(filter_pid: Option<u32>) -> Result<Vec<WindowInfo>> {
Ok(result)
}
-fn z_index_from_bottom_to_top(position: usize) -> usize {
- position
-}
-
fn get_window_list(conn: &RustConnection, root: Window) -> Result<Vec<Window>> {
let atom_names = ["_NET_CLIENT_LIST_STACKING", "_NET_CLIENT_LIST"];
for name in &atom_names {
@@ -620,13 +618,6 @@ mod tests {
assert!(!fallback_window_is_listable(MapState::UNVIEWABLE));
}
- #[test]
- fn ewmh_bottom_to_top_order_normalizes_to_higher_is_frontmost() {
- let indices: Vec<_> = (0..3).map(z_index_from_bottom_to_top).collect();
- assert_eq!(indices, vec![0, 1, 2]);
- assert!(indices[2] > indices[0]);
- }
-
#[test]
fn moveresize_requests_static_gravity_and_all_frame_fields() {
let flags = moveresize_window_flags();
diff --git a/libs/cua-driver/rust/crates/platform-linux/tests/kwin_helper_contract.rs b/libs/cua-driver/rust/crates/platform-linux/tests/kwin_helper_contract.rs
index 6e31b17de6..7c06fe4453 100644
--- a/libs/cua-driver/rust/crates/platform-linux/tests/kwin_helper_contract.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/tests/kwin_helper_contract.rs
@@ -1,25 +1,6 @@
#![cfg(target_os = "linux")]
-use platform_linux::wayland::kwin_helper::{
- available, correlate_atspi_window, parse_snapshot, require_active_target, with_focused_window,
- CorrelationError,
-};
-use platform_linux::x11::WindowInfo;
-
-fn atspi_window(pid: u32, x: i32, y: i32, width: u32, height: u32) -> WindowInfo {
- WindowInfo {
- xid: 99,
- pid: Some(pid),
- app_name: "org.example.Editor".into(),
- title: "Editor".into(),
- is_on_screen: true,
- z_index: None,
- x,
- y,
- width,
- height,
- }
-}
+use platform_linux::wayland::kwin_helper::{available, parse_snapshot, with_focused_window};
#[test]
fn parses_versioned_kwin_snapshot() {
@@ -64,44 +45,6 @@ fn parses_fractional_plasma_geometry() {
assert_eq!(snapshot[0].height, 99);
}
-#[test]
-fn correlates_one_same_pid_window_with_bounded_frame_delta() {
- let snapshot = parse_snapshot(
- r#"[{"token":41,"pid":1200,"x":100,"y":80,"w":800,"h":600,"active":false,"minimized":false,"stacking":3}]"#,
- )
- .unwrap();
-
- let target = correlate_atspi_window(&atspi_window(1200, 104, 112, 792, 560), &snapshot)
- .expect("one bounded geometry match");
- assert_eq!(target.token, 41);
-}
-
-#[test]
-fn rejects_duplicate_same_pid_geometry_candidates() {
- let snapshot = parse_snapshot(
- r#"[{"token":41,"pid":1200,"x":100,"y":80,"w":800,"h":600,"active":false,"minimized":false,"stacking":3},{"token":42,"pid":1200,"x":102,"y":82,"w":798,"h":598,"active":false,"minimized":false,"stacking":4}]"#,
- )
- .unwrap();
-
- assert_eq!(
- correlate_atspi_window(&atspi_window(1200, 104, 112, 792, 560), &snapshot),
- Err(CorrelationError::Ambiguous)
- );
-}
-
-#[test]
-fn refuses_minimized_same_pid_window() {
- let snapshot = parse_snapshot(
- r#"[{"token":41,"pid":1200,"x":100,"y":80,"w":800,"h":600,"active":false,"minimized":true,"stacking":3}]"#,
- )
- .unwrap();
-
- assert_eq!(
- correlate_atspi_window(&atspi_window(1200, 104, 112, 792, 560), &snapshot),
- Err(CorrelationError::NoMatch)
- );
-}
-
#[test]
fn rejects_zero_token() {
assert!(parse_snapshot(
@@ -126,19 +69,6 @@ fn rejects_multiple_active_records() {
.is_none());
}
-#[test]
-fn refuses_when_a_different_token_is_active() {
- let snapshot = parse_snapshot(
- r#"[{"token":41,"pid":1200,"x":100,"y":80,"w":800,"h":600,"active":false,"minimized":false,"stacking":3},{"token":42,"pid":1300,"x":0,"y":0,"w":800,"h":600,"active":true,"minimized":false,"stacking":4}]"#,
- )
- .unwrap();
-
- assert_eq!(
- require_active_target(&snapshot, 41),
- Err(CorrelationError::WrongActiveTarget)
- );
-}
-
#[test]
fn raw_kwin_input_is_refused_before_dispatch() {
assert!(