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
|
|
@ -144,8 +144,13 @@ pub enum AxisSource {
|
|||
pub enum InputEvent {
|
||||
Key(u32, KeyState),
|
||||
ConnectorPosition(ConnectorId, Fixed, Fixed),
|
||||
#[allow(dead_code)]
|
||||
Motion(Fixed, Fixed),
|
||||
Motion {
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
},
|
||||
Button(u32, KeyState),
|
||||
|
||||
Axis(Fixed, ScrollAxis),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use {
|
|||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
use crate::fixed::Fixed;
|
||||
|
||||
macro_rules! unpack {
|
||||
($slf:expr, $ev:expr) => {{
|
||||
|
|
@ -148,7 +149,7 @@ impl MetalBackend {
|
|||
dev.event(InputEvent::AxisDiscrete(scroll_discrete as _, sa));
|
||||
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);
|
||||
|
|
@ -174,10 +175,20 @@ impl MetalBackend {
|
|||
let (event, dev) = unpack!(self, event, pointer_event);
|
||||
let mut dx = event.dx();
|
||||
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() {
|
||||
dx = matrix[0][0] * dx + matrix[0][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),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -761,7 +761,7 @@ impl XBackend {
|
|||
};
|
||||
seat.mouse_event(InputEvent::AxisSource(AxisSource::Wheel));
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -366,9 +366,9 @@ impl Client {
|
|||
self.flush_request.trigger();
|
||||
}
|
||||
|
||||
pub fn flush(&self) {
|
||||
self.flush_request.trigger();
|
||||
}
|
||||
// pub fn flush(&self) {
|
||||
// self.flush_request.trigger();
|
||||
// }
|
||||
|
||||
pub async fn check_queue_size(&self) {
|
||||
if self.swapchain.borrow_mut().exceeds_limit() {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ use {
|
|||
},
|
||||
std::{cell::RefCell, mem, ops::DerefMut, rc::Rc},
|
||||
};
|
||||
use crate::ifs::wl_seat::wl_pointer::WlPointer;
|
||||
use crate::wire::WlPointerId;
|
||||
|
||||
pub struct Objects {
|
||||
pub display: CloneCell<Option<Rc<WlDisplay>>>,
|
||||
|
|
@ -48,6 +50,7 @@ pub struct Objects {
|
|||
pub xdg_positioners: CopyHashMap<XdgPositionerId, Rc<XdgPositioner>>,
|
||||
pub regions: CopyHashMap<WlRegionId, Rc<WlRegion>>,
|
||||
pub buffers: CopyHashMap<WlBufferId, Rc<WlBuffer>>,
|
||||
pub pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>,
|
||||
pub xdg_wm_bases: CopyHashMap<XdgWmBaseId, Rc<XdgWmBase>>,
|
||||
pub seats: CopyHashMap<WlSeatId, Rc<WlSeat>>,
|
||||
ids: RefCell<Vec<usize>>,
|
||||
|
|
@ -71,6 +74,7 @@ impl Objects {
|
|||
xdg_positioners: Default::default(),
|
||||
regions: Default::default(),
|
||||
buffers: Default::default(),
|
||||
pointers: Default::default(),
|
||||
xdg_wm_bases: Default::default(),
|
||||
seats: Default::default(),
|
||||
ids: RefCell::new(vec![]),
|
||||
|
|
@ -104,6 +108,7 @@ impl Objects {
|
|||
self.buffers.clear();
|
||||
self.xdg_wm_bases.clear();
|
||||
self.seats.clear();
|
||||
self.pointers.clear();
|
||||
}
|
||||
|
||||
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ async fn receive(data: Rc<Client>) {
|
|||
if let Err(e) = obj.handle_request(request, parser) {
|
||||
return Err(ClientError::RequestError(Box::new(e)));
|
||||
}
|
||||
data.flush();
|
||||
// data.flush();
|
||||
}
|
||||
};
|
||||
let res: Result<(), ClientError> = recv.await;
|
||||
|
|
|
|||
24
src/fixed.rs
24
src/fixed.rs
|
|
@ -8,6 +8,14 @@ use std::{
|
|||
pub struct Fixed(pub i32);
|
||||
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
Display::fmt(&f64::from(*self), f)
|
||||
Display::fmt(&self.to_f64(), f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ use {
|
|||
},
|
||||
thiserror::Error,
|
||||
};
|
||||
use crate::ifs::wl_seat::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1Global;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GlobalsError {
|
||||
|
|
@ -134,6 +135,7 @@ impl Globals {
|
|||
add_singleton!(ZxdgOutputManagerV1Global);
|
||||
add_singleton!(JayCompositorGlobal);
|
||||
add_singleton!(ZwlrScreencopyManagerV1Global);
|
||||
add_singleton!(ZwpRelativePointerManagerV1Global);
|
||||
|
||||
if backend.supports_idle() {
|
||||
add_singleton!(ZwpIdleInhibitManagerV1Global);
|
||||
|
|
@ -206,7 +208,7 @@ impl Globals {
|
|||
for registry in registries.values() {
|
||||
f(registry);
|
||||
}
|
||||
c.flush();
|
||||
// c.flush();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use {
|
|||
},
|
||||
std::marker::PhantomData,
|
||||
};
|
||||
use crate::libinput::sys::{libinput_event_pointer_get_dx_unaccelerated, libinput_event_pointer_get_dy_unaccelerated};
|
||||
|
||||
pub struct LibInputEvent<'a> {
|
||||
pub(super) event: *mut libinput_event,
|
||||
|
|
@ -101,6 +102,14 @@ impl<'a> LibInputEventPointer<'a> {
|
|||
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 {
|
||||
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 }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_pointer_get_time_usec(self.event) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_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_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_state(
|
||||
event: *mut libinput_event_pointer,
|
||||
|
|
|
|||
|
|
@ -198,6 +198,15 @@ pub trait Node: 'static {
|
|||
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) {
|
||||
let _ = dnd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,7 @@ impl Node for ContainerNode {
|
|||
Some(s) => s,
|
||||
_ => 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();
|
||||
scroll -= discrete * PX_PER_SCROLL;
|
||||
self.scroll.set(scroll);
|
||||
|
|
|
|||
|
|
@ -262,13 +262,15 @@ impl ToplevelData {
|
|||
let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone()));
|
||||
parent.cnode_replace_child(node.tl_as_node(), placeholder.clone());
|
||||
let mut kb_foci = Default::default();
|
||||
if let Some(container) = ws.container.get() {
|
||||
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);
|
||||
stacked.stacked_set_visible(false);
|
||||
if ws.visible.get() {
|
||||
if let Some(container) = ws.container.get() {
|
||||
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);
|
||||
stacked.stacked_set_visible(false);
|
||||
}
|
||||
}
|
||||
*data = Some(FullscreenedData {
|
||||
placeholder,
|
||||
|
|
|
|||
10
wire/zwp_relative_pointer_manager_v1.txt
Normal file
10
wire/zwp_relative_pointer_manager_v1.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# requests
|
||||
|
||||
msg destroy = 0 {
|
||||
|
||||
}
|
||||
|
||||
msg get_relative_pointer = 1 {
|
||||
id: id(zwp_relative_pointer_v1),
|
||||
pointer: id(wl_pointer),
|
||||
}
|
||||
16
wire/zwp_relative_pointer_v1.txt
Normal file
16
wire/zwp_relative_pointer_v1.txt
Normal 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,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue