autocommit 2022-04-30 13:45:20 CEST
This commit is contained in:
parent
4e717ecef8
commit
3d4a6b21f3
26 changed files with 340 additions and 60 deletions
|
|
@ -33,6 +33,7 @@ use {
|
|||
smallvec::SmallVec,
|
||||
std::rc::Rc,
|
||||
};
|
||||
use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeSeatState {
|
||||
|
|
@ -155,7 +156,7 @@ 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) => self.motion_event(dx, dy),
|
||||
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),
|
||||
|
|
@ -183,7 +184,8 @@ impl WlSeatGlobal {
|
|||
self.set_new_position(x, y);
|
||||
}
|
||||
|
||||
fn motion_event(self: &Rc<Self>, dx: Fixed, dy: Fixed) {
|
||||
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;
|
||||
|
|
@ -327,8 +329,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();
|
||||
|
|
@ -338,6 +340,18 @@ impl WlSeatGlobal {
|
|||
})
|
||||
}
|
||||
|
||||
fn for_each_relative_pointer<C>(&self, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<ZwpRelativePointerV1>),
|
||||
{
|
||||
self.for_each_seat(0, client, |seat| {
|
||||
let pointers = seat.relative_pointers.lock();
|
||||
for pointer in pointers.values() {
|
||||
f(pointer);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn for_each_kb<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<WlKeyboard>),
|
||||
|
|
@ -383,14 +397,24 @@ 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| {
|
||||
f(p);
|
||||
});
|
||||
client.flush();
|
||||
// client.flush();
|
||||
}
|
||||
|
||||
fn surface_relative_pointer_event<F>(&self, surface: &WlSurface, mut f: F)
|
||||
where
|
||||
F: FnMut(&Rc<ZwpRelativePointerV1>),
|
||||
{
|
||||
let client = &surface.client;
|
||||
self.for_each_relative_pointer(client.id, |p| {
|
||||
f(p);
|
||||
});
|
||||
}
|
||||
|
||||
fn surface_kb_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
||||
|
|
@ -401,7 +425,7 @@ impl WlSeatGlobal {
|
|||
self.for_each_kb(ver, client.id, |p| {
|
||||
f(p);
|
||||
});
|
||||
client.flush();
|
||||
// client.flush();
|
||||
}
|
||||
|
||||
fn set_new_position(self: &Rc<Self>, x: Fixed, y: Fixed) {
|
||||
|
|
@ -492,6 +516,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) {
|
||||
self.surface_relative_pointer_event(surface, |p| {
|
||||
p.send_relative_motion(time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Enter callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn enter_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) {
|
||||
|
|
@ -594,7 +627,7 @@ impl WlSeatGlobal {
|
|||
if let Some(src) = &dnd.src {
|
||||
src.on_leave();
|
||||
}
|
||||
surface.client.flush();
|
||||
// surface.client.flush();
|
||||
}
|
||||
|
||||
pub fn dnd_surface_drop(&self, surface: &WlSurface, dnd: &Dnd) {
|
||||
|
|
@ -606,7 +639,7 @@ impl WlSeatGlobal {
|
|||
if let Some(src) = &dnd.src {
|
||||
src.on_drop();
|
||||
}
|
||||
surface.client.flush();
|
||||
// surface.client.flush();
|
||||
}
|
||||
|
||||
pub fn dnd_surface_enter(
|
||||
|
|
@ -628,7 +661,7 @@ impl WlSeatGlobal {
|
|||
dd.send_enter(surface.id, x, y, WlDataOfferId::NONE, serial);
|
||||
})
|
||||
}
|
||||
surface.client.flush();
|
||||
// surface.client.flush();
|
||||
}
|
||||
|
||||
pub fn dnd_surface_motion(&self, surface: &WlSurface, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
|
|
@ -637,6 +670,6 @@ impl WlSeatGlobal {
|
|||
dd.send_motion(x, y);
|
||||
})
|
||||
}
|
||||
surface.client.flush();
|
||||
// surface.client.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ impl PointerOwnerHolder {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply_changes(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.owner.get().apply_changes(seat)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl PendingScroll {
|
|||
|
||||
pub struct WlPointer {
|
||||
id: WlPointerId,
|
||||
seat: Rc<WlSeat>,
|
||||
pub seat: Rc<WlSeat>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ impl Object for WlPointer {
|
|||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlPointer);
|
||||
dedicated_add_obj!(WlPointer, WlPointerId, pointers);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlPointerError {
|
||||
|
|
|
|||
104
src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs
Normal file
104
src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
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::*;
|
||||
|
||||
pub struct ZwpRelativePointerManagerV1Global {
|
||||
pub name: GlobalName,
|
||||
}
|
||||
|
||||
pub struct ZwpRelativePointerManagerV1 {
|
||||
pub id: ZwpRelativePointerManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl ZwpRelativePointerManagerV1Global {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: ZwpRelativePointerManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
_version: u32,
|
||||
) -> Result<(), ZwpRelativePointerManagerV1Error> {
|
||||
let obj = Rc::new(ZwpRelativePointerManagerV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(ZwpRelativePointerManagerV1Global, ZwpRelativePointerManagerV1, ZwpRelativePointerManagerV1Error);
|
||||
|
||||
impl Global for ZwpRelativePointerManagerV1Global {
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(ZwpRelativePointerManagerV1Global);
|
||||
|
||||
impl ZwpRelativePointerManagerV1 {
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpRelativePointerManagerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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 {
|
||||
id: req.id,
|
||||
client: self.client.clone(),
|
||||
seat: pointer.seat.clone(),
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(self.client, rp);
|
||||
self.client.add_client_obj(&rp)?;
|
||||
pointer.seat.relative_pointers.set(req.id, rp);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
ZwpRelativePointerManagerV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_RELATIVE_POINTER => get_relative_pointer,
|
||||
}
|
||||
|
||||
impl Object for ZwpRelativePointerManagerV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
GET_RELATIVE_POINTER + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpRelativePointerManagerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpRelativePointerManagerV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpRelativePointerManagerV1Error, MsgParserError);
|
||||
efrom!(ZwpRelativePointerManagerV1Error, ClientError);
|
||||
62
src/ifs/wl_seat/zwp_relative_pointer_v1.rs
Normal file
62
src/ifs/wl_seat/zwp_relative_pointer_v1.rs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
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::*;
|
||||
|
||||
pub struct ZwpRelativePointerV1 {
|
||||
pub id: ZwpRelativePointerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub seat: Rc<WlSeat>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl ZwpRelativePointerV1 {
|
||||
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,
|
||||
utime_lo: time_usec as u32,
|
||||
dx,
|
||||
dy,
|
||||
dx_unaccelerated,
|
||||
dy_unaccelerated,
|
||||
});
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpRelativePointerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.seat.relative_pointers.remove(&self.id);
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
ZwpRelativePointerV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for ZwpRelativePointerV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpRelativePointerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpRelativePointerV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(Box<MsgParserError>),
|
||||
}
|
||||
efrom!(ZwpRelativePointerV1Error, ClientError);
|
||||
efrom!(ZwpRelativePointerV1Error, MsgParserError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue