first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -4,7 +4,7 @@ mod x11;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{Action, ActionResult, Options};
|
||||
use crate::{ActionResult, Options, TargetedAction};
|
||||
|
||||
/// Returns true if a Wayland environment is available.
|
||||
fn is_wayland_available() -> bool {
|
||||
@@ -24,6 +24,12 @@ pub fn is_supported_on_current_platform() -> bool {
|
||||
is_wayland_available() || is_x11_available()
|
||||
}
|
||||
|
||||
/// Reports whether background, per-window control is available. The Linux input stack drives the
|
||||
/// whole screen / frontmost application, so per-window background control is unsupported.
|
||||
pub fn background_supported() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub struct Actor {
|
||||
inner: ActorInner,
|
||||
}
|
||||
@@ -77,7 +83,7 @@ impl super::Actor for Actor {
|
||||
|
||||
async fn perform_actions(
|
||||
&mut self,
|
||||
actions: &[Action],
|
||||
actions: &[TargetedAction],
|
||||
options: Options,
|
||||
) -> Result<ActionResult, String> {
|
||||
match &mut self.inner {
|
||||
|
||||
@@ -11,14 +11,13 @@ mod screenshot;
|
||||
mod session;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use galaxyui::r#async::Timer;
|
||||
use pathfinder_geometry::vector::Vector2I;
|
||||
|
||||
use crate::{Action, ActionResult, Options};
|
||||
|
||||
use keyboard::Keyboard;
|
||||
use mouse::Mouse;
|
||||
use pathfinder_geometry::vector::Vector2I;
|
||||
use session::PortalSession;
|
||||
use galaxyui_core::r#async::Timer;
|
||||
|
||||
use crate::{Action, ActionResult, Options, TargetedAction};
|
||||
|
||||
/// An actor that performs computer use actions on Wayland via XDG portals.
|
||||
pub struct Actor {
|
||||
@@ -58,7 +57,7 @@ impl crate::Actor for Actor {
|
||||
|
||||
async fn perform_actions(
|
||||
&mut self,
|
||||
actions: &[Action],
|
||||
actions: &[TargetedAction],
|
||||
options: Options,
|
||||
) -> Result<ActionResult, String> {
|
||||
// Ensure we have an active session before processing actions.
|
||||
@@ -67,7 +66,10 @@ impl crate::Actor for Actor {
|
||||
|
||||
let mut last_mouse_position: Option<Vector2I> = None;
|
||||
|
||||
for action in actions {
|
||||
for targeted in actions {
|
||||
// Per-window targeting is not supported on Wayland; act on the screen / focused
|
||||
// surface regardless of the requested target.
|
||||
let action: &Action = &targeted.action;
|
||||
// Re-acquire session reference each iteration (borrow checker workaround).
|
||||
let session = self
|
||||
.session
|
||||
@@ -153,9 +155,6 @@ impl crate::Actor for Actor {
|
||||
self.mouse.last_position()
|
||||
};
|
||||
|
||||
Ok(ActionResult {
|
||||
screenshot,
|
||||
cursor_position,
|
||||
})
|
||||
Ok(ActionResult::legacy(screenshot, cursor_position))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,13 @@ mod screenshot;
|
||||
use async_trait::async_trait;
|
||||
use galaxyui::r#async::Timer;
|
||||
use pathfinder_geometry::vector::Vector2I;
|
||||
use galaxyui_core::r#async::Timer;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto::{self, ConnectionExt as _};
|
||||
use x11rb::protocol::xtest::ConnectionExt as _;
|
||||
use x11rb::rust_connection::RustConnection;
|
||||
|
||||
use crate::{Action, ActionResult, Options};
|
||||
use crate::{Action, ActionResult, Options, TargetedAction};
|
||||
|
||||
/// An actor that performs computer use actions on X11.
|
||||
pub struct Actor {
|
||||
@@ -71,14 +72,17 @@ impl crate::Actor for Actor {
|
||||
|
||||
async fn perform_actions(
|
||||
&mut self,
|
||||
actions: &[Action],
|
||||
actions: &[TargetedAction],
|
||||
options: Options,
|
||||
) -> Result<ActionResult, String> {
|
||||
let mut mouse = mouse::Mouse::new(&self.conn, self.root_window());
|
||||
let mut keyboard = keyboard::Keyboard::new(&self.conn, &self.keyboard_mapping);
|
||||
let mut last_mouse_position: Option<Vector2I> = None;
|
||||
|
||||
for action in actions {
|
||||
for targeted in actions {
|
||||
// Per-window targeting is not supported on X11; act on the screen regardless of the
|
||||
// requested target.
|
||||
let action: &Action = &targeted.action;
|
||||
match action {
|
||||
Action::Wait(duration) => {
|
||||
Timer::after(*duration).await;
|
||||
@@ -135,9 +139,6 @@ impl crate::Actor for Actor {
|
||||
Some(mouse.current_position()?)
|
||||
};
|
||||
|
||||
Ok(ActionResult {
|
||||
screenshot,
|
||||
cursor_position,
|
||||
})
|
||||
Ok(ActionResult::legacy(screenshot, cursor_position))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user