1
0
Fork 0
forked from wry/wry

backend: add ButtonState

This commit is contained in:
Julian Orth 2025-10-16 19:50:21 +02:00
parent e22e6680b6
commit 0e1be7544f
17 changed files with 75 additions and 66 deletions

View file

@ -8,7 +8,7 @@ use {
crate::{
async_engine::SpawnedFuture,
backend::{
Backend, InputDevice, InputDeviceAccelProfile, InputDeviceCapability,
Backend, ButtonState, InputDevice, InputDeviceAccelProfile, InputDeviceCapability,
InputDeviceClickMethod, InputDeviceGroupId, InputDeviceId, InputEvent, KeyState, Leds,
TransformMatrix, transaction::BackendConnectorTransactionError,
},
@ -598,7 +598,7 @@ impl MetalInputDevice {
self.event(InputEvent::Button {
time_usec,
button,
state: KeyState::Released,
state: ButtonState::Released,
});
}
}

View file

@ -1,6 +1,6 @@
use {
crate::{
backend::{AxisSource, InputEvent, KeyState, ScrollAxis},
backend::{AxisSource, ButtonState, InputEvent, KeyState, ScrollAxis},
backends::metal::MetalBackend,
fixed::Fixed,
ifs::wl_seat::tablet::{
@ -216,12 +216,12 @@ impl MetalBackend {
if dev.pressed_buttons.insert(event.button(), ()).is_some() {
return;
}
KeyState::Pressed
ButtonState::Pressed
} else {
if dev.pressed_buttons.remove(&event.button()).is_none() {
return;
}
KeyState::Released
ButtonState::Released
};
dev.event(InputEvent::Button {
time_usec: event.time_usec(),

View file

@ -4,9 +4,10 @@ use {
async_engine::{Phase, SpawnedFuture},
backend::{
AXIS_120, AxisSource, Backend, BackendConnectorState, BackendDrmDevice, BackendEvent,
Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId, DrmEvent,
InputDevice, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceClickMethod,
InputDeviceId, InputEvent, KeyState, Mode, MonitorInfo, ScrollAxis, TransformMatrix,
ButtonState, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
DrmEvent, InputDevice, InputDeviceAccelProfile, InputDeviceCapability,
InputDeviceClickMethod, InputDeviceId, InputEvent, KeyState, Mode, MonitorInfo,
ScrollAxis, TransformMatrix,
transaction::{
BackendAppliedConnectorTransaction, BackendConnectorTransaction,
BackendConnectorTransactionError, BackendConnectorTransactionType,
@ -817,8 +818,8 @@ impl XBackend {
match event.code() {
XiMotion::OPCODE => self.handle_input_motion(event),
XiEnter::OPCODE => self.handle_input_enter(event),
XiButtonPress::OPCODE => self.handle_input_button_press(event, KeyState::Pressed),
XiButtonRelease::OPCODE => self.handle_input_button_press(event, KeyState::Released),
XiButtonPress::OPCODE => self.handle_input_button_press(event, ButtonState::Pressed),
XiButtonRelease::OPCODE => self.handle_input_button_press(event, ButtonState::Released),
XiKeyPress::OPCODE => self.handle_input_key_press(event, KeyState::Pressed),
XiKeyRelease::OPCODE => self.handle_input_key_press(event, KeyState::Released),
XiHierarchy::OPCODE => self.handle_input_hierarchy(event).await,
@ -829,14 +830,14 @@ impl XBackend {
fn handle_input_button_press(
self: &Rc<Self>,
event: &Event,
state: KeyState,
state: ButtonState,
) -> Result<(), XBackendError> {
let event: XiButtonPress = event.parse()?;
if let Some(seat) = self.mouse_seats.get(&event.deviceid) {
let button = event.detail;
// let button = seat.button_map.get(&event.detail).unwrap_or(event.detail);
if matches!(button, 4..=7) {
if state == KeyState::Pressed {
if state == ButtonState::Pressed {
let (axis, val) = match button {
4 => (ScrollAxis::Vertical, -1),
5 => (ScrollAxis::Vertical, 1),