1
0
Fork 0
forked from wry/wry

autocommit 2022-04-30 13:53:02 CEST

This commit is contained in:
Julian Orth 2022-04-30 13:53:02 +02:00
parent 3d4a6b21f3
commit ac56970f14
14 changed files with 132 additions and 53 deletions

View file

@ -3,6 +3,7 @@ use {
async_engine::FdStatus,
backend::{AxisSource, InputEvent, KeyState, ScrollAxis},
backends::metal::MetalBackend,
fixed::Fixed,
ifs::wl_seat::PX_PER_SCROLL,
libinput::{
consts::{
@ -15,7 +16,6 @@ use {
},
std::rc::Rc,
};
use crate::fixed::Fixed;
macro_rules! unpack {
($slf:expr, $ev:expr) => {{

View file

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

View file

@ -11,7 +11,7 @@ use {
wl_output::WlOutput,
wl_region::WlRegion,
wl_registry::WlRegistry,
wl_seat::WlSeat,
wl_seat::{wl_pointer::WlPointer, WlSeat},
wl_surface::{
xdg_surface::{xdg_toplevel::XdgToplevel, XdgSurface},
WlSurface,
@ -26,15 +26,13 @@ use {
copyhashmap::{CopyHashMap, Locked},
},
wire::{
WlBufferId, WlDataSourceId, WlOutputId, WlRegionId, WlRegistryId, WlSeatId,
WlSurfaceId, XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId,
WlBufferId, WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId,
WlSeatId, WlSurfaceId, XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId,
ZwpPrimarySelectionSourceV1Id,
},
},
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>>>,

View file

@ -13,7 +13,9 @@ use {
wl_drm::WlDrmGlobal,
wl_output::WlOutputGlobal,
wl_registry::WlRegistry,
wl_seat::WlSeatGlobal,
wl_seat::{
zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1Global, WlSeatGlobal,
},
wl_shm::WlShmGlobal,
wl_subcompositor::WlSubcompositorGlobal,
wp_presentation::WpPresentationGlobal,
@ -39,7 +41,6 @@ use {
},
thiserror::Error,
};
use crate::ifs::wl_seat::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1Global;
#[derive(Debug, Error)]
pub enum GlobalsError {

View file

@ -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;

View file

@ -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);
});

View file

@ -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,
);
}
}

View file

@ -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 {

View file

@ -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,

View file

@ -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);
}

View file

@ -9,14 +9,14 @@ use {
libinput_event_keyboard_get_key_state, libinput_event_keyboard_get_time_usec,
libinput_event_pointer, libinput_event_pointer_get_button,
libinput_event_pointer_get_button_state, libinput_event_pointer_get_dx,
libinput_event_pointer_get_dy, libinput_event_pointer_get_scroll_value,
libinput_event_pointer_get_dx_unaccelerated, libinput_event_pointer_get_dy,
libinput_event_pointer_get_dy_unaccelerated, libinput_event_pointer_get_scroll_value,
libinput_event_pointer_get_scroll_value_v120, libinput_event_pointer_get_time_usec,
libinput_event_pointer_has_axis,
},
},
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,

View file

@ -198,7 +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) {
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;

View file

@ -1,7 +1,7 @@
use {
crate::{
client::Client,
ifs::wl_seat::{collect_kb_foci, NodeSeatState, SeatId},
ifs::wl_seat::{collect_kb_foci, collect_kb_foci2, NodeSeatState, SeatId},
rect::Rect,
state::State,
tree::{ContainingNode, Node, OutputNode, PlaceholderNode, WorkspaceNode},
@ -14,7 +14,6 @@ use {
rc::Rc,
},
};
use crate::ifs::wl_seat::collect_kb_foci2;
tree_id!(ToplevelNodeId);