chiark / gitweb /
wip coords matrix
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jan 2021 00:42:01 +0000 (00:42 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jan 2021 00:42:01 +0000 (00:42 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock.example
wdriver.rs
wdriver/Cargo.toml
wdriver/wdt-simple.rs

index b9c9a462cad426d33e3e68c421bce48762b3a3d1..651c4aa49737465018e92bbc2c80758837fc00f1 100644 (file)
@@ -1649,6 +1649,7 @@ dependencies = [
  "nix 0.19.1",
  "num-derive",
  "num-traits",
+ "once_cell",
  "otter",
  "parking_lot",
  "regex",
index 91242b587774ccc8fe7a43969c99215f2ffe3a0f..8705a9bc7247b011a59435e99672d5a087b3cdfa 100644 (file)
@@ -57,6 +57,8 @@ pub type AE = anyhow::Error;
 
 pub const URL : &str = "http://localhost:8000";
 
+pub fn default<T:Default>() -> T { Default::default() }
+
 use t4::Capabilities;
 use otter::config::DAEMON_STARTUP_REPORT;
 
@@ -724,6 +726,7 @@ pub struct Window {
 pub struct WindowGuard<'g> {
   su: &'g mut Setup,
   w: &'g Window,
+  matrix: once_cell::sync::OnceCell<()>,
 }
 
 impl Debug for WindowGuard<'_> {
@@ -778,7 +781,15 @@ impl<'g> PieceElement<'g> {
   }
 
   #[throws(AE)]
-  pub fn pos(&self) -> WebPos {
+  pub fn posw(&self) -> WebPos {
+    let ary = self.w.matrix.get_or_try_init(||{
+      let ary = self.w.su.driver.execute_script(r#"
+        let m = space.getScreenCTM();
+        return [m.a, m.b, m.c, m.d, m.e, m.f];
+      "#)?;
+      dbg!(ary.value());
+      Ok::<_,AE>(())
+    })?;
     (||{
       Ok::<_,AE>( todo!() )
     })()
@@ -850,7 +861,11 @@ impl Setup {
         .context("switch to window")?;
       self.current_window = Some(w.name.clone());
     }
-    WindowGuard { su: self, w }
+    WindowGuard {
+      w,
+      su: self,
+      matrix: default(),
+    }
   }
 }
 
index 4564bb76b5c1237d5b47dabb2b54d4badaaddac7..56a869e77b08d502797139a3f25baa13f05ce70e 100644 (file)
@@ -24,6 +24,7 @@ libc = "0.2"
 nix = "0.19"
 num-derive = "0.3"
 num-traits = "0.2"
+once_cell = "1"
 parking_lot = "0.11"
 regex = "1"
 serde = { version = "1", features = ["derive","rc"] }
index 1dc66eb1b47163d81d27171f942497003c35643e..595e02cc36ab66c8cb356812f26bdbe8caa4febe 100644 (file)
@@ -25,6 +25,9 @@ fn main(){
       dbg!(
         p1.posg(),
       );
+      dbg!(
+        p1.posw(),
+      );
       
       w.action_chain()
         .move_to_element_center(&p1)