1
0
Fork 0
forked from wry/wry

cursor_user: ensure cursor position is on live output

This commit is contained in:
kossLAN 2026-06-08 20:31:16 -04:00
parent dc62d2240f
commit 2b676d72ce
No known key found for this signature in database

View file

@ -224,6 +224,8 @@ impl CursorUserGroup {
if user.output.get().id == output.id { if user.output.get().id == output.id {
user.set_output(next); user.set_output(next);
user.set_position(x, y); user.set_position(x, y);
} else {
user.ensure_position_on_live_output();
} }
} }
} }
@ -368,6 +370,19 @@ impl CursorUser {
self.desired_known_cursor.set(None); self.desired_known_cursor.set(None);
} }
fn ensure_position_on_live_output(&self) {
let (x, y) = self.pos.get();
let x_int = x.round_down();
let y_int = y.round_down();
let (output, new_x, new_y) = self.group.state.find_closest_output(x_int, y_int);
if self.output.get().id != output.id {
self.set_output(&output);
}
if (x_int, y_int) != (new_x, new_y) {
self.set_position(x.apply_fract(new_x), y.apply_fract(new_y));
}
}
fn is_active(&self) -> bool { fn is_active(&self) -> bool {
self.group.active_id.get() == Some(self.id) self.group.active_id.get() == Some(self.id)
} }