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
|
|
@ -79,7 +79,6 @@ impl<T: Vtable> Default for DeviceData<T> {
|
|||
pub struct OfferData<T: Vtable> {
|
||||
device: CloneCell<Option<Rc<T::Device>>>,
|
||||
source: CloneCell<Option<Rc<T::Source>>>,
|
||||
client: Rc<Client>,
|
||||
shared: Rc<SharedState>,
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +189,7 @@ pub fn detach_seat<T: Vtable>(src: &T::Source) {
|
|||
if !data.state.get().contains(SOURCE_STATE_FINISHED) {
|
||||
T::send_cancelled(src);
|
||||
}
|
||||
data.client.flush();
|
||||
// data.client.flush();
|
||||
}
|
||||
|
||||
pub fn offer_source_to<T: Vtable>(src: &Rc<T::Source>, client: &Rc<Client>) {
|
||||
|
|
@ -218,7 +217,6 @@ pub fn offer_source_to<T: Vtable>(src: &Rc<T::Source>, client: &Rc<Client>) {
|
|||
let offer_data = OfferData {
|
||||
device: CloneCell::new(Some(dd.clone())),
|
||||
source: CloneCell::new(Some(src.clone())),
|
||||
client: client.clone(),
|
||||
shared: shared.clone(),
|
||||
};
|
||||
let offer = T::create_offer(client, dd, offer_data, id);
|
||||
|
|
@ -246,8 +244,8 @@ fn add_mime_type<T: Vtable>(src: &T::Source, mime_type: &str) {
|
|||
if data.mime_types.borrow_mut().insert(mime_type.to_string()) {
|
||||
for (_, offer) in &data.offers {
|
||||
T::send_mime_type(&offer, mime_type);
|
||||
let data = T::get_offer_data(&offer);
|
||||
data.client.flush();
|
||||
// let data = T::get_offer_data(&offer);
|
||||
// data.client.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -321,7 +319,7 @@ fn receive<T: Vtable>(offer: &T::Offer, mime_type: &str, fd: Rc<OwnedFd>) {
|
|||
let data = T::get_offer_data(offer);
|
||||
if let Some(src) = data.source.get() {
|
||||
T::send_send(&src, mime_type, fd);
|
||||
let data = T::get_source_data(&src);
|
||||
data.client.flush();
|
||||
// let data = T::get_source_data(&src);
|
||||
// data.client.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ impl WlDataSource {
|
|||
if shared.selected_action.replace(action) != action {
|
||||
for (_, offer) in &self.data.offers {
|
||||
offer.send_action(action);
|
||||
offer.client.flush();
|
||||
// offer.client.flush();
|
||||
}
|
||||
self.send_action(action);
|
||||
self.data.client.flush();
|
||||
// self.data.client.flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ impl WlOutputGlobal {
|
|||
for xdg in xdg.values() {
|
||||
xdg.send_updates();
|
||||
}
|
||||
binding.client.flush();
|
||||
// binding.client.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ mod pointer_owner;
|
|||
pub mod wl_keyboard;
|
||||
pub mod wl_pointer;
|
||||
pub mod wl_touch;
|
||||
pub mod zwp_relative_pointer_manager_v1;
|
||||
pub mod zwp_relative_pointer_v1;
|
||||
|
||||
pub use event_handling::NodeSeatState;
|
||||
use {
|
||||
|
|
@ -65,6 +67,8 @@ 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;
|
||||
|
|
@ -467,7 +471,7 @@ impl WlSeatGlobal {
|
|||
T::send_selection(device, ObjectId::NONE.into());
|
||||
}),
|
||||
}
|
||||
client.flush();
|
||||
// client.flush();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -608,6 +612,7 @@ impl WlSeatGlobal {
|
|||
id,
|
||||
client: client.clone(),
|
||||
pointers: Default::default(),
|
||||
relative_pointers: Default::default(),
|
||||
keyboards: Default::default(),
|
||||
version,
|
||||
tracker: Default::default(),
|
||||
|
|
@ -652,6 +657,7 @@ pub struct WlSeat {
|
|||
pub id: WlSeatId,
|
||||
pub client: Rc<Client>,
|
||||
pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>,
|
||||
relative_pointers: CopyHashMap<ZwpRelativePointerV1Id, Rc<ZwpRelativePointerV1>>,
|
||||
keyboards: CopyHashMap<WlKeyboardId, Rc<WlKeyboard>>,
|
||||
version: u32,
|
||||
tracker: Tracker<Self>,
|
||||
|
|
@ -814,6 +820,7 @@ impl Object for WlSeat {
|
|||
}
|
||||
}
|
||||
self.pointers.clear();
|
||||
self.relative_pointers.clear();
|
||||
self.keyboards.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -796,6 +796,10 @@ 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) {
|
||||
seat.relative_motion_surface(self, time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated);
|
||||
}
|
||||
|
||||
fn node_on_dnd_drop(&self, dnd: &Dnd) {
|
||||
dnd.seat.dnd_surface_drop(self, dnd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ impl XdgToplevel {
|
|||
|
||||
fn send_close(&self) {
|
||||
self.xdg.surface.client.event(Close { self_id: self.id });
|
||||
self.xdg.surface.client.flush();
|
||||
// self.xdg.surface.client.flush();
|
||||
}
|
||||
|
||||
fn send_configure(&self, width: i32, height: i32) {
|
||||
|
|
@ -472,7 +472,7 @@ impl ToplevelNode for XdgToplevel {
|
|||
}
|
||||
self.send_configure_checked(nw, nh);
|
||||
self.xdg.do_send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
// self.xdg.surface.client.flush();
|
||||
}
|
||||
self.xdg.set_absolute_desired_extents(rect);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue