Skip to content

Commit

Permalink
Fix tablet input
Browse files Browse the repository at this point in the history
We need to call `add_tablet` for each tablet device, not just if the
capability is new. Also, the tool needs to be added with `add_tool`.

`xournalpp` seems to be working now.
  • Loading branch information
ids1024 authored and Drakulix committed May 15, 2024
1 parent 36bf611 commit 46fd6eb
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,12 @@ impl State {
InputEvent::DeviceAdded { device } => {
let shell = self.common.shell.read().unwrap();
let seat = shell.seats.last_active();
for cap in seat.devices().add_device(&device) {
match cap {
DeviceCapability::TabletTool => {
seat.tablet_seat().add_tablet::<Self>(
&self.common.display_handle,
&TabletDescriptor::from(&device),
);
}
// TODO: Handle touch
_ => {}
}
seat.devices().add_device(&device);
if device.has_capability(DeviceCapability::TabletTool) {
seat.tablet_seat().add_tablet::<Self>(
&self.common.display_handle,
&TabletDescriptor::from(&device),
);
}
#[cfg(feature = "debug")]
{
Expand All @@ -166,14 +161,12 @@ impl State {
for seat in &mut self.common.shell.read().unwrap().seats.iter() {
let devices = seat.devices();
if devices.has_device(&device) {
for cap in devices.remove_device(&device) {
match cap {
DeviceCapability::TabletTool => {
seat.tablet_seat()
.remove_tablet(&TabletDescriptor::from(&device));
}
// TODO: Handle touch
_ => {}
devices.remove_device(&device);
if device.has_capability(DeviceCapability::TabletTool) {
seat.tablet_seat()
.remove_tablet(&TabletDescriptor::from(&device));
if seat.tablet_seat().count_tablets() == 0 {
seat.tablet_seat().clear_tools();
}
}
break;
Expand Down Expand Up @@ -1574,9 +1567,10 @@ impl State {
let tablet_seat = seat.tablet_seat();

let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
let tool = tablet_seat.get_tool(&event.tool());
let tool =
tablet_seat.add_tool::<Self>(&self.common.display_handle, &event.tool());

if let (Some(tablet), Some(tool)) = (tablet, tool) {
if let Some(tablet) = tablet {
match event.state() {
ProximityState::In => {
if let Some(under) =
Expand Down

0 comments on commit 46fd6eb

Please sign in to comment.