autocommit 2022-04-30 13:53:02 CEST
This commit is contained in:
parent
3d4a6b21f3
commit
ac56970f14
14 changed files with 132 additions and 53 deletions
|
|
@ -28,6 +28,7 @@ use {
|
|||
wl_keyboard::{WlKeyboard, WlKeyboardError, REPEAT_INFO_SINCE},
|
||||
wl_pointer::WlPointer,
|
||||
wl_touch::WlTouch,
|
||||
zwp_relative_pointer_v1::ZwpRelativePointerV1,
|
||||
},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
|
|
@ -50,7 +51,7 @@ use {
|
|||
},
|
||||
wire::{
|
||||
wl_seat::*, WlDataDeviceId, WlKeyboardId, WlPointerId, WlSeatId,
|
||||
ZwpPrimarySelectionDeviceV1Id,
|
||||
ZwpPrimarySelectionDeviceV1Id, ZwpRelativePointerV1Id,
|
||||
},
|
||||
xkbcommon::{XkbKeymap, XkbState},
|
||||
},
|
||||
|
|
@ -67,8 +68,6 @@ use {
|
|||
thiserror::Error,
|
||||
uapi::{c, Errno, OwnedFd},
|
||||
};
|
||||
use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1;
|
||||
use crate::wire::ZwpRelativePointerV1Id;
|
||||
|
||||
const POINTER: u32 = 1;
|
||||
const KEYBOARD: u32 = 2;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use {
|
|||
AXIS_SOURCE_SINCE_VERSION, AXIS_STOP_SINCE_VERSION,
|
||||
POINTER_FRAME_SINCE_VERSION, WHEEL_TILT, WHEEL_TILT_SINCE_VERSION,
|
||||
},
|
||||
zwp_relative_pointer_v1::ZwpRelativePointerV1,
|
||||
Dnd, SeatId, WlSeat, WlSeatGlobal, CHANGE_CURSOR_MOVED,
|
||||
},
|
||||
wl_surface::{xdg_surface::xdg_popup::XdgPopup, WlSurface},
|
||||
|
|
@ -33,7 +34,6 @@ use {
|
|||
smallvec::SmallVec,
|
||||
std::rc::Rc,
|
||||
};
|
||||
use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeSeatState {
|
||||
|
|
@ -156,7 +156,13 @@ impl WlSeatGlobal {
|
|||
match event {
|
||||
InputEvent::Key(k, s) => self.key_event(k, s),
|
||||
InputEvent::ConnectorPosition(o, x, y) => self.connector_position_event(o, x, y),
|
||||
InputEvent::Motion { dx, dy, dx_unaccelerated, dy_unaccelerated, time_usec } => self.motion_event(time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated),
|
||||
InputEvent::Motion {
|
||||
dx,
|
||||
dy,
|
||||
dx_unaccelerated,
|
||||
dy_unaccelerated,
|
||||
time_usec,
|
||||
} => self.motion_event(time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated),
|
||||
InputEvent::Button(b, s) => self.pointer_owner.button(self, b, s),
|
||||
|
||||
InputEvent::AxisSource(s) => self.pointer_owner.axis_source(s),
|
||||
|
|
@ -184,8 +190,22 @@ impl WlSeatGlobal {
|
|||
self.set_new_position(x, y);
|
||||
}
|
||||
|
||||
fn motion_event(self: &Rc<Self>, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) {
|
||||
self.pointer_owner.relative_motion(self, time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated);
|
||||
fn motion_event(
|
||||
self: &Rc<Self>,
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
) {
|
||||
self.pointer_owner.relative_motion(
|
||||
self,
|
||||
time_usec,
|
||||
dx,
|
||||
dy,
|
||||
dx_unaccelerated,
|
||||
dy_unaccelerated,
|
||||
);
|
||||
let (mut x, mut y) = self.pos.get();
|
||||
x += dx;
|
||||
y += dy;
|
||||
|
|
@ -329,8 +349,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn for_each_pointer<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<WlPointer>),
|
||||
where
|
||||
C: FnMut(&Rc<WlPointer>),
|
||||
{
|
||||
self.for_each_seat(ver, client, |seat| {
|
||||
let pointers = seat.pointers.lock();
|
||||
|
|
@ -397,8 +417,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn surface_pointer_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
||||
where
|
||||
F: FnMut(&Rc<WlPointer>),
|
||||
where
|
||||
F: FnMut(&Rc<WlPointer>),
|
||||
{
|
||||
let client = &surface.client;
|
||||
self.for_each_pointer(ver, client.id, |p| {
|
||||
|
|
@ -518,7 +538,15 @@ impl WlSeatGlobal {
|
|||
|
||||
// Relative motion callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn relative_motion_surface(&self, surface: &WlSurface, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) {
|
||||
pub fn relative_motion_surface(
|
||||
&self,
|
||||
surface: &WlSurface,
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
) {
|
||||
self.surface_relative_pointer_event(surface, |p| {
|
||||
p.send_relative_motion(time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -58,9 +58,24 @@ impl PointerOwnerHolder {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn relative_motion(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) {
|
||||
pub fn relative_motion(
|
||||
&self,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
) {
|
||||
if let Some(n) = self.owner.get().axis_node(seat) {
|
||||
n.node_on_pointer_relative_motion(seat, time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated);
|
||||
n.node_on_pointer_relative_motion(
|
||||
seat,
|
||||
time_usec,
|
||||
dx,
|
||||
dy,
|
||||
dx_unaccelerated,
|
||||
dy_unaccelerated,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1;
|
||||
use crate::leaks::Tracker;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::wire::ZwpRelativePointerManagerV1Id;
|
||||
use crate::wire::zwp_relative_pointer_manager_v1::*;
|
||||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwp_relative_pointer_manager_v1::*, ZwpRelativePointerManagerV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct ZwpRelativePointerManagerV1Global {
|
||||
pub name: GlobalName,
|
||||
|
|
@ -41,7 +44,11 @@ impl ZwpRelativePointerManagerV1Global {
|
|||
}
|
||||
}
|
||||
|
||||
global_base!(ZwpRelativePointerManagerV1Global, ZwpRelativePointerManagerV1, ZwpRelativePointerManagerV1Error);
|
||||
global_base!(
|
||||
ZwpRelativePointerManagerV1Global,
|
||||
ZwpRelativePointerManagerV1,
|
||||
ZwpRelativePointerManagerV1Error
|
||||
);
|
||||
|
||||
impl Global for ZwpRelativePointerManagerV1Global {
|
||||
fn singleton(&self) -> bool {
|
||||
|
|
@ -62,7 +69,10 @@ impl ZwpRelativePointerManagerV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_relative_pointer(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpRelativePointerManagerV1Error> {
|
||||
fn get_relative_pointer(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpRelativePointerManagerV1Error> {
|
||||
let req: GetRelativePointer = self.client.parse(self, parser)?;
|
||||
let pointer = self.client.lookup(req.pointer)?;
|
||||
let rp = Rc::new(ZwpRelativePointerV1 {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{WlSeat};
|
||||
use crate::leaks::Tracker;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::wire::ZwpRelativePointerV1Id;
|
||||
use crate::wire::zwp_relative_pointer_v1::*;
|
||||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
fixed::Fixed,
|
||||
ifs::wl_seat::WlSeat,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwp_relative_pointer_v1::*, ZwpRelativePointerV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct ZwpRelativePointerV1 {
|
||||
pub id: ZwpRelativePointerV1Id,
|
||||
|
|
@ -17,7 +20,14 @@ pub struct ZwpRelativePointerV1 {
|
|||
}
|
||||
|
||||
impl ZwpRelativePointerV1 {
|
||||
pub fn send_relative_motion(&self, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) {
|
||||
pub fn send_relative_motion(
|
||||
&self,
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
) {
|
||||
self.client.event(RelativeMotion {
|
||||
self_id: self.id,
|
||||
utime_hi: (time_usec >> 32) as u32,
|
||||
|
|
|
|||
|
|
@ -796,7 +796,15 @@ impl Node for WlSurface {
|
|||
seat.motion_surface(&*self, x, y)
|
||||
}
|
||||
|
||||
fn node_on_pointer_relative_motion(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) {
|
||||
fn node_on_pointer_relative_motion(
|
||||
&self,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
) {
|
||||
seat.relative_motion_surface(self, time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue