1
0
Fork 0
forked from wry/wry

autocommit 2022-02-06 19:56:51 CET

This commit is contained in:
Julian Orth 2022-02-06 19:56:51 +01:00
parent 1fdff156ec
commit 3f50b0c75e
37 changed files with 452 additions and 439 deletions

View file

@ -1,5 +1,5 @@
use crate::backend::{KeyState, OutputId, ScrollAxis, SeatEvent, SeatId};
use crate::client::{ClientId, DynEventFormatter};
use crate::client::{ClientId};
use crate::fixed::Fixed;
use crate::ifs::wl_data_device::WlDataDevice;
use crate::ifs::wl_seat::wl_keyboard::WlKeyboard;
@ -229,7 +229,7 @@ impl WlSeatGlobal {
let pressed_keys: Vec<_> = self.pressed_keys.borrow().iter().copied().collect();
let serial = self.serial.fetch_add(1);
self.surface_kb_event(0, &surface, |k| {
k.enter(serial, surface.id, pressed_keys.clone())
k.send_enter(serial, surface.id, pressed_keys.clone())
});
let ModifierState {
mods_depressed,
@ -239,14 +239,14 @@ impl WlSeatGlobal {
} = self.kb_state.borrow().mods();
let serial = self.serial.fetch_add(1);
self.surface_kb_event(0, &surface, |k| {
k.modifiers(serial, mods_depressed, mods_latched, mods_locked, group)
k.send_modifiers(serial, mods_depressed, mods_latched, mods_locked, group)
});
if old.client_id() != Some(surface.client.id) {
match self.selection.get() {
None => {
self.surface_data_device_event(0, &surface, |dd| {
dd.selection(WlDataOfferId::NONE)
dd.send_selection(WlDataOfferId::NONE)
});
}
Some(sel) => {
@ -256,7 +256,7 @@ impl WlSeatGlobal {
match self.primary_selection.get() {
None => {
self.surface_primary_selection_device_event(0, &surface, |dd| {
dd.selection(ZwpPrimarySelectionOfferV1Id::NONE)
dd.send_selection(ZwpPrimarySelectionOfferV1Id::NONE)
});
}
Some(sel) => {
@ -333,49 +333,49 @@ impl WlSeatGlobal {
}
fn surface_pointer_frame(&self, surface: &WlSurface) {
self.surface_pointer_event(POINTER_FRAME_SINCE_VERSION, surface, |p| p.frame());
self.surface_pointer_event(POINTER_FRAME_SINCE_VERSION, surface, |p| p.send_frame());
}
fn surface_pointer_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
where
F: FnMut(&Rc<WlPointer>) -> DynEventFormatter,
F: FnMut(&Rc<WlPointer>),
{
let client = &surface.client;
self.for_each_pointer(ver, client.id, |p| {
client.event(f(p));
f(p);
});
client.flush();
}
fn surface_kb_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
where
F: FnMut(&Rc<WlKeyboard>) -> DynEventFormatter,
F: FnMut(&Rc<WlKeyboard>),
{
let client = &surface.client;
self.for_each_kb(ver, client.id, |p| {
client.event(f(p));
f(p);
});
client.flush();
}
fn surface_data_device_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
where
F: FnMut(&Rc<WlDataDevice>) -> DynEventFormatter,
F: FnMut(&Rc<WlDataDevice>),
{
let client = &surface.client;
self.for_each_data_device(ver, client.id, |p| {
client.event(f(p));
f(p);
});
client.flush();
}
fn surface_primary_selection_device_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
where
F: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>) -> DynEventFormatter,
F: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>),
{
let client = &surface.client;
self.for_each_primary_selection_device(ver, client.id, |p| {
client.event(f(p));
f(p);
});
client.flush();
}
@ -487,7 +487,7 @@ impl WlSeatGlobal {
KeyState::Pressed => (wl_pointer::PRESSED, true),
};
let serial = self.serial.fetch_add(1);
self.surface_pointer_event(0, surface, |p| p.button(serial, 0, button, state));
self.surface_pointer_event(0, surface, |p| p.send_button(serial, 0, button, state));
self.surface_pointer_frame(surface);
if pressed && surface.belongs_to_toplevel() {
self.focus_surface(surface);
@ -502,7 +502,7 @@ impl WlSeatGlobal {
ScrollAxis::Horizontal => wl_pointer::HORIZONTAL_SCROLL,
ScrollAxis::Vertical => wl_pointer::VERTICAL_SCROLL,
};
self.surface_pointer_event(0, surface, |p| p.axis(0, axis, Fixed::from_int(delta)));
self.surface_pointer_event(0, surface, |p| p.send_axis(0, axis, Fixed::from_int(delta)));
self.surface_pointer_frame(surface);
}
}
@ -510,7 +510,7 @@ impl WlSeatGlobal {
// Motion callbacks
impl WlSeatGlobal {
pub fn motion_surface(&self, n: &WlSurface, x: Fixed, y: Fixed) {
self.surface_pointer_event(0, n, |p| p.motion(0, x, y));
self.surface_pointer_event(0, n, |p| p.send_motion(0, x, y));
self.surface_pointer_frame(n);
}
}
@ -527,7 +527,7 @@ impl WlSeatGlobal {
pub fn enter_surface(&self, n: &WlSurface, x: Fixed, y: Fixed) {
let serial = self.serial.fetch_add(1);
self.surface_pointer_event(0, n, |p| p.enter(serial, n.id, x, y));
self.surface_pointer_event(0, n, |p| p.send_enter(serial, n.id, x, y));
self.surface_pointer_frame(n);
}
}
@ -536,7 +536,7 @@ impl WlSeatGlobal {
impl WlSeatGlobal {
pub fn leave_surface(&self, n: &WlSurface) {
let serial = self.serial.fetch_add(1);
self.surface_pointer_event(0, n, |p| p.leave(serial, n.id));
self.surface_pointer_event(0, n, |p| p.send_leave(serial, n.id));
self.surface_pointer_frame(n);
}
}
@ -544,7 +544,7 @@ impl WlSeatGlobal {
// Unfocus callbacks
impl WlSeatGlobal {
pub fn unfocus_surface(&self, surface: &WlSurface) {
self.surface_kb_event(0, surface, |k| k.leave(0, surface.id))
self.surface_kb_event(0, surface, |k| k.send_leave(0, surface.id))
}
}
@ -558,11 +558,11 @@ impl WlSeatGlobal {
mods: Option<ModifierState>,
) {
let serial = self.serial.fetch_add(1);
self.surface_kb_event(0, surface, |k| k.key(serial, 0, key, state));
self.surface_kb_event(0, surface, |k| k.send_key(serial, 0, key, state));
let serial = self.serial.fetch_add(1);
if let Some(mods) = mods {
self.surface_kb_event(0, surface, |k| {
k.modifiers(
k.send_modifiers(
serial,
mods.mods_depressed,
mods.mods_latched,

View file

@ -1,5 +1,5 @@
use crate::client::{ClientError, DynEventFormatter};
use crate::client::{ClientError};
use crate::ifs::wl_seat::WlSeat;
use crate::object::Object;
use crate::utils::buffd::MsgParser;
@ -62,8 +62,8 @@ impl WlKeyboard {
Ok(Rc::new(fd))
}
pub fn keymap(self: &Rc<Self>, format: u32, fd: Rc<OwnedFd>, size: u32) -> DynEventFormatter {
Box::new(Keymap {
pub fn send_keymap(self: &Rc<Self>, format: u32, fd: Rc<OwnedFd>, size: u32) {
self.seat.client.event(Keymap {
self_id: self.id,
format,
fd,
@ -71,13 +71,13 @@ impl WlKeyboard {
})
}
pub fn enter(
pub fn send_enter(
self: &Rc<Self>,
serial: u32,
surface: WlSurfaceId,
keys: Vec<u32>,
) -> DynEventFormatter {
Box::new(EnterOut {
) {
self.seat.client.event(EnterOut {
self_id: self.id,
serial,
surface,
@ -85,16 +85,16 @@ impl WlKeyboard {
})
}
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
Box::new(Leave {
pub fn send_leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) {
self.seat.client.event(Leave {
self_id: self.id,
serial,
surface,
})
}
pub fn key(self: &Rc<Self>, serial: u32, time: u32, key: u32, state: u32) -> DynEventFormatter {
Box::new(Key {
pub fn send_key(self: &Rc<Self>, serial: u32, time: u32, key: u32, state: u32) {
self.seat.client.event(Key {
self_id: self.id,
serial,
time,
@ -103,15 +103,15 @@ impl WlKeyboard {
})
}
pub fn modifiers(
pub fn send_modifiers(
self: &Rc<Self>,
serial: u32,
mods_depressed: u32,
mods_latched: u32,
mods_locked: u32,
group: u32,
) -> DynEventFormatter {
Box::new(Modifiers {
) {
self.seat.client.event(Modifiers {
self_id: self.id,
serial,
mods_depressed,
@ -121,8 +121,8 @@ impl WlKeyboard {
})
}
pub fn repeat_info(self: &Rc<Self>, rate: i32, delay: i32) -> DynEventFormatter {
Box::new(RepeatInfo {
pub fn send_repeat_info(self: &Rc<Self>, rate: i32, delay: i32) {
self.seat.client.event(RepeatInfo {
self_id: self.id,
rate,
delay,

View file

@ -1,5 +1,5 @@
use crate::client::{ClientError, DynEventFormatter};
use crate::client::{ClientError};
use crate::cursor::Cursor;
use crate::fixed::Fixed;
use crate::ifs::wl_seat::WlSeat;
@ -45,14 +45,14 @@ impl WlPointer {
}
}
pub fn enter(
self: &Rc<Self>,
pub fn send_enter(
&self,
serial: u32,
surface: WlSurfaceId,
x: Fixed,
y: Fixed,
) -> DynEventFormatter {
Box::new(Enter {
) {
self.seat.client.event(Enter {
self_id: self.id,
serial,
surface,
@ -61,16 +61,16 @@ impl WlPointer {
})
}
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
Box::new(Leave {
pub fn send_leave(&self, serial: u32, surface: WlSurfaceId) {
self.seat.client.event(Leave {
self_id: self.id,
serial,
surface,
})
}
pub fn motion(self: &Rc<Self>, time: u32, x: Fixed, y: Fixed) -> DynEventFormatter {
Box::new(Motion {
pub fn send_motion(&self, time: u32, x: Fixed, y: Fixed) {
self.seat.client.event(Motion {
self_id: self.id,
time,
surface_x: x,
@ -78,14 +78,14 @@ impl WlPointer {
})
}
pub fn button(
self: &Rc<Self>,
pub fn send_button(
&self,
serial: u32,
time: u32,
button: u32,
state: u32,
) -> DynEventFormatter {
Box::new(Button {
) {
self.seat.client.event(Button {
self_id: self.id,
serial,
time,
@ -94,8 +94,8 @@ impl WlPointer {
})
}
pub fn axis(self: &Rc<Self>, time: u32, axis: u32, value: Fixed) -> DynEventFormatter {
Box::new(Axis {
pub fn send_axis(&self, time: u32, axis: u32, value: Fixed) {
self.seat.client.event(Axis {
self_id: self.id,
time,
axis,
@ -104,21 +104,21 @@ impl WlPointer {
}
#[allow(dead_code)]
pub fn frame(self: &Rc<Self>) -> DynEventFormatter {
Box::new(Frame { self_id: self.id })
pub fn send_frame(&self) {
self.seat.client.event(Frame { self_id: self.id })
}
#[allow(dead_code)]
pub fn axis_source(self: &Rc<Self>, axis_source: u32) -> DynEventFormatter {
Box::new(AxisSource {
pub fn send_axis_source(&self, axis_source: u32) {
self.seat.client.event(AxisSource {
self_id: self.id,
axis_source,
})
}
#[allow(dead_code)]
pub fn axis_stop(self: &Rc<Self>, time: u32, axis: u32) -> DynEventFormatter {
Box::new(AxisStop {
pub fn send_axis_stop(&self, time: u32, axis: u32) {
self.seat.client.event(AxisStop {
self_id: self.id,
time,
axis,
@ -126,8 +126,8 @@ impl WlPointer {
}
#[allow(dead_code)]
pub fn axis_discrete(self: &Rc<Self>, axis: u32, discrete: i32) -> DynEventFormatter {
Box::new(AxisDiscrete {
pub fn send_axis_discrete(&self, axis: u32, discrete: i32) {
self.seat.client.event(AxisDiscrete {
self_id: self.id,
axis,
discrete,