1
0
Fork 0
forked from wry/wry

autocommit 2022-04-30 13:45:20 CEST

This commit is contained in:
Julian Orth 2022-04-30 13:45:20 +02:00
parent 4e717ecef8
commit 3d4a6b21f3
26 changed files with 340 additions and 60 deletions

View file

@ -144,8 +144,13 @@ pub enum AxisSource {
pub enum InputEvent { pub enum InputEvent {
Key(u32, KeyState), Key(u32, KeyState),
ConnectorPosition(ConnectorId, Fixed, Fixed), ConnectorPosition(ConnectorId, Fixed, Fixed),
#[allow(dead_code)] Motion {
Motion(Fixed, Fixed), time_usec: u64,
dx: Fixed,
dy: Fixed,
dx_unaccelerated: Fixed,
dy_unaccelerated: Fixed,
},
Button(u32, KeyState), Button(u32, KeyState),
Axis(Fixed, ScrollAxis), Axis(Fixed, ScrollAxis),

View file

@ -15,6 +15,7 @@ use {
}, },
std::rc::Rc, std::rc::Rc,
}; };
use crate::fixed::Fixed;
macro_rules! unpack { macro_rules! unpack {
($slf:expr, $ev:expr) => {{ ($slf:expr, $ev:expr) => {{
@ -148,7 +149,7 @@ impl MetalBackend {
dev.event(InputEvent::AxisDiscrete(scroll_discrete as _, sa)); dev.event(InputEvent::AxisDiscrete(scroll_discrete as _, sa));
scroll = PX_PER_SCROLL * scroll_discrete; scroll = PX_PER_SCROLL * scroll_discrete;
} }
dev.event(InputEvent::Axis(scroll.into(), sa)); dev.event(InputEvent::Axis(Fixed::from_f64(scroll), sa));
} }
} }
dev.event(InputEvent::Frame); dev.event(InputEvent::Frame);
@ -174,10 +175,20 @@ impl MetalBackend {
let (event, dev) = unpack!(self, event, pointer_event); let (event, dev) = unpack!(self, event, pointer_event);
let mut dx = event.dx(); let mut dx = event.dx();
let mut dy = event.dy(); let mut dy = event.dy();
let mut dx_unaccelerated = event.dx_unaccelerated();
let mut dy_unaccelerated = event.dy_unaccelerated();
if let Some(matrix) = dev.transform_matrix.get() { if let Some(matrix) = dev.transform_matrix.get() {
dx = matrix[0][0] * dx + matrix[0][1] * dy; dx = matrix[0][0] * dx + matrix[0][1] * dy;
dy = matrix[1][0] * dx + matrix[1][1] * dy; dy = matrix[1][0] * dx + matrix[1][1] * dy;
dx_unaccelerated = matrix[0][0] * dx_unaccelerated + matrix[0][1] * dy_unaccelerated;
dy_unaccelerated = matrix[1][0] * dx_unaccelerated + matrix[1][1] * dy_unaccelerated;
} }
dev.event(InputEvent::Motion(dx.into(), dy.into())); dev.event(InputEvent::Motion {
time_usec: event.time_usec(),
dx: Fixed::from_f64(dx),
dy: Fixed::from_f64(dy),
dx_unaccelerated: Fixed::from_f64(dx_unaccelerated),
dy_unaccelerated: Fixed::from_f64(dy_unaccelerated),
});
} }
} }

View file

@ -761,7 +761,7 @@ impl XBackend {
}; };
seat.mouse_event(InputEvent::AxisSource(AxisSource::Wheel)); seat.mouse_event(InputEvent::AxisSource(AxisSource::Wheel));
seat.mouse_event(InputEvent::AxisDiscrete(val, axis)); seat.mouse_event(InputEvent::AxisDiscrete(val, axis));
seat.mouse_event(InputEvent::Axis((val as f64 * PX_PER_SCROLL).into(), axis)); seat.mouse_event(InputEvent::Axis(Fixed::from_f64(val as f64 * PX_PER_SCROLL), axis));
seat.mouse_event(InputEvent::Frame); seat.mouse_event(InputEvent::Frame);
} }
} else { } else {

View file

@ -366,9 +366,9 @@ impl Client {
self.flush_request.trigger(); self.flush_request.trigger();
} }
pub fn flush(&self) { // pub fn flush(&self) {
self.flush_request.trigger(); // self.flush_request.trigger();
} // }
pub async fn check_queue_size(&self) { pub async fn check_queue_size(&self) {
if self.swapchain.borrow_mut().exceeds_limit() { if self.swapchain.borrow_mut().exceeds_limit() {

View file

@ -33,6 +33,8 @@ use {
}, },
std::{cell::RefCell, mem, ops::DerefMut, rc::Rc}, std::{cell::RefCell, mem, ops::DerefMut, rc::Rc},
}; };
use crate::ifs::wl_seat::wl_pointer::WlPointer;
use crate::wire::WlPointerId;
pub struct Objects { pub struct Objects {
pub display: CloneCell<Option<Rc<WlDisplay>>>, pub display: CloneCell<Option<Rc<WlDisplay>>>,
@ -48,6 +50,7 @@ pub struct Objects {
pub xdg_positioners: CopyHashMap<XdgPositionerId, Rc<XdgPositioner>>, pub xdg_positioners: CopyHashMap<XdgPositionerId, Rc<XdgPositioner>>,
pub regions: CopyHashMap<WlRegionId, Rc<WlRegion>>, pub regions: CopyHashMap<WlRegionId, Rc<WlRegion>>,
pub buffers: CopyHashMap<WlBufferId, Rc<WlBuffer>>, pub buffers: CopyHashMap<WlBufferId, Rc<WlBuffer>>,
pub pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>,
pub xdg_wm_bases: CopyHashMap<XdgWmBaseId, Rc<XdgWmBase>>, pub xdg_wm_bases: CopyHashMap<XdgWmBaseId, Rc<XdgWmBase>>,
pub seats: CopyHashMap<WlSeatId, Rc<WlSeat>>, pub seats: CopyHashMap<WlSeatId, Rc<WlSeat>>,
ids: RefCell<Vec<usize>>, ids: RefCell<Vec<usize>>,
@ -71,6 +74,7 @@ impl Objects {
xdg_positioners: Default::default(), xdg_positioners: Default::default(),
regions: Default::default(), regions: Default::default(),
buffers: Default::default(), buffers: Default::default(),
pointers: Default::default(),
xdg_wm_bases: Default::default(), xdg_wm_bases: Default::default(),
seats: Default::default(), seats: Default::default(),
ids: RefCell::new(vec![]), ids: RefCell::new(vec![]),
@ -104,6 +108,7 @@ impl Objects {
self.buffers.clear(); self.buffers.clear();
self.xdg_wm_bases.clear(); self.xdg_wm_bases.clear();
self.seats.clear(); self.seats.clear();
self.pointers.clear();
} }
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError> pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>

View file

@ -78,7 +78,7 @@ async fn receive(data: Rc<Client>) {
if let Err(e) = obj.handle_request(request, parser) { if let Err(e) = obj.handle_request(request, parser) {
return Err(ClientError::RequestError(Box::new(e))); return Err(ClientError::RequestError(Box::new(e)));
} }
data.flush(); // data.flush();
} }
}; };
let res: Result<(), ClientError> = recv.await; let res: Result<(), ClientError> = recv.await;

View file

@ -8,6 +8,14 @@ use std::{
pub struct Fixed(pub i32); pub struct Fixed(pub i32);
impl Fixed { impl Fixed {
pub fn from_f64(f: f64) -> Self {
Self((f * 256.0) as i32)
}
pub fn to_f64(self) -> f64 {
self.0 as f64 / 256.0
}
pub fn from_1616(i: i32) -> Self { pub fn from_1616(i: i32) -> Self {
Self(i >> 8) Self(i >> 8)
} }
@ -25,27 +33,15 @@ impl Fixed {
} }
} }
impl From<f64> for Fixed {
fn from(v: f64) -> Self {
Self((v * 256.0) as i32)
}
}
impl From<Fixed> for f64 {
fn from(v: Fixed) -> Self {
v.0 as f64 / 256.0
}
}
impl Debug for Fixed { impl Debug for Fixed {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&f64::from(*self), f) Debug::fmt(&self.to_f64(), f)
} }
} }
impl Display for Fixed { impl Display for Fixed {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(&f64::from(*self), f) Display::fmt(&self.to_f64(), f)
} }
} }

View file

@ -39,6 +39,7 @@ use {
}, },
thiserror::Error, thiserror::Error,
}; };
use crate::ifs::wl_seat::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1Global;
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum GlobalsError { pub enum GlobalsError {
@ -134,6 +135,7 @@ impl Globals {
add_singleton!(ZxdgOutputManagerV1Global); add_singleton!(ZxdgOutputManagerV1Global);
add_singleton!(JayCompositorGlobal); add_singleton!(JayCompositorGlobal);
add_singleton!(ZwlrScreencopyManagerV1Global); add_singleton!(ZwlrScreencopyManagerV1Global);
add_singleton!(ZwpRelativePointerManagerV1Global);
if backend.supports_idle() { if backend.supports_idle() {
add_singleton!(ZwpIdleInhibitManagerV1Global); add_singleton!(ZwpIdleInhibitManagerV1Global);
@ -206,7 +208,7 @@ impl Globals {
for registry in registries.values() { for registry in registries.values() {
f(registry); f(registry);
} }
c.flush(); // c.flush();
}); });
} }

View file

@ -79,7 +79,6 @@ impl<T: Vtable> Default for DeviceData<T> {
pub struct OfferData<T: Vtable> { pub struct OfferData<T: Vtable> {
device: CloneCell<Option<Rc<T::Device>>>, device: CloneCell<Option<Rc<T::Device>>>,
source: CloneCell<Option<Rc<T::Source>>>, source: CloneCell<Option<Rc<T::Source>>>,
client: Rc<Client>,
shared: Rc<SharedState>, shared: Rc<SharedState>,
} }
@ -190,7 +189,7 @@ pub fn detach_seat<T: Vtable>(src: &T::Source) {
if !data.state.get().contains(SOURCE_STATE_FINISHED) { if !data.state.get().contains(SOURCE_STATE_FINISHED) {
T::send_cancelled(src); T::send_cancelled(src);
} }
data.client.flush(); // data.client.flush();
} }
pub fn offer_source_to<T: Vtable>(src: &Rc<T::Source>, client: &Rc<Client>) { 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 { let offer_data = OfferData {
device: CloneCell::new(Some(dd.clone())), device: CloneCell::new(Some(dd.clone())),
source: CloneCell::new(Some(src.clone())), source: CloneCell::new(Some(src.clone())),
client: client.clone(),
shared: shared.clone(), shared: shared.clone(),
}; };
let offer = T::create_offer(client, dd, offer_data, id); 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()) { if data.mime_types.borrow_mut().insert(mime_type.to_string()) {
for (_, offer) in &data.offers { for (_, offer) in &data.offers {
T::send_mime_type(&offer, mime_type); T::send_mime_type(&offer, mime_type);
let data = T::get_offer_data(&offer); // let data = T::get_offer_data(&offer);
data.client.flush(); // 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); let data = T::get_offer_data(offer);
if let Some(src) = data.source.get() { if let Some(src) = data.source.get() {
T::send_send(&src, mime_type, fd); T::send_send(&src, mime_type, fd);
let data = T::get_source_data(&src); // let data = T::get_source_data(&src);
data.client.flush(); // data.client.flush();
} }
} }

View file

@ -78,10 +78,10 @@ impl WlDataSource {
if shared.selected_action.replace(action) != action { if shared.selected_action.replace(action) != action {
for (_, offer) in &self.data.offers { for (_, offer) in &self.data.offers {
offer.send_action(action); offer.send_action(action);
offer.client.flush(); // offer.client.flush();
} }
self.send_action(action); self.send_action(action);
self.data.client.flush(); // self.data.client.flush();
} }
} }

View file

@ -126,7 +126,7 @@ impl WlOutputGlobal {
for xdg in xdg.values() { for xdg in xdg.values() {
xdg.send_updates(); xdg.send_updates();
} }
binding.client.flush(); // binding.client.flush();
} }
} }
} }

View file

@ -4,6 +4,8 @@ mod pointer_owner;
pub mod wl_keyboard; pub mod wl_keyboard;
pub mod wl_pointer; pub mod wl_pointer;
pub mod wl_touch; pub mod wl_touch;
pub mod zwp_relative_pointer_manager_v1;
pub mod zwp_relative_pointer_v1;
pub use event_handling::NodeSeatState; pub use event_handling::NodeSeatState;
use { use {
@ -65,6 +67,8 @@ use {
thiserror::Error, thiserror::Error,
uapi::{c, Errno, OwnedFd}, uapi::{c, Errno, OwnedFd},
}; };
use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1;
use crate::wire::ZwpRelativePointerV1Id;
const POINTER: u32 = 1; const POINTER: u32 = 1;
const KEYBOARD: u32 = 2; const KEYBOARD: u32 = 2;
@ -467,7 +471,7 @@ impl WlSeatGlobal {
T::send_selection(device, ObjectId::NONE.into()); T::send_selection(device, ObjectId::NONE.into());
}), }),
} }
client.flush(); // client.flush();
} }
Ok(()) Ok(())
} }
@ -608,6 +612,7 @@ impl WlSeatGlobal {
id, id,
client: client.clone(), client: client.clone(),
pointers: Default::default(), pointers: Default::default(),
relative_pointers: Default::default(),
keyboards: Default::default(), keyboards: Default::default(),
version, version,
tracker: Default::default(), tracker: Default::default(),
@ -652,6 +657,7 @@ pub struct WlSeat {
pub id: WlSeatId, pub id: WlSeatId,
pub client: Rc<Client>, pub client: Rc<Client>,
pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>, pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>,
relative_pointers: CopyHashMap<ZwpRelativePointerV1Id, Rc<ZwpRelativePointerV1>>,
keyboards: CopyHashMap<WlKeyboardId, Rc<WlKeyboard>>, keyboards: CopyHashMap<WlKeyboardId, Rc<WlKeyboard>>,
version: u32, version: u32,
tracker: Tracker<Self>, tracker: Tracker<Self>,
@ -814,6 +820,7 @@ impl Object for WlSeat {
} }
} }
self.pointers.clear(); self.pointers.clear();
self.relative_pointers.clear();
self.keyboards.clear(); self.keyboards.clear();
} }
} }

View file

@ -33,6 +33,7 @@ use {
smallvec::SmallVec, smallvec::SmallVec,
std::rc::Rc, std::rc::Rc,
}; };
use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1;
#[derive(Default)] #[derive(Default)]
pub struct NodeSeatState { pub struct NodeSeatState {
@ -155,7 +156,7 @@ impl WlSeatGlobal {
match event { match event {
InputEvent::Key(k, s) => self.key_event(k, s), InputEvent::Key(k, s) => self.key_event(k, s),
InputEvent::ConnectorPosition(o, x, y) => self.connector_position_event(o, x, y), 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::Button(b, s) => self.pointer_owner.button(self, b, s),
InputEvent::AxisSource(s) => self.pointer_owner.axis_source(s), InputEvent::AxisSource(s) => self.pointer_owner.axis_source(s),
@ -183,7 +184,8 @@ impl WlSeatGlobal {
self.set_new_position(x, y); 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(); let (mut x, mut y) = self.pos.get();
x += dx; x += dx;
y += dy; y += dy;
@ -327,8 +329,8 @@ impl WlSeatGlobal {
} }
fn for_each_pointer<C>(&self, ver: u32, client: ClientId, mut f: C) fn for_each_pointer<C>(&self, ver: u32, client: ClientId, mut f: C)
where where
C: FnMut(&Rc<WlPointer>), C: FnMut(&Rc<WlPointer>),
{ {
self.for_each_seat(ver, client, |seat| { self.for_each_seat(ver, client, |seat| {
let pointers = seat.pointers.lock(); 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) fn for_each_kb<C>(&self, ver: u32, client: ClientId, mut f: C)
where where
C: FnMut(&Rc<WlKeyboard>), C: FnMut(&Rc<WlKeyboard>),
@ -383,14 +397,24 @@ impl WlSeatGlobal {
} }
fn surface_pointer_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F) fn surface_pointer_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
where where
F: FnMut(&Rc<WlPointer>), F: FnMut(&Rc<WlPointer>),
{ {
let client = &surface.client; let client = &surface.client;
self.for_each_pointer(ver, client.id, |p| { self.for_each_pointer(ver, client.id, |p| {
f(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) 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| { self.for_each_kb(ver, client.id, |p| {
f(p); f(p);
}); });
client.flush(); // client.flush();
} }
fn set_new_position(self: &Rc<Self>, x: Fixed, y: Fixed) { 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 // Enter callbacks
impl WlSeatGlobal { impl WlSeatGlobal {
pub fn enter_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) { pub fn enter_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) {
@ -594,7 +627,7 @@ impl WlSeatGlobal {
if let Some(src) = &dnd.src { if let Some(src) = &dnd.src {
src.on_leave(); src.on_leave();
} }
surface.client.flush(); // surface.client.flush();
} }
pub fn dnd_surface_drop(&self, surface: &WlSurface, dnd: &Dnd) { pub fn dnd_surface_drop(&self, surface: &WlSurface, dnd: &Dnd) {
@ -606,7 +639,7 @@ impl WlSeatGlobal {
if let Some(src) = &dnd.src { if let Some(src) = &dnd.src {
src.on_drop(); src.on_drop();
} }
surface.client.flush(); // surface.client.flush();
} }
pub fn dnd_surface_enter( pub fn dnd_surface_enter(
@ -628,7 +661,7 @@ impl WlSeatGlobal {
dd.send_enter(surface.id, x, y, WlDataOfferId::NONE, serial); 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) { 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); dd.send_motion(x, y);
}) })
} }
surface.client.flush(); // surface.client.flush();
} }
} }

View file

@ -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>) { pub fn apply_changes(&self, seat: &Rc<WlSeatGlobal>) {
self.owner.get().apply_changes(seat) self.owner.get().apply_changes(seat)
} }

View file

@ -64,7 +64,7 @@ impl PendingScroll {
pub struct WlPointer { pub struct WlPointer {
id: WlPointerId, id: WlPointerId,
seat: Rc<WlSeat>, pub seat: Rc<WlSeat>,
pub tracker: Tracker<Self>, 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)] #[derive(Debug, Error)]
pub enum WlPointerError { pub enum WlPointerError {

View 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);

View 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);

View file

@ -796,6 +796,10 @@ impl Node for WlSurface {
seat.motion_surface(&*self, x, y) 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) { fn node_on_dnd_drop(&self, dnd: &Dnd) {
dnd.seat.dnd_surface_drop(self, dnd); dnd.seat.dnd_surface_drop(self, dnd);
} }

View file

@ -152,7 +152,7 @@ impl XdgToplevel {
fn send_close(&self) { fn send_close(&self) {
self.xdg.surface.client.event(Close { self_id: self.id }); 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) { fn send_configure(&self, width: i32, height: i32) {
@ -472,7 +472,7 @@ impl ToplevelNode for XdgToplevel {
} }
self.send_configure_checked(nw, nh); self.send_configure_checked(nw, nh);
self.xdg.do_send_configure(); self.xdg.do_send_configure();
self.xdg.surface.client.flush(); // self.xdg.surface.client.flush();
} }
self.xdg.set_absolute_desired_extents(rect); self.xdg.set_absolute_desired_extents(rect);
} }

View file

@ -16,6 +16,7 @@ use {
}, },
std::marker::PhantomData, std::marker::PhantomData,
}; };
use crate::libinput::sys::{libinput_event_pointer_get_dx_unaccelerated, libinput_event_pointer_get_dy_unaccelerated};
pub struct LibInputEvent<'a> { pub struct LibInputEvent<'a> {
pub(super) event: *mut libinput_event, pub(super) event: *mut libinput_event,
@ -101,6 +102,14 @@ impl<'a> LibInputEventPointer<'a> {
unsafe { libinput_event_pointer_get_dy(self.event) } unsafe { libinput_event_pointer_get_dy(self.event) }
} }
pub fn dx_unaccelerated(&self) -> f64 {
unsafe { libinput_event_pointer_get_dx_unaccelerated(self.event) }
}
pub fn dy_unaccelerated(&self) -> f64 {
unsafe { libinput_event_pointer_get_dy_unaccelerated(self.event) }
}
pub fn button(&self) -> u32 { pub fn button(&self) -> u32 {
unsafe { libinput_event_pointer_get_button(self.event) } unsafe { libinput_event_pointer_get_button(self.event) }
} }
@ -121,7 +130,6 @@ impl<'a> LibInputEventPointer<'a> {
unsafe { libinput_event_pointer_has_axis(self.event, axis.raw() as _) != 0 } unsafe { libinput_event_pointer_has_axis(self.event, axis.raw() as _) != 0 }
} }
#[allow(dead_code)]
pub fn time_usec(&self) -> u64 { pub fn time_usec(&self) -> u64 {
unsafe { libinput_event_pointer_get_time_usec(self.event) } unsafe { libinput_event_pointer_get_time_usec(self.event) }
} }

View file

@ -74,6 +74,8 @@ extern "C" {
pub fn libinput_event_pointer_get_time_usec(event: *mut libinput_event_pointer) -> u64; pub fn libinput_event_pointer_get_time_usec(event: *mut libinput_event_pointer) -> u64;
pub fn libinput_event_pointer_get_dx(event: *mut libinput_event_pointer) -> f64; pub fn libinput_event_pointer_get_dx(event: *mut libinput_event_pointer) -> f64;
pub fn libinput_event_pointer_get_dy(event: *mut libinput_event_pointer) -> f64; pub fn libinput_event_pointer_get_dy(event: *mut libinput_event_pointer) -> f64;
pub fn libinput_event_pointer_get_dx_unaccelerated(event: *mut libinput_event_pointer) -> f64;
pub fn libinput_event_pointer_get_dy_unaccelerated(event: *mut libinput_event_pointer) -> f64;
pub fn libinput_event_pointer_get_button(event: *mut libinput_event_pointer) -> u32; pub fn libinput_event_pointer_get_button(event: *mut libinput_event_pointer) -> u32;
pub fn libinput_event_pointer_get_button_state( pub fn libinput_event_pointer_get_button_state(
event: *mut libinput_event_pointer, event: *mut libinput_event_pointer,

View file

@ -198,6 +198,15 @@ pub trait Node: 'static {
let _ = y; let _ = y;
} }
fn node_on_pointer_relative_motion(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) {
let _ = seat;
let _ = time_usec;
let _ = dx;
let _ = dy;
let _ = dx_unaccelerated;
let _ = dy_unaccelerated;
}
fn node_on_dnd_drop(&self, dnd: &Dnd) { fn node_on_dnd_drop(&self, dnd: &Dnd) {
let _ = dnd; let _ = dnd;
} }

View file

@ -1158,7 +1158,7 @@ impl Node for ContainerNode {
Some(s) => s, Some(s) => s,
_ => return, _ => return,
}; };
let mut scroll = self.scroll.get() + f64::from(scroll); let mut scroll = self.scroll.get() + scroll.to_f64();
let discrete = (scroll / PX_PER_SCROLL).round(); let discrete = (scroll / PX_PER_SCROLL).round();
scroll -= discrete * PX_PER_SCROLL; scroll -= discrete * PX_PER_SCROLL;
self.scroll.set(scroll); self.scroll.set(scroll);

View file

@ -262,13 +262,15 @@ impl ToplevelData {
let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone())); let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone()));
parent.cnode_replace_child(node.tl_as_node(), placeholder.clone()); parent.cnode_replace_child(node.tl_as_node(), placeholder.clone());
let mut kb_foci = Default::default(); let mut kb_foci = Default::default();
if let Some(container) = ws.container.get() { if ws.visible.get() {
kb_foci = collect_kb_foci(container.clone()); if let Some(container) = ws.container.get() {
container.tl_set_visible(false); kb_foci = collect_kb_foci(container.clone());
} container.tl_set_visible(false);
for stacked in ws.stacked.iter() { }
collect_kb_foci2(stacked.deref().clone().stacked_into_node(), &mut kb_foci); for stacked in ws.stacked.iter() {
stacked.stacked_set_visible(false); collect_kb_foci2(stacked.deref().clone().stacked_into_node(), &mut kb_foci);
stacked.stacked_set_visible(false);
}
} }
*data = Some(FullscreenedData { *data = Some(FullscreenedData {
placeholder, placeholder,

View file

@ -0,0 +1,10 @@
# requests
msg destroy = 0 {
}
msg get_relative_pointer = 1 {
id: id(zwp_relative_pointer_v1),
pointer: id(wl_pointer),
}

View file

@ -0,0 +1,16 @@
# requests
msg destroy = 0 {
}
# events
msg relative_motion = 0 {
utime_hi: u32,
utime_lo: u32,
dx: fixed,
dy: fixed,
dx_unaccelerated: fixed,
dy_unaccelerated: fixed,
}