cursor_user: ensure cursor position is on live output
This commit is contained in:
parent
dc62d2240f
commit
2b676d72ce
1 changed files with 15 additions and 0 deletions
|
|
@ -224,6 +224,8 @@ impl CursorUserGroup {
|
|||
if user.output.get().id == output.id {
|
||||
user.set_output(next);
|
||||
user.set_position(x, y);
|
||||
} else {
|
||||
user.ensure_position_on_live_output();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -368,6 +370,19 @@ impl CursorUser {
|
|||
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 {
|
||||
self.group.active_id.get() == Some(self.id)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue