From d83731e1e51597796ec4df51dd447a95b6ecc105 Mon Sep 17 00:00:00 2001 From: edwloef Date: Thu, 4 Dec 2025 17:16:55 +0100 Subject: [PATCH] Implement `Sub` for `Cursor` --- core/src/mouse/cursor.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/src/mouse/cursor.rs b/core/src/mouse/cursor.rs index 7acf6c7d..3e1d2bf4 100644 --- a/core/src/mouse/cursor.rs +++ b/core/src/mouse/cursor.rs @@ -89,6 +89,20 @@ impl std::ops::Add for Cursor { } } +impl std::ops::Sub for Cursor { + type Output = Self; + + fn sub(self, translation: Vector) -> Self::Output { + match self { + Cursor::Available(point) => Cursor::Available(point - translation), + Cursor::Levitating(point) => { + Cursor::Levitating(point - translation) + } + Cursor::Unavailable => Cursor::Unavailable, + } + } +} + impl std::ops::Mul for Cursor { type Output = Self;