all: implement hardware cursors
This commit is contained in:
parent
6cc97ee56e
commit
3b8935cf55
23 changed files with 614 additions and 91 deletions
|
|
@ -123,6 +123,7 @@ impl ConnectorHandler {
|
|||
pointer_positions: Default::default(),
|
||||
lock_surface: Default::default(),
|
||||
preferred_scale: Cell::new(Fixed::from_int(1)),
|
||||
hardware_cursor: Default::default(),
|
||||
});
|
||||
self.state.add_output_scale(on.preferred_scale.get());
|
||||
let mode = info.initial_mode;
|
||||
|
|
@ -191,6 +192,10 @@ impl ConnectorHandler {
|
|||
while let Some(event) = self.data.connector.event() {
|
||||
match event {
|
||||
ConnectorEvent::Disconnected => break 'outer,
|
||||
ConnectorEvent::HardwareCursor(hc) => {
|
||||
on.hardware_cursor.set(hc);
|
||||
self.state.refresh_hardware_cursors();
|
||||
}
|
||||
ConnectorEvent::ModeChanged(mode) => {
|
||||
on.update_mode(mode);
|
||||
}
|
||||
|
|
|
|||
31
src/tasks/hardware_cursor.rs
Normal file
31
src/tasks/hardware_cursor.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use {
|
||||
crate::{state::State, utils::errorfmt::ErrorFmt},
|
||||
futures_util::{select, FutureExt},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub async fn handle_hardware_cursor_tick(state: Rc<State>) {
|
||||
loop {
|
||||
let cursor = match state.hardware_tick_cursor.pop().await {
|
||||
Some(c) => c,
|
||||
_ => continue,
|
||||
};
|
||||
if !cursor.needs_tick() {
|
||||
continue;
|
||||
}
|
||||
loop {
|
||||
let tick = (cursor.time_until_tick().as_nanos() + 999_999) / 1_000_000;
|
||||
if tick > 0 {
|
||||
let res = select! {
|
||||
_ = state.hardware_tick_cursor.non_empty().fuse() => break,
|
||||
res = state.wheel.timeout(tick as _).fuse() => res,
|
||||
};
|
||||
if let Err(e) = res {
|
||||
log::error!("Could not wait for cursor tick: {}", ErrorFmt(e));
|
||||
break;
|
||||
}
|
||||
}
|
||||
state.refresh_hardware_cursors();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue