autocommit 2022-02-01 01:20:49 CET
This commit is contained in:
parent
f2117256b9
commit
7654e70f64
39 changed files with 830 additions and 761 deletions
|
|
@ -1,20 +1,20 @@
|
|||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use crate::backend::{KeyState, OutputId, ScrollAxis, SeatEvent, SeatId};
|
||||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
use crate::ifs::wl_seat::{wl_keyboard, wl_pointer, WlSeatGlobal, WlSeatObj};
|
||||
use crate::ifs::wl_seat::wl_keyboard::WlKeyboard;
|
||||
use crate::ifs::wl_seat::wl_pointer::{POINTER_FRAME_SINCE_VERSION, WlPointer};
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, POINTER_FRAME_SINCE_VERSION};
|
||||
use crate::ifs::wl_seat::{wl_keyboard, wl_pointer, WlSeatGlobal, WlSeatObj};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::ifs::wl_surface::xdg_surface::XdgSurface;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::tree::{FloatNode, FoundNode, Node};
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeSeatState {
|
||||
|
|
@ -197,8 +197,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn for_each_seat<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<WlSeatObj>),
|
||||
where
|
||||
C: FnMut(&Rc<WlSeatObj>),
|
||||
{
|
||||
let bindings = self.bindings.borrow();
|
||||
if let Some(hm) = bindings.get(&client) {
|
||||
|
|
@ -211,8 +211,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();
|
||||
|
|
@ -223,8 +223,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn for_each_kb<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<WlKeyboard>),
|
||||
where
|
||||
C: FnMut(&Rc<WlKeyboard>),
|
||||
{
|
||||
self.for_each_seat(ver, client, |seat| {
|
||||
let keyboards = seat.keyboards.lock();
|
||||
|
|
@ -235,8 +235,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn for_each_data_device<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<WlDataDevice>),
|
||||
where
|
||||
C: FnMut(&Rc<WlDataDevice>),
|
||||
{
|
||||
let dd = self.data_devices.borrow_mut();
|
||||
if let Some(dd) = dd.get(&client) {
|
||||
|
|
@ -253,8 +253,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn surface_pointer_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
||||
where
|
||||
F: FnMut(&Rc<WlPointer>) -> DynEventFormatter,
|
||||
where
|
||||
F: FnMut(&Rc<WlPointer>) -> DynEventFormatter,
|
||||
{
|
||||
let client = &surface.client;
|
||||
self.for_each_pointer(ver, client.id, |p| {
|
||||
|
|
@ -264,8 +264,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn surface_kb_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
||||
where
|
||||
F: FnMut(&Rc<WlKeyboard>) -> DynEventFormatter,
|
||||
where
|
||||
F: FnMut(&Rc<WlKeyboard>) -> DynEventFormatter,
|
||||
{
|
||||
let client = &surface.client;
|
||||
self.for_each_kb(ver, client.id, |p| {
|
||||
|
|
@ -275,8 +275,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn surface_data_device_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
||||
where
|
||||
F: FnMut(&Rc<WlDataDevice>) -> DynEventFormatter,
|
||||
where
|
||||
F: FnMut(&Rc<WlDataDevice>) -> DynEventFormatter,
|
||||
{
|
||||
let client = &surface.client;
|
||||
self.for_each_data_device(ver, client.id, |p| {
|
||||
|
|
@ -334,7 +334,8 @@ impl WlSeatGlobal {
|
|||
if (stack.len(), found_tree.len()) == (divergence, divergence) {
|
||||
if changed {
|
||||
if let Some(node) = found_tree.last() {
|
||||
node.node.motion(self, x.apply_fract(node.x), y.apply_fract(node.y));
|
||||
node.node
|
||||
.motion(self, x.apply_fract(node.x), y.apply_fract(node.y));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -344,7 +345,9 @@ impl WlSeatGlobal {
|
|||
}
|
||||
for new in found_tree.drain(divergence..) {
|
||||
new.node.seat_state().enter(self);
|
||||
new.node.clone().enter(self, x.apply_fract(new.x), y.apply_fract(new.y));
|
||||
new.node
|
||||
.clone()
|
||||
.enter(self, x.apply_fract(new.x), y.apply_fract(new.y));
|
||||
stack.push(new.node);
|
||||
}
|
||||
}
|
||||
|
|
@ -423,7 +426,13 @@ impl WlSeatGlobal {
|
|||
|
||||
// Key callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn key_surface(&self, surface: &WlSurface, key: u32, state: u32, mods: Option<ModifierState>) {
|
||||
pub fn key_surface(
|
||||
&self,
|
||||
surface: &WlSurface,
|
||||
key: u32,
|
||||
state: u32,
|
||||
mods: Option<ModifierState>,
|
||||
) {
|
||||
let serial = self.serial.fetch_add(1);
|
||||
self.surface_kb_event(0, surface, |k| k.key(serial, 0, key, state));
|
||||
let serial = self.serial.fetch_add(1);
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
mod handling;
|
||||
mod types;
|
||||
pub mod wl_keyboard;
|
||||
pub mod wl_pointer;
|
||||
pub mod wl_touch;
|
||||
mod handling;
|
||||
|
||||
use crate::backend::{Seat, SeatId};
|
||||
use crate::client::{Client, ClientId, DynEventFormatter};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceId};
|
||||
use crate::ifs::wl_seat::wl_keyboard::{WlKeyboard, WlKeyboardId, REPEAT_INFO_SINCE};
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, WlPointerId};
|
||||
use crate::ifs::wl_seat::wl_touch::WlTouch;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::{XdgToplevel};
|
||||
use crate::ifs::wl_surface::cursor::CursorSurface;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::tree::{FloatNode, FoundNode, Node};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::copyhashmap::CopyHashMap;
|
||||
use crate::utils::linkedlist::{LinkedList};
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
use crate::xkbcommon::{XkbContext, XkbState};
|
||||
use crate::{NumCell, State};
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
use bstr::ByteSlice;
|
||||
pub use handling::NodeSeatState;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::io::Write;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use uapi::{c, OwnedFd};
|
||||
pub use handling::NodeSeatState;
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceId};
|
||||
use crate::ifs::wl_surface::cursor::CursorSurface;
|
||||
|
||||
id!(WlSeatId);
|
||||
|
||||
|
|
@ -53,6 +53,8 @@ const MISSING_CAPABILITY: u32 = 0;
|
|||
#[allow(dead_code)]
|
||||
const BTN_LEFT: u32 = 0x110;
|
||||
|
||||
pub const SEAT_NAME_SINCE: u32 = 2;
|
||||
|
||||
pub struct WlSeatGlobal {
|
||||
name: GlobalName,
|
||||
state: Rc<State>,
|
||||
|
|
@ -92,7 +94,7 @@ impl WlSeatGlobal {
|
|||
memfd.raw(),
|
||||
c::F_SEAL_SEAL | c::F_SEAL_GROW | c::F_SEAL_SHRINK | c::F_SEAL_WRITE,
|
||||
)
|
||||
.unwrap();
|
||||
.unwrap();
|
||||
(state, Rc::new(memfd), (string.len() + 1) as _)
|
||||
};
|
||||
Self {
|
||||
|
|
@ -155,7 +157,9 @@ impl WlSeatGlobal {
|
|||
});
|
||||
client.add_client_obj(&obj)?;
|
||||
client.event(obj.capabilities());
|
||||
client.event(obj.name(&self.seat_name));
|
||||
if version >= SEAT_NAME_SINCE {
|
||||
client.event(obj.name(&self.seat_name));
|
||||
}
|
||||
{
|
||||
let mut bindings = self.bindings.borrow_mut();
|
||||
let bindings = bindings.entry(client.id).or_insert_with(Default::default);
|
||||
|
|
@ -215,7 +219,9 @@ impl WlSeatObj {
|
|||
|
||||
pub fn add_data_device(&self, device: &Rc<WlDataDevice>) {
|
||||
let mut dd = self.global.data_devices.borrow_mut();
|
||||
dd.entry(self.client.id).or_default().insert(device.id, device.clone());
|
||||
dd.entry(self.client.id)
|
||||
.or_default()
|
||||
.insert(device.id, device.clone());
|
||||
}
|
||||
|
||||
pub fn remove_data_device(&self, device: &WlDataDevice) {
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ impl WlPointer {
|
|||
_ => {
|
||||
// cannot happen
|
||||
return Ok(());
|
||||
},
|
||||
}
|
||||
};
|
||||
if pointer_node.client_id() != Some(self.seat.client.id) {
|
||||
return Ok(());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue