mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-26 21:58:10 +01:00
Support pointer gestures
This commit is contained in:
parent
4ecf1c2e71
commit
7896d88c8c
3 changed files with 170 additions and 37 deletions
|
@ -17,8 +17,8 @@ use smithay::{
|
||||||
},
|
},
|
||||||
delegate_compositor, delegate_cursor_shape, delegate_data_control, delegate_data_device,
|
delegate_compositor, delegate_cursor_shape, delegate_data_control, delegate_data_device,
|
||||||
delegate_fractional_scale, delegate_keyboard_shortcuts_inhibit, delegate_layer_shell,
|
delegate_fractional_scale, delegate_keyboard_shortcuts_inhibit, delegate_layer_shell,
|
||||||
delegate_output, delegate_pointer_constraints, delegate_presentation,
|
delegate_output, delegate_pointer_constraints, delegate_pointer_gestures,
|
||||||
delegate_primary_selection, delegate_relative_pointer, delegate_seat,
|
delegate_presentation, delegate_primary_selection, delegate_relative_pointer, delegate_seat,
|
||||||
delegate_security_context, delegate_shm, delegate_tablet_manager, delegate_viewporter,
|
delegate_security_context, delegate_shm, delegate_tablet_manager, delegate_viewporter,
|
||||||
delegate_xdg_activation, delegate_xwayland_keyboard_grab, delegate_xwayland_shell,
|
delegate_xdg_activation, delegate_xwayland_keyboard_grab, delegate_xwayland_shell,
|
||||||
desktop::{
|
desktop::{
|
||||||
|
@ -1036,6 +1036,8 @@ impl XdgActivationHandler for State {
|
||||||
}
|
}
|
||||||
delegate_xdg_activation!(State);
|
delegate_xdg_activation!(State);
|
||||||
|
|
||||||
|
delegate_pointer_gestures!(State);
|
||||||
|
|
||||||
impl Pinnacle {
|
impl Pinnacle {
|
||||||
fn position_popup(&self, popup: &PopupSurface) {
|
fn position_popup(&self, popup: &PopupSurface) {
|
||||||
trace!("State::position_popup");
|
trace!("State::position_popup");
|
||||||
|
|
198
src/input.rs
198
src/input.rs
|
@ -21,15 +21,21 @@ use pinnacle_api_defs::pinnacle::input::v0alpha1::{
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
input::{
|
input::{
|
||||||
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,
|
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, GestureBeginEvent,
|
||||||
KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,
|
GestureEndEvent, InputBackend, InputEvent, KeyState, KeyboardKeyEvent,
|
||||||
|
PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,
|
||||||
},
|
},
|
||||||
renderer::utils::with_renderer_surface_state,
|
renderer::utils::with_renderer_surface_state,
|
||||||
},
|
},
|
||||||
desktop::{layer_map_for_output, space::SpaceElement, WindowSurfaceType},
|
desktop::{layer_map_for_output, space::SpaceElement, WindowSurfaceType},
|
||||||
input::{
|
input::{
|
||||||
keyboard::{keysyms, FilterResult, ModifiersState},
|
keyboard::{keysyms, FilterResult, ModifiersState},
|
||||||
pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent},
|
pointer::{
|
||||||
|
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||||
|
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||||
|
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent,
|
||||||
|
RelativeMotionEvent,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
reexports::input::{self, Led},
|
reexports::input::{self, Led},
|
||||||
utils::{Logical, Point, Rectangle, SERIAL_COUNTER},
|
utils::{Logical, Point, Rectangle, SERIAL_COUNTER},
|
||||||
|
@ -295,17 +301,32 @@ impl Pinnacle {
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn process_input_event<B: InputBackend>(&mut self, event: InputEvent<B>) {
|
pub fn process_input_event<B: InputBackend>(&mut self, event: InputEvent<B>) {
|
||||||
match event {
|
self.pinnacle
|
||||||
// TODO: rest of input events
|
.idle_notifier_state
|
||||||
|
.notify_activity(&self.pinnacle.seat);
|
||||||
|
|
||||||
|
match event {
|
||||||
// InputEvent::DeviceAdded { device } => todo!(),
|
// InputEvent::DeviceAdded { device } => todo!(),
|
||||||
// InputEvent::DeviceRemoved { device } => todo!(),
|
// InputEvent::DeviceRemoved { device } => todo!(),
|
||||||
InputEvent::Keyboard { event } => self.keyboard::<B>(event),
|
InputEvent::Keyboard { event } => self.on_keyboard::<B>(event),
|
||||||
InputEvent::PointerMotion { event } => self.pointer_motion::<B>(event),
|
|
||||||
InputEvent::PointerMotionAbsolute { event } => self.pointer_motion_absolute::<B>(event),
|
|
||||||
InputEvent::PointerButton { event } => self.pointer_button::<B>(event),
|
|
||||||
InputEvent::PointerAxis { event } => self.pointer_axis::<B>(event),
|
|
||||||
|
|
||||||
|
InputEvent::PointerMotion { event } => self.on_pointer_motion::<B>(event),
|
||||||
|
InputEvent::PointerMotionAbsolute { event } => {
|
||||||
|
self.on_pointer_motion_absolute::<B>(event)
|
||||||
|
}
|
||||||
|
InputEvent::PointerButton { event } => self.on_pointer_button::<B>(event),
|
||||||
|
InputEvent::PointerAxis { event } => self.on_pointer_axis::<B>(event),
|
||||||
|
|
||||||
|
InputEvent::GestureSwipeBegin { event } => self.on_gesture_swipe_begin::<B>(event),
|
||||||
|
InputEvent::GestureSwipeUpdate { event } => self.on_gesture_swipe_update::<B>(event),
|
||||||
|
InputEvent::GestureSwipeEnd { event } => self.on_gesture_swipe_end::<B>(event),
|
||||||
|
InputEvent::GesturePinchBegin { event } => self.on_gesture_pinch_begin::<B>(event),
|
||||||
|
InputEvent::GesturePinchUpdate { event } => self.on_gesture_pinch_update::<B>(event),
|
||||||
|
InputEvent::GesturePinchEnd { event } => self.on_gesture_pinch_end::<B>(event),
|
||||||
|
InputEvent::GestureHoldBegin { event } => self.on_gesture_hold_begin::<B>(event),
|
||||||
|
InputEvent::GestureHoldEnd { event } => self.on_gesture_hold_end::<B>(event),
|
||||||
|
|
||||||
|
// TODO: rest of input events
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,11 +425,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keyboard<I: InputBackend>(&mut self, event: I::KeyboardKeyEvent) {
|
fn on_keyboard<I: InputBackend>(&mut self, event: I::KeyboardKeyEvent) {
|
||||||
self.pinnacle
|
|
||||||
.idle_notifier_state
|
|
||||||
.notify_activity(&self.pinnacle.seat);
|
|
||||||
|
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
let time = event.time_msec();
|
let time = event.time_msec();
|
||||||
let press_state = event.state();
|
let press_state = event.state();
|
||||||
|
@ -602,11 +619,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pointer_button<I: InputBackend>(&mut self, event: I::PointerButtonEvent) {
|
fn on_pointer_button<I: InputBackend>(&mut self, event: I::PointerButtonEvent) {
|
||||||
self.pinnacle
|
|
||||||
.idle_notifier_state
|
|
||||||
.notify_activity(&self.pinnacle.seat);
|
|
||||||
|
|
||||||
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -680,11 +693,7 @@ impl State {
|
||||||
pointer.frame(self);
|
pointer.frame(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pointer_axis<I: InputBackend>(&mut self, event: I::PointerAxisEvent) {
|
fn on_pointer_axis<I: InputBackend>(&mut self, event: I::PointerAxisEvent) {
|
||||||
self.pinnacle
|
|
||||||
.idle_notifier_state
|
|
||||||
.notify_activity(&self.pinnacle.seat);
|
|
||||||
|
|
||||||
let source = event.source();
|
let source = event.source();
|
||||||
|
|
||||||
let horizontal_amount = event
|
let horizontal_amount = event
|
||||||
|
@ -732,11 +741,10 @@ impl State {
|
||||||
///
|
///
|
||||||
/// This *should* only be generated on the winit backend.
|
/// This *should* only be generated on the winit backend.
|
||||||
/// Unless there's a case where it's generated on udev that I'm unaware of.
|
/// Unless there's a case where it's generated on udev that I'm unaware of.
|
||||||
fn pointer_motion_absolute<I: InputBackend>(&mut self, event: I::PointerMotionAbsoluteEvent) {
|
fn on_pointer_motion_absolute<I: InputBackend>(
|
||||||
self.pinnacle
|
&mut self,
|
||||||
.idle_notifier_state
|
event: I::PointerMotionAbsoluteEvent,
|
||||||
.notify_activity(&self.pinnacle.seat);
|
) {
|
||||||
|
|
||||||
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
error!("Pointer motion absolute received with no pointer on seat");
|
error!("Pointer motion absolute received with no pointer on seat");
|
||||||
return;
|
return;
|
||||||
|
@ -784,11 +792,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pointer_motion<I: InputBackend>(&mut self, event: I::PointerMotionEvent) {
|
fn on_pointer_motion<I: InputBackend>(&mut self, event: I::PointerMotionEvent) {
|
||||||
self.pinnacle
|
|
||||||
.idle_notifier_state
|
|
||||||
.notify_activity(&self.pinnacle.seat);
|
|
||||||
|
|
||||||
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
error!("Pointer motion received with no pointer on seat");
|
error!("Pointer motion received with no pointer on seat");
|
||||||
return;
|
return;
|
||||||
|
@ -971,6 +975,130 @@ impl State {
|
||||||
self.schedule_render(&output);
|
self.schedule_render(&output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn on_gesture_swipe_begin<I: InputBackend>(&mut self, event: I::GestureSwipeBeginEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
pointer.gesture_swipe_begin(
|
||||||
|
self,
|
||||||
|
&GestureSwipeBeginEvent {
|
||||||
|
serial: SERIAL_COUNTER.next_serial(),
|
||||||
|
time: event.time_msec(),
|
||||||
|
fingers: event.fingers(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_gesture_swipe_update<I: InputBackend>(&mut self, event: I::GestureSwipeUpdateEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
use smithay::backend::input::GestureSwipeUpdateEvent as _;
|
||||||
|
|
||||||
|
pointer.gesture_swipe_update(
|
||||||
|
self,
|
||||||
|
&GestureSwipeUpdateEvent {
|
||||||
|
time: event.time_msec(),
|
||||||
|
delta: event.delta(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_gesture_swipe_end<I: InputBackend>(&mut self, event: I::GestureSwipeEndEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
pointer.gesture_swipe_end(
|
||||||
|
self,
|
||||||
|
&GestureSwipeEndEvent {
|
||||||
|
serial: SERIAL_COUNTER.next_serial(),
|
||||||
|
time: event.time_msec(),
|
||||||
|
cancelled: event.cancelled(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_gesture_pinch_begin<I: InputBackend>(&mut self, event: I::GesturePinchBeginEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
pointer.gesture_pinch_begin(
|
||||||
|
self,
|
||||||
|
&GesturePinchBeginEvent {
|
||||||
|
serial: SERIAL_COUNTER.next_serial(),
|
||||||
|
time: event.time_msec(),
|
||||||
|
fingers: event.fingers(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_gesture_pinch_update<I: InputBackend>(&mut self, event: I::GesturePinchUpdateEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
use smithay::backend::input::GesturePinchUpdateEvent as _;
|
||||||
|
|
||||||
|
pointer.gesture_pinch_update(
|
||||||
|
self,
|
||||||
|
&GesturePinchUpdateEvent {
|
||||||
|
time: event.time_msec(),
|
||||||
|
delta: event.delta(),
|
||||||
|
scale: event.scale(),
|
||||||
|
rotation: event.rotation(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_gesture_pinch_end<I: InputBackend>(&mut self, event: I::GesturePinchEndEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
pointer.gesture_pinch_end(
|
||||||
|
self,
|
||||||
|
&GesturePinchEndEvent {
|
||||||
|
serial: SERIAL_COUNTER.next_serial(),
|
||||||
|
time: event.time_msec(),
|
||||||
|
cancelled: event.cancelled(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_gesture_hold_begin<I: InputBackend>(&mut self, event: I::GestureHoldBeginEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
pointer.gesture_hold_begin(
|
||||||
|
self,
|
||||||
|
&GestureHoldBeginEvent {
|
||||||
|
serial: SERIAL_COUNTER.next_serial(),
|
||||||
|
time: event.time_msec(),
|
||||||
|
fingers: event.fingers(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_gesture_hold_end<I: InputBackend>(&mut self, event: I::GestureHoldEndEvent) {
|
||||||
|
let Some(pointer) = self.pinnacle.seat.get_pointer() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
pointer.gesture_hold_end(
|
||||||
|
self,
|
||||||
|
&GestureHoldEndEvent {
|
||||||
|
serial: SERIAL_COUNTER.next_serial(),
|
||||||
|
time: event.time_msec(),
|
||||||
|
cancelled: event.cancelled(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clamp the given point within the given rects.
|
/// Clamp the given point within the given rects.
|
||||||
|
|
|
@ -45,6 +45,7 @@ use smithay::{
|
||||||
keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitState,
|
keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitState,
|
||||||
output::OutputManagerState,
|
output::OutputManagerState,
|
||||||
pointer_constraints::PointerConstraintsState,
|
pointer_constraints::PointerConstraintsState,
|
||||||
|
pointer_gestures::PointerGesturesState,
|
||||||
relative_pointer::RelativePointerManagerState,
|
relative_pointer::RelativePointerManagerState,
|
||||||
security_context::SecurityContextState,
|
security_context::SecurityContextState,
|
||||||
selection::{
|
selection::{
|
||||||
|
@ -129,6 +130,7 @@ pub struct Pinnacle {
|
||||||
pub xdg_activation_state: XdgActivationState,
|
pub xdg_activation_state: XdgActivationState,
|
||||||
pub xdg_decoration_state: XdgDecorationState,
|
pub xdg_decoration_state: XdgDecorationState,
|
||||||
pub kde_decoration_state: KdeDecorationState,
|
pub kde_decoration_state: KdeDecorationState,
|
||||||
|
pub pointer_gestures_state: PointerGesturesState,
|
||||||
|
|
||||||
pub lock_state: LockState,
|
pub lock_state: LockState,
|
||||||
|
|
||||||
|
@ -362,6 +364,7 @@ impl Pinnacle {
|
||||||
&display_handle,
|
&display_handle,
|
||||||
org_kde_kwin_server_decoration_manager::Mode::Client,
|
org_kde_kwin_server_decoration_manager::Mode::Client,
|
||||||
),
|
),
|
||||||
|
pointer_gestures_state: PointerGesturesState::new::<State>(&display_handle),
|
||||||
|
|
||||||
lock_state: LockState::default(),
|
lock_state: LockState::default(),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue