Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zwp_locked_pointer_v1::set_cursor_position_hint is unimplemented #341

Open
tadeokondrak opened this issue Jan 5, 2025 · 0 comments
Open

Comments

@tadeokondrak
Copy link
Contributor

Currently using this which works but is too hacky to PR:

Patch
diff --git a/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs b/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs
index 2c1b83b8..3267d5b6 100644
--- a/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs
+++ b/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs
@@ -61,6 +61,7 @@ pub struct SeatConstraint {
     pub one_shot: bool,
     pub status: Cell<SeatConstraintStatus>,
     pub ty: ConstraintType,
+    pub cursor_position_hint: Cell<Option<(Fixed, Fixed)>>,
 }
 
 impl SeatConstraint {
@@ -129,6 +130,17 @@ impl SeatConstraint {
         self.region.set(region);
         Ok(())
     }
+
+    fn warp_to_hint(&self) {
+        if let Some((x, y)) = self.cursor_position_hint.get() {
+            let surface_pos = self.surface.buffer_abs_pos.get();
+            self.seat.motion_event_abs(
+                0,
+                Fixed::from_int(surface_pos.x1()) + x,
+                Fixed::from_int(surface_pos.y1()) + y,
+            );
+        }
+    }
 }
 
 pub trait ConstraintOwner {
@@ -221,6 +233,7 @@ impl ZwpPointerConstraintsV1 {
             one_shot,
             status: Cell::new(SeatConstraintStatus::Inactive),
             ty,
+            cursor_position_hint: Cell::new(None),
         }))
     }
 }
diff --git a/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs b/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs
index 581df25c..0427e7dc 100644
--- a/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs
+++ b/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs
@@ -23,6 +23,7 @@ impl ZwpLockedPointerV1RequestHandler for ZwpLockedPointerV1 {
     type Error = ZwpLockedPointerV1Error;
 
     fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
+        self.constraint.warp_to_hint();
         self.constraint.detach();
         self.constraint.client.remove_obj(self)?;
         Ok(())
@@ -30,9 +31,10 @@ impl ZwpLockedPointerV1RequestHandler for ZwpLockedPointerV1 {
 
     fn set_cursor_position_hint(
         &self,
-        _req: SetCursorPositionHint,
+        req: SetCursorPositionHint,
         _slf: &Rc<Self>,
     ) -> Result<(), Self::Error> {
+        self.constraint.cursor_position_hint.set(Some((req.surface_x, req.surface_y)));
         Ok(())
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant