Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cua-driver): admit any native Wayland app to Hyprland background input (#6706)
cua-agents[bot]895aec7e51b0
diff --git a/docs/content/docs/cua-driver/concepts/platform-support.mdx b/docs/content/docs/cua-driver/concepts/platform-support.mdxindex 1c1be5ef8b..be89ee2967 100644--- a/docs/content/docs/cua-driver/concepts/platform-support.mdx+++ b/docs/content/docs/cua-driver/concepts/platform-support.mdx@@ -57,14 +57,19 @@ that received it and may prompt again after a restart.Omarchy is an Arch setup built on Hyprland. Modern Hyprland is not wlroots, soSway results do not carry over. An optional Hyprland plugin, off by default andoutside the normal installer, adds two independent agent seats (`Cua-Agent`,-`Cua-Agent-2`) for isolated background input. Cua Driver 0.24.0 shipped it with-a narrow qualification:--- Apps: Calc from `libreoffice-fresh 26.2.5-3` and Inkscape `1.4.4-6`, checked- against package metadata before every action.+`Cua-Agent-2`) for isolated background input:++- Apps: any native Wayland app that binds the agent seats, such as GTK 3 and 4+ and Qt 6 apps. Before every action the driver checks that the target is a+ native Wayland window of that process, and the plugin refuses an app that never+ bound the agent seat (`client_not_bound`). Chromium and Electron bind only the+ user's seat, so drive their pages with the browser tools.+- Qt 6 apps take background clicks, scrolls and drags but not keys: Qt sends keys+ only to the window the user has active, so background keys refuse+ (`client_drops_background_keys`).- The plugin's Hyprland ABI and compiler toolchain must match the compositor.-- Not covered: Chromium, Electron, and XWayland raw input; Unicode and IME;- multiple layouts; modified pointer gestures.+- Not covered: XWayland raw input; Unicode and IME; multiple layouts; modified+ pointer gestures.- Explicit foreground actions change focus and pointer and do not restore them.Evidence for this feature is recorded in PRsdiff --git a/libs/cua-driver/docs/action-support.md b/libs/cua-driver/docs/action-support.mdindex ab30295aeb..24fb846cf3 100644--- a/libs/cua-driver/docs/action-support.md+++ b/libs/cua-driver/docs/action-support.md@@ -97,9 +97,9 @@ coverage still requires the complete canonical Linux suite in native Hyprland.Foreground delivery may activate the target and move the primary cursor, withno restoration promise. Held keys/buttons, grabs, constraints, and drag-and-dropmust refuse before takeover; foreground drag interruption still requires review-and native verification. This route has no Calc/Inkscape package gate. Background-`TARGET` retains its Calc/Inkscape qualification and never escalates to-foreground. Observation followed by global `wtype` input is not an exact-target+and native verification. Background `TARGET` admits any native Wayland window+whose app bound the agent seats (see `hyprland_compatibility.rs` for the toolkit+quirks) and never escalates to foreground. Observation followed by global `wtype` input is not an exact-targetfallback. Both routes retain the common permission and lifecycle contract.## Maintenance rulediff --git a/libs/cua-driver/docs/test-harnesses-guide.md b/libs/cua-driver/docs/test-harnesses-guide.mdindex 86d91e8f84..3d328806a4 100644--- a/libs/cua-driver/docs/test-harnesses-guide.md+++ b/libs/cua-driver/docs/test-harnesses-guide.md@@ -96,17 +96,18 @@ only the test sentinel's animation, not its placement or the product's geometryguard. Restore the original configuration after the run. It is a deterministicfixture requirement, not an Omarchy user configuration requirement.-This is fixture regression coverage. For background `TARGET` input, the production compatibility gate in-`platform-linux/src/wayland/hyprland_compatibility.rs` admits only the qualified-native Calc `26.2.5-3` and Inkscape `1.4.4-6` packages. Ordinary GTK, Electron,-and Tauri fixtures do not qualify for v3 background raw input. Their declared refusals-can prove refusal behavior, but cannot prove plugin delivery or isolation.-Do not widen background production admission or add a test bypass to make them qualify.+This is fixture regression coverage. For background `TARGET` input, the production compatibility check in+`platform-linux/src/wayland/hyprland_compatibility.rs` admits any native Wayland+window whose app bound the agent seats, so the GTK3 fixture's background pointer+and key rows are delivered through the agent seats on Hyprland. A client that+binds only its first `wl_seat` (Chromium and Electron through Ozone) refuses with+`client_not_bound`; Qt 6 keys refuse with `client_drops_background_keys`. XWayland+targets refuse. Do not add a test bypass to make a refusing client pass.The [accepted foreground extension](https://github.com/trycua/cua/issues/3550#issuecomment-5564996417)adds a separate production `FOREGROUND_TARGET` route for ordinary nativetop-level surfaces, advertised by `HELLO` with `foreground_target:true`.-It does not apply the Calc/Inkscape background package gate. The existing+The existingcomplete suite covers defined native GTK3, Electron, and Tauri foregroundcases. Acceptance requires those cases to pass. Preserve the runner and tests.Foreground activation and primary-cursor movement are intentional, with no@@ -125,11 +126,10 @@ intervals, plus an uninstrumented six-action smoke. Saved outputs confirm Calccell A1 contains `a` and the Inkscape object's x-coordinate changes from 40 to42 while y remains 60. The plugin tree and uninstrumented module hash areunchanged at `1133a06e4f205cf80188a7ac9e41102f37611fea`. This is bounded-supporting evidence, not a complete app matrix or release-byte proof. Raw-background qualification remains native Calc from `libreoffice-fresh 26.2.5-3`,-Inkscape `1.4.4-6`, the plain compiled `evdev`/`pc105`/`us` keymap, and two-seats. Chromium, Electron, and XWayland raw background input remain unqualified;-semantic AT-SPI actions are separate.+supporting evidence, not a complete app matrix or release-byte proof; it+predates the per-target admission above. Background input keeps the plain+compiled `evdev`/`pc105`/`us` keymap and two seats. Chromium, Electron, and+XWayland raw background input refuse; semantic AT-SPI actions are separate.See [production proof preparation](../hyprland-plugin/docs/production-proof.md)for the bounded plans and their limits.diff --git a/libs/cua-driver/hyprland-plugin/README.md b/libs/cua-driver/hyprland-plugin/README.mdindex ec826c30e0..d15047c614 100644--- a/libs/cua-driver/hyprland-plugin/README.md+++ b/libs/cua-driver/hyprland-plugin/README.md@@ -35,12 +35,13 @@ testing, packaging, and release requirements.Bounded instrumented app proof and an uninstrumented smoke are retained fromsource `f180e8828b8f31cc153e3c44eaa89a9c13c5bc68`, with an unchanged plugintree and uninstrumented module hash at-`1133a06e4f205cf80188a7ac9e41102f37611fea`. Raw background qualification is-limited to native Calc from `libreoffice-fresh 26.2.5-3`, Inkscape `1.4.4-6`,-the plain compiled `evdev`/`pc105`/`us` keymap, and the two seats `Cua-Agent`-and `Cua-Agent-2`. The proof covers the recorded actions and observation-intervals. Chromium, Electron, and XWayland raw background input remain-unqualified; semantic AT-SPI actions are separate.+`1133a06e4f205cf80188a7ac9e41102f37611fea`. The proof covers the recorded+actions and observation intervals. Background input now admits any native+Wayland window whose app bound the agent seats `Cua-Agent` and `Cua-Agent-2`+(GTK 3 and 4 and Qt 6 do; Qt 6 keys refuse), with the plain compiled+`evdev`/`pc105`/`us` keymap. Chromium and Electron bind only the user's seat and+refuse with `client_not_bound`; XWayland refuses. Semantic AT-SPI actions are+separate.The exact-target foreground route intentionally changes primary focus and,for pointer actions, cursor position, without restoration. The canonical native@@ -316,5 +317,5 @@ remains discovery-only in its normal build. The separate physical run has explicactivation observation, GTK3, GTK4, Qt6, LibreOffice, Chromium/Ozone, Electron,DPMS-off refusal, and one-shot and long-lived graphical-session client rows;see `tests/README.md` for the required evidence. Those broader application rows-do not widen the raw-background qualification beyond the exact Calc/Inkscape-packages, plain US keymap, and two seats documented in the input v3 contract.+are separate from the per-target background admission, plain US keymap, and+two seats documented in the input v3 contract.diff --git a/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.md b/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.mdindex 3d56d54661..b482f8917f 100644--- a/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.md+++ b/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.md@@ -136,8 +136,8 @@ protocol, capabilities, socket paths, and compositor identity. A loaded modulealone does not prove input availability. Start the matching Driver with`CUA_DRIVER_RS_ENABLE_WAYLAND=1`; its production input protocol is v3 by default.-The input path checks exact native application packages: `libreoffice-fresh-26.2.5-3` for Calc and `inkscape 1.4.4-6`. Each background input lane publishes+The input path admits any native Wayland window whose app bound the agent seats+(GTK 3 and 4 and Qt 6 do; Chromium and Electron do not). Each background input lane publishesits own canonical `evdev/pc105/us` keymap, independent of user options such asCaps Lock remapped to Ctrl or Super. Existing actions are canceled when thephysical keymap changes; start a fresh action after the reload. Foregrounddiff --git a/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.md b/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.mdindex 149e44547f..2c3d6e45e5 100644--- a/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.md+++ b/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.md@@ -253,9 +253,10 @@ of bounded cleanup latency.## Compatibility and build gates-For background `TARGET`, Driver restricts app/package/version/operation-eligibility before connecting. Its qualification scope remains native Calc and-Inkscape. Foreground `FOREGROUND_TARGET` has no Calc/Inkscape package gate; its+For background `TARGET`, Driver admits a native Wayland window of the exact+process before connecting, and refuses XWayland windows and inputs a toolkit is+known to drop (Qt 6 keys). The plugin refuses `client_not_bound` when the client+never bound the lane seat's pointer or keyboard. Foreground `FOREGROUND_TARGET`scope is ordinary native top-level surfaces. Native GTK3, Electron, and Tauriforeground coverage is planned and still requires certification. The plugin checksnative surface identity, geometry, client conflicts, and exact compiled XKBdiff --git a/libs/cua-driver/hyprland-plugin/protocol/host-authority-boundary.md b/libs/cua-driver/hyprland-plugin/protocol/host-authority-boundary.mdindex e10cbc529b..a387409283 100644--- a/libs/cua-driver/hyprland-plugin/protocol/host-authority-boundary.md+++ b/libs/cua-driver/hyprland-plugin/protocol/host-authority-boundary.md@@ -32,13 +32,13 @@ connection. These checks prevent cross-account access and accidental routingto another compositor; they do not prove human consent or sandbox arbitrarynative code running as the same user.-The Linux adapter checks the qualified application package on every action-before allocating or using a lane. Eligibility is a compatibility check, not-an authorization boundary. The initial candidate scope is native Calc-`libreoffice-fresh 26.2.5-3` and Inkscape `1.4.4-6`, subject to per-operation-native qualification. Unknown packages refuse. The plugin separately checks-the live native surface, geometry, primary/other-agent conflicts, desktop-availability, and canonical US keymap.+The Linux adapter checks the target on every action+before allocating or using a lane: a native Wayland window of the exact+process, not XWayland, and not an input its toolkit is known to drop.+Eligibility is a compatibility check, not an authorization boundary. The+plugin separately checks that the client bound the lane seat, the live native+surface, geometry, primary/other-agent conflicts, desktop availability, and+canonical US keymap.Production [input v3](cua-input-v3.md) has separate endpoints from discovery v2and signed experiment 0. Each private connection claims one compositor-owneddiff --git a/libs/cua-driver/rust/Skills/cua-driver/LINUX.md b/libs/cua-driver/rust/Skills/cua-driver/LINUX.mdindex c64e0f6e79..eb98d25395 100644--- a/libs/cua-driver/rust/Skills/cua-driver/LINUX.md+++ b/libs/cua-driver/rust/Skills/cua-driver/LINUX.md@@ -316,14 +316,15 @@ signer. The plugin accepts the trusted desktop account over same-user localsockets; this does not sandbox native code running as that user. Applicationqualification is a compatibility check, not authorization.-The initial native qualification scope is Calc from `libreoffice-fresh 26.2.5-3`-and Inkscape `1.4.4-6`, subject to per-operation native evidence. Before each-action, Driver matches `/proc/<pid>/exe` to the canonical executable path-(`/usr/lib/libreoffice/program/soffice.bin` or `/usr/bin/inkscape`), checks the-exact package name and version in the local pacman database and its executable-file listing, and rechecks process identity. Unknown or unavailable package-identity refuses. Package eligibility does not certify every LibreOffice-application or operation.+Background input reaches any native Wayland app that binds the agent seats+(GTK 3 and 4 and Qt 6 apps do). Before each action, Driver checks that the+compositor reports the target as a native Wayland window of that process;+XWayland windows refuse with `client_xwayland`. The plugin refuses an app that+never bound the agent seat with `client_not_bound`: Chromium and Electron bind+only the user's seat, so use the browser tools for their pages. Qt 6 apps take+background clicks, scrolls and drags, but refuse keys+(`client_drops_background_keys`): Qt sends keys only to the window the user has+active.The plugin separately binds the exact live native surface and checks geometry,desktop availability, and primary-client and other-lane conflicts. Each@@ -348,7 +349,7 @@ The candidate also adds an explicitly requested foreground route, advertisedby the plugin as `foreground_target:true`. It binds the exact native top-levelsurface on the compositor thread and intentionally changes primary focus and,for pointer actions, cursor position. It does not restore the previous focus or-cursor. This route has no Calc/Inkscape background package gate. The canonical+cursor. The canonicalnative harness covers defined GTK3, Electron, and Tauri foreground cases. It refusesheld physical input, grabs, constraints, drag-and-drop, ambiguous primary seatbindings, and non-neutral keyboard modifiers. Background refusal never selectsdiff --git a/libs/cua-driver/rust/crates/cua-driver-e2e/tests/harness_gtk3_test.rs b/libs/cua-driver/rust/crates/cua-driver-e2e/tests/harness_gtk3_test.rsindex f9d2c87b67..69975b2fde 100644--- a/libs/cua-driver/rust/crates/cua-driver-e2e/tests/harness_gtk3_test.rs+++ b/libs/cua-driver/rust/crates/cua-driver-e2e/tests/harness_gtk3_test.rs@@ -1202,8 +1202,16 @@ fn invoke_operation(false}+/// Hyprland's agent seats (the Cua plugin's isolated input) take background+/// pointer and key input for any native Wayland client that binds them, the+/// GTK3 fixture included.+fn hyprland_agent_seats() -> bool {+ DisplayServer::current() == DisplayServer::Wayland+ && platform_linux::wayland::hyprland_input::enabled()+}+fn row_expects_refusal(row: CatalogRow) -> bool {- if row.delivery != Delivery::Background {+ if row.delivery != Delivery::Background || hyprland_agent_seats() {return false;}// X11 promotes a plain left click on an accessible GTK control to the@@ -1263,6 +1271,8 @@ fn run_catalog_row(row: CatalogRow) {) && row.delivery == Delivery::Background{DriverRoute::LinuxAtSpiAction+ } else if row.delivery == Delivery::Background && hyprland_agent_seats() {+ DriverRoute::LinuxHyprlandIsolatedInput} else if std::env::var_os("CUA_INJECT_SOCKET").is_some() {DriverRoute::LinuxCuaCompositorInject} else {diff --git a/libs/cua-driver/rust/crates/cua-driver-testkit/src/e2e.rs b/libs/cua-driver/rust/crates/cua-driver-testkit/src/e2e.rsindex e6b307f726..1c154bdb9b 100644--- a/libs/cua-driver/rust/crates/cua-driver-testkit/src/e2e.rs+++ b/libs/cua-driver/rust/crates/cua-driver-testkit/src/e2e.rs@@ -139,6 +139,7 @@ pub enum DriverRoute {LinuxLibei,LinuxWaylandVirtualPointer,LinuxCuaCompositorInject,+ LinuxHyprlandIsolatedInput,Cdp,Composite,}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_.rsindex 8c5325c670..6d95d5a34d 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@@ -3036,6 +3036,13 @@ pub(crate) fn hyprland_input_result(result: anyhow::Result<Value>, foreground: b} else {unavailable};+ if !foreground && code.starts_with("client_") {+ value["hint"] = json!(+ "This app does not take background pointer or key input on Hyprland's \+ agent seats. Use element_token (accessibility actions), the browser \+ tools for a browser page, or delivery_mode:\"foreground\"."+ );+ }value["reason"] = json!(code);value["code"] = json!(refusal);value["route"] = json!(if foreground {@@ -3508,6 +3515,27 @@ fn failed_session_end_release_remains_retryable_and_bounded() {.is_none());}+#[cfg(test)]+#[test]+fn background_client_refusals_name_the_alternatives() {+ for code in ["client_not_bound", "client_xwayland", "client_unattested"] {+ let result = isolated_hyprland_result(Ok(json!({"ok":false,"code":code,"detail":code})));+ let value = result.structured_content.as_ref().unwrap();+ assert_eq!(value["code"], "background_unavailable");+ assert_eq!(value["reason"], code);+ assert!(value["hint"].as_str().unwrap().contains("element_token"));+ }+ let foreground = hyprland_input_result(+ Ok(json!({"ok":false,"code":"client_not_bound","detail":"client_not_bound"})),+ true,+ );+ assert!(foreground.structured_content.as_ref().unwrap()["hint"].is_null());+ let other = isolated_hyprland_result(Ok(+ json!({"ok":false,"code":"primary_target_busy","detail":"primary_target_busy"}),+ ));+ assert!(other.structured_content.as_ref().unwrap()["hint"].is_null());+}+#[cfg(test)]#[test]fn isolated_hyprland_refused_partial_and_unknown_outcomes_stay_distinct() {diff --git a/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_compatibility.rs b/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_compatibility.rsindex fa0a29daa4..26af366e63 100644--- a/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_compatibility.rs+++ b/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_compatibility.rs@@ -1,103 +1,194 @@// SPDX-License-Identifier: MIT// Copyright (c) 2026 Cua AI, Inc.-//! Compatibility admission for the initial native Hyprland input package.-//! This is not a security boundary against same-user code. Unknown package-//! versions refuse until the native operation matrix is qualified for them.+//! Which targets background input on Hyprland's agent seats can reach.+//!+//! Background input arrives on the plugin's own seats (`Cua-Agent`,+//! `Cua-Agent-2`), separate `wl_seat` globals beside the user's. A native+//! Wayland client that binds every advertised seat gets it the same way, with+//! no toolkit-specific path; GTK 3, GTK 4 and Qt 6 do. So admission checks the+//! live target, not a list of packages:+//!+//! - the compositor must report the exact `(pid, window address)` as a mapped+//! native Wayland client. XWayland windows refuse: X11 has one core pointer+//! and keyboard, so a second seat cannot reach them separately;+//! - the process must be alive, and the input must not be one its toolkit is+//! known to drop ([`QUIRKS`]).+//!+//! The plugin repeats the live checks at dispatch and adds the one only the+//! compositor can see: whether the client bound the lane seat's pointer or+//! keyboard. A client that binds only its first `wl_seat` (Chromium's Ozone+//! backend, and so Electron) is refused there with `client_not_bound`, before+//! any event is sent.+//!+//! This is a compatibility check, not a security boundary against same-user+//! code.-use std::io::Read;-use std::path::{Path, PathBuf};+use std::io::{BufRead, BufReader};-struct QualifiedPackage {- name: &'static str,- version: &'static str,- executable: &'static str,+/// A toolkit that binds the agent seats but drops some of their input.+struct Quirk {+ /// A shared library the client has mapped, naming its toolkit.+ library: &'static str,+ /// Whether the quirk is about keyboard input (else pointer input).+ keyboard: bool,+ /// Refusal code reported to the caller.+ reason: &'static str,}-const PACKAGES: &[QualifiedPackage] = &[- QualifiedPackage {- name: "libreoffice-fresh",- version: "26.2.5-3",- executable: "/usr/lib/libreoffice/program/soffice.bin",- },- QualifiedPackage {- name: "inkscape",- version: "1.4.4-6",- executable: "/usr/bin/inkscape",+/// Refused although the client binds the agent seats. Add an entry only for a+/// reproduced failure, and say what fails.+const QUIRKS: &[Quirk] = &[+ // Qt 6 sends a key to its focus window, which is only ever a window the+ // compositor activated for the user's seat: a background Qt window drops+ // agent-seat keys (Qt 6.12, Qt Quick). Its pointer input works.+ Quirk {+ library: "libQt6Gui.so",+ keyboard: true,+ reason: "client_drops_background_keys",},];-fn field<'a>(description: &'a str, name: &str) -> Option<&'a str> {- let mut lines = description.lines();- while let Some(line) = lines.next() {- if line == name {- return lines.next().filter(|value| !value.is_empty());- }- }- None+/// Whether background input on the agent seats may target `address`, a+/// window of `pid`; `keyboard` when the actions include keys. `Err` is the+/// refusal code.+pub(super) fn admit(pid: u32, address: u64, keyboard: bool) -> Result<(), &'static str> {+ let window = super::hyprland::window_for_address(address).ok_or("target_unavailable")?;+ admit_target(pid, window.pid, window.xwayland, keyboard, QUIRKS)}-fn read_bounded(path: &Path) -> Result<String, &'static str> {- let file = std::fs::File::open(path).map_err(|_| "client_qualification_unavailable")?;- let mut content = String::new();- file.take(1024 * 1024 + 1)- .read_to_string(&mut content)- .map_err(|_| "client_qualification_unavailable")?;- if content.len() > 1024 * 1024 {- return Err("client_qualification_unavailable");+/// `window_pid` and `xwayland` are what the compositor reports for the window.+fn admit_target(+ pid: u32,+ window_pid: u32,+ xwayland: Option<bool>,+ keyboard: bool,+ quirks: &[Quirk],+) -> Result<(), &'static str> {+ if window_pid != pid {+ return Err("target_unavailable");}- Ok(content)-}--pub(super) fn qualify(pid: u32) -> Result<(), &'static str> {- let process_exe = PathBuf::from(format!("/proc/{pid}/exe"));- let executable =- std::fs::read_link(&process_exe).map_err(|_| "client_qualification_unavailable")?;- let package = PACKAGES- .iter()- .find(|package| {- std::fs::canonicalize(package.executable).ok().as_ref() == Some(&executable)- })- .ok_or("client_not_qualified")?;- let directory = PathBuf::from("/var/lib/pacman/local")- .join(format!("{}-{}", package.name, package.version));- let description = read_bounded(&directory.join("desc"))?;- if field(&description, "%NAME%") != Some(package.name)- || field(&description, "%VERSION%") != Some(package.version)- {- return Err("client_not_qualified");+ match xwayland {+ Some(false) => {}+ Some(true) => return Err("client_xwayland"),+ None => return Err("client_unattested"),}- let files = read_bounded(&directory.join("files"))?;- if !files- .lines()- .any(|line| line == package.executable.trim_start_matches('/'))- {- return Err("client_not_qualified");- }- // Detect replacement between initial identification and admission. The- // compositor independently verifies its exact live target at dispatch.- if std::fs::read_link(process_exe).ok().as_ref() != Some(&executable) {- return Err("client_qualification_unavailable");+ let maps =+ std::fs::File::open(format!("/proc/{pid}/maps")).map_err(|_| "target_unavailable")?;+ let applicable: Vec<&Quirk> = quirks+ .iter()+ .filter(|quirk| quirk.keyboard == keyboard)+ .collect();+ if applicable.is_empty() {+ return Ok(());}- Ok(())+ quirk_in(BufReader::new(maps), &applicable).map_or(Ok(()), |quirk| Err(quirk.reason))+}++/// The first quirk whose library appears in a `/proc/<pid>/maps` listing.+fn quirk_in<'a>(maps: impl BufRead, quirks: &[&'a Quirk]) -> Option<&'a Quirk> {+ maps.lines().map_while(Result::ok).find_map(|line| {+ let file = line.rsplit('/').next()?;+ quirks+ .iter()+ .copied()+ .find(|quirk| file.starts_with(quirk.library))+ })}#[cfg(test)]mod tests {use super::*;+ const QT_KEYS: Quirk = Quirk {+ library: "libQt6Gui.so",+ keyboard: true,+ reason: "client_drops_background_keys",+ };++ #[test]+ fn any_native_wayland_client_is_admitted() {+ // This test process stands in for an arbitrary unlisted application.+ let pid = std::process::id();+ for keyboard in [false, true] {+ assert_eq!(+ admit_target(pid, pid, Some(false), keyboard, QUIRKS),+ Ok(())+ );+ }+ }++ #[test]+ fn xwayland_and_unattested_windows_refuse() {+ let pid = std::process::id();+ assert_eq!(+ admit_target(pid, pid, Some(true), false, QUIRKS),+ Err("client_xwayland")+ );+ assert_eq!(+ admit_target(pid, pid, None, false, QUIRKS),+ Err("client_unattested")+ );+ }++ #[test]+ fn window_of_another_process_or_a_dead_one_refuses() {+ let pid = std::process::id();+ assert_eq!(+ admit_target(pid, pid + 1, Some(false), false, QUIRKS),+ Err("target_unavailable")+ );+ assert_eq!(+ admit_target(u32::MAX, u32::MAX, Some(false), false, QUIRKS),+ Err("target_unavailable")+ );+ }+#[test]- fn alpm_identity_requires_exact_package_and_version_fields() {- let description = "%NAME%\ninkscape\n\n%VERSION%\n1.4.4-6\n\n";- assert_eq!(field(description, "%NAME%"), Some("inkscape"));- assert_eq!(field(description, "%VERSION%"), Some("1.4.4-6"));- assert_eq!(field("%VERSION%\n", "%VERSION%"), None);- assert_eq!(field("%VERSION%\n\n", "%VERSION%"), None);- assert_eq!(field("prefix%NAME%\ninkscape", "%NAME%"), None);+ fn qt6_quirk_refuses_keys_only() {+ let maps = "7f00-7f10 r-xp 00000000 fd:01 42 /usr/lib/libQt6Gui.so.6.12.0\n\+ 7f10-7f20 r-xp 00000000 fd:01 43 /usr/lib/libc.so.6\n";+ assert_eq!(+ quirk_in(maps.as_bytes(), &[&QT_KEYS]).map(|quirk| quirk.reason),+ Some("client_drops_background_keys")+ );+ let gtk = "7f00-7f10 r-xp 00000000 fd:01 44 /usr/lib/libgtk-3.so.0.2400.52\n\+ 7f10-7f20 rw-p 00000000 00:00 0 [heap]\n";+ assert!(quirk_in(gtk.as_bytes(), &[&QT_KEYS]).is_none());+ // The live check reads this process's own maps: no Qt here.+ let pid = std::process::id();+ assert_eq!(+ admit_target(pid, pid, Some(false), true, &[QT_KEYS]),+ Ok(())+ );}#[test]- fn nonexistent_process_cannot_be_qualified() {- assert!(qualify(u32::MAX).is_err());+ fn a_quirk_matching_this_process_refuses_only_its_input_kind() {+ let pid = std::process::id();+ let maps = std::fs::read_to_string(format!("/proc/{pid}/maps")).unwrap();+ let library: &'static str = Box::leak(+ maps.lines()+ .find_map(|line| line.rsplit('/').next().filter(|f| f.contains(".so")))+ .expect("a mapped shared library")+ .split(".so")+ .next()+ .map(|stem| format!("{stem}.so"))+ .unwrap()+ .into_boxed_str(),+ );+ let quirk = Quirk {+ library,+ keyboard: true,+ reason: "client_quirk_test",+ };+ assert_eq!(+ admit_target(pid, pid, Some(false), true, std::slice::from_ref(&quirk)),+ Err("client_quirk_test")+ );+ assert_eq!(+ admit_target(pid, pid, Some(false), false, std::slice::from_ref(&quirk)),+ Ok(())+ );}}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.rsindex 7aaa598a4d..7c5188912c 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@@ -249,14 +249,14 @@ pub fn enabled() -> bool {}))}-/// Whether background (isolated seat) input is admitted for `pid`'s windows,-/// the check a background action makes before dispatch. `Err` carries the-/// refusal reason (`client_not_qualified`, ...). Only meaningful while-/// [`enabled`]: without the isolated seats the tools route background input-/// elsewhere.-pub fn background_admission(pid: u32) -> std::result::Result<(), &'static str> {+/// Whether background (isolated seat) input can reach window `address` of+/// `pid`, the check a background session makes when it opens. `Err` carries+/// the refusal reason (`client_xwayland`, ...). Per-action checks, such as a+/// toolkit that drops background keys, still apply to each action. Only+/// meaningful while [`enabled`].+pub fn background_admission(pid: u32, address: u64) -> std::result::Result<(), &'static str> {if protocol() == InputProtocol::Production {- super::hyprland_compatibility::qualify(pid)+ super::hyprland_compatibility::admit(pid, address, false)} else {Ok(())}@@ -1203,7 +1203,10 @@ fn execute_actions_routed("foreground input requires production protocol; no downgrade is permitted");if route == DeliveryRoute::Background && protocol() == InputProtocol::Production {- if let Err(reason) = super::hyprland_compatibility::qualify(pid) {+ let keyboard = actions+ .iter()+ .any(|action| matches!(action, Action::Key { .. } | Action::TextKey { .. }));+ if let Err(reason) = super::hyprland_compatibility::admit(pid, address, keyboard) {return Ok(json!({"ok":false,"code":reason,"detail":reason}));}}diff --git a/libs/cua-spacesd/crates/cua-spacesd-desktop/src/lib.rs b/libs/cua-spacesd/crates/cua-spacesd-desktop/src/lib.rsindex 5728cd15f7..0d82456d53 100644--- a/libs/cua-spacesd/crates/cua-spacesd-desktop/src/lib.rs+++ b/libs/cua-spacesd/crates/cua-spacesd-desktop/src/lib.rs@@ -304,8 +304,8 @@ impl TargetCatalog {}/// A background session reaches a Hyprland window only through the-/// cua-hyprland-plugin's isolated seats, which admit qualified clients only.-/// Any other window is refused when the session opens, as X11 refuses a+/// cua-hyprland-plugin's isolated seats, which reach native Wayland windows+/// only. Any other window (XWayland) is refused when the session opens, as X11 refuses a/// toolkit that drops synthetic events, instead of acknowledging every/// batch as undelivered.#[cfg(target_os = "linux")]@@ -315,7 +315,7 @@ fn hyprland_background_admission(native: NativeTarget) -> Result<(), ProviderErrreturn Ok(());}let pid = u32::try_from(native.pid).unwrap_or(0);- hyprland_input::background_admission(pid).map_err(|reason| {+ hyprland_input::background_admission(pid, native.window_id).map_err(|reason| {ProviderError::new(ProviderErrorCode::WouldRequireActivation,format!(diff --git a/libs/cua/skills/cua-driver/LINUX.md b/libs/cua/skills/cua-driver/LINUX.mdindex af4b584d83..06c10bae02 100644--- a/libs/cua/skills/cua-driver/LINUX.md+++ b/libs/cua/skills/cua-driver/LINUX.md@@ -276,14 +276,15 @@ signer. The plugin accepts the trusted desktop account over same-user localsockets; this does not sandbox native code running as that user. Applicationqualification is a compatibility check, not authorization.-The initial native qualification scope is Calc from `libreoffice-fresh 26.2.5-3`-and Inkscape `1.4.4-6`, subject to per-operation native evidence. Before each-action, Driver matches `/proc/<pid>/exe` to the canonical executable path-(`/usr/lib/libreoffice/program/soffice.bin` or `/usr/bin/inkscape`), checks the-exact package name and version in the local pacman database and its executable-file listing, and rechecks process identity. Unknown or unavailable package-identity refuses. Package eligibility does not certify every LibreOffice-application or operation.+Background input reaches any native Wayland app that binds the agent seats+(GTK 3 and 4 and Qt 6 apps do). Before each action, Driver checks that the+compositor reports the target as a native Wayland window of that process;+XWayland windows refuse with `client_xwayland`. The plugin refuses an app that+never bound the agent seat with `client_not_bound`: Chromium and Electron bind+only the user's seat, so use the browser tools for their pages. Qt 6 apps take+background clicks, scrolls and drags, but refuse keys+(`client_drops_background_keys`): Qt sends keys only to the window the user has+active.The plugin separately binds the exact live native surface and checks geometry,desktop availability, and primary-client and other-lane conflicts. Each@@ -308,7 +309,7 @@ The candidate also adds an explicitly requested foreground route, advertisedby the plugin as `foreground_target:true`. It binds the exact native top-levelsurface on the compositor thread and intentionally changes primary focus and,for pointer actions, cursor position. It does not restore the previous focus or-cursor. This route has no Calc/Inkscape background package gate. The canonical+cursor. The canonicalnative harness covers defined GTK3, Electron, and Tauri foreground cases. It refusesheld physical input, grabs, constraints, drag-and-drop, ambiguous primary seatbindings, and non-neutral keyboard modifiers. Background refusal never selectsdiff --git a/libs/spaces-app-swift/Sources/CuaSpacesStreaming/SpaceStreamProvider.swift b/libs/spaces-app-swift/Sources/CuaSpacesStreaming/SpaceStreamProvider.swiftindex 57a2ecb684..67983cfada 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesStreaming/SpaceStreamProvider.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesStreaming/SpaceStreamProvider.swift@@ -86,8 +86,8 @@ public final class SpaceStreamProvider: SpaceStreamSourceProviding, @unchecked S/// every click on a desktop stream went nowhere. The desktop is driven/// like a physical mouse and keyboard, which is `allow_activation`: the/// same policy the Tauri and HTML5 viewers use for it. A window whose- /// input the Space can only deliver by activating it (Hyprland outside- /// its qualified apps, X11 toolkits that drop synthetic events) is+ /// input the Space can only deliver by activating it (an XWayland window+ /// on Hyprland, X11 toolkits that drop synthetic events) is/// refused as would-require-activation; `LiveStreamSession` then reopens/// that window with `allow_activation`.public static func inputPolicy(for source: StreamSource) -> String {diff --git a/libs/spaces-app-swift/Tests/CuaSpacesStreamingTests/ViewerInputTests.swift b/libs/spaces-app-swift/Tests/CuaSpacesStreamingTests/ViewerInputTests.swiftindex c71b279e8b..742fcd2ea7 100644--- a/libs/spaces-app-swift/Tests/CuaSpacesStreamingTests/ViewerInputTests.swift+++ b/libs/spaces-app-swift/Tests/CuaSpacesStreamingTests/ViewerInputTests.swift@@ -252,8 +252,8 @@ private func pointerEvents(in text: String) -> [[String: Any]] {await session.stop()}- /// A window the Space can reach only by activating it (Hyprland outside- /// its qualified apps) refuses the background session as+ /// A window the Space can reach only by activating it (an XWayland+ /// window on Hyprland) refuses the background session as/// would-require-activation. The viewer reopens that window with/// `allow_activation` and resends the refused click, instead of showing/// "Input not delivered" for every click.