autocommit 2022-01-08 18:38:24 CET
This commit is contained in:
parent
33549184d4
commit
d061a5c313
38 changed files with 179 additions and 371 deletions
5
build.rs
5
build.rs
|
|
@ -63,11 +63,6 @@ fn main() -> anyhow::Result<()> {
|
||||||
write_ty(&mut f, pixman::OPS, "PixmanOp")?;
|
write_ty(&mut f, pixman::OPS, "PixmanOp")?;
|
||||||
|
|
||||||
let mut f = open("xkbcommon_tys.rs")?;
|
let mut f = open("xkbcommon_tys.rs")?;
|
||||||
write_ty(
|
|
||||||
&mut f,
|
|
||||||
xkbcommon::XKB_X11_SETUP_XKB_EXTENSION_FLAGS,
|
|
||||||
"xkb_x11_setup_xkb_extension_flags",
|
|
||||||
)?;
|
|
||||||
write_ty(&mut f, xkbcommon::XKB_LOG_LEVEL, "xkb_log_level")?;
|
write_ty(&mut f, xkbcommon::XKB_LOG_LEVEL, "xkb_log_level")?;
|
||||||
write_ty(&mut f, xkbcommon::XKB_CONTEXT_FLAGS, "xkb_context_flags")?;
|
write_ty(&mut f, xkbcommon::XKB_CONTEXT_FLAGS, "xkb_context_flags")?;
|
||||||
write_ty(
|
write_ty(
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@ impl XorgBackend {
|
||||||
let seat = Rc::new(XorgSeat {
|
let seat = Rc::new(XorgSeat {
|
||||||
id: self.state.seat_ids.next(),
|
id: self.state.seat_ids.next(),
|
||||||
backend: self.clone(),
|
backend: self.clone(),
|
||||||
kb: info.deviceid,
|
_kb: info.deviceid,
|
||||||
mouse: info.attachment,
|
mouse: info.attachment,
|
||||||
removed: Cell::new(false),
|
removed: Cell::new(false),
|
||||||
cb: RefCell::new(None),
|
cb: RefCell::new(None),
|
||||||
|
|
@ -481,7 +481,7 @@ impl XorgBackend {
|
||||||
1 => BTN_LEFT,
|
1 => BTN_LEFT,
|
||||||
2 => BTN_MIDDLE,
|
2 => BTN_MIDDLE,
|
||||||
3 => BTN_RIGHT,
|
3 => BTN_RIGHT,
|
||||||
n => n + BTN_SIDE - 8,
|
n => BTN_SIDE + n - 8,
|
||||||
};
|
};
|
||||||
seat.event(SeatEvent::Button(button, state));
|
seat.event(SeatEvent::Button(button, state));
|
||||||
}
|
}
|
||||||
|
|
@ -516,7 +516,9 @@ impl XorgBackend {
|
||||||
};
|
};
|
||||||
for info in infos {
|
for info in infos {
|
||||||
if info.flags & ffi::XCB_INPUT_HIERARCHY_MASK_MASTER_ADDED != 0 {
|
if info.flags & ffi::XCB_INPUT_HIERARCHY_MASK_MASTER_ADDED != 0 {
|
||||||
self.query_devices(info.deviceid);
|
if let Err(e) = self.query_devices(info.deviceid) {
|
||||||
|
log::error!("Could not query device {}: {:#}", info.deviceid, e);
|
||||||
|
}
|
||||||
} else if info.flags & ffi::XCB_INPUT_HIERARCHY_MASK_MASTER_REMOVED != 0 {
|
} else if info.flags & ffi::XCB_INPUT_HIERARCHY_MASK_MASTER_REMOVED != 0 {
|
||||||
self.mouse_seats.remove(&info.attachment);
|
self.mouse_seats.remove(&info.attachment);
|
||||||
if let Some(seat) = self.seats.remove(&info.deviceid) {
|
if let Some(seat) = self.seats.remove(&info.deviceid) {
|
||||||
|
|
@ -654,7 +656,7 @@ impl XorgBackend {
|
||||||
node_extents.x - surface_extents.x1,
|
node_extents.x - surface_extents.x1,
|
||||||
node_extents.y - surface_extents.y1,
|
node_extents.y - surface_extents.y1,
|
||||||
);
|
);
|
||||||
image.fill_insert_border(
|
let _ = image.fill_insert_border(
|
||||||
255,
|
255,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
@ -700,7 +702,15 @@ impl XorgBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_buffer(&self, image: &Image<Rc<ServerMem>>, buffer: &Rc<WlBuffer>, x: i32, y: i32) {
|
fn render_buffer(&self, image: &Image<Rc<ServerMem>>, buffer: &Rc<WlBuffer>, x: i32, y: i32) {
|
||||||
image.add_image(&buffer.image, x, y);
|
if let Err(e) = image.add_image(&buffer.image, x, y) {
|
||||||
|
let client = &buffer.client;
|
||||||
|
log::error!("Could not access client {} memory: {:#}", client.id, e);
|
||||||
|
if let Ok(d) = client.display() {
|
||||||
|
client.fatal_event(d.implementation_error(format!("Could not access memory: {:#}", e)));
|
||||||
|
} else {
|
||||||
|
self.state.clients.kill(client.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self) -> Result<(), XorgBackendError> {
|
fn render(&self) -> Result<(), XorgBackendError> {
|
||||||
|
|
@ -711,7 +721,7 @@ impl XorgBackend {
|
||||||
Some(i) => i,
|
Some(i) => i,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
image.fill(0, 0, 0, 255);
|
let _ = image.fill(0, 0, 0, 255);
|
||||||
let node = match self.state.root.outputs.get(&output.id) {
|
let node = match self.state.root.outputs.get(&output.id) {
|
||||||
Some(n) => n,
|
Some(n) => n,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
|
@ -808,7 +818,7 @@ impl Output for XorgOutput {
|
||||||
struct XorgSeat {
|
struct XorgSeat {
|
||||||
id: SeatId,
|
id: SeatId,
|
||||||
backend: Rc<XorgBackend>,
|
backend: Rc<XorgBackend>,
|
||||||
kb: ffi::xcb_input_device_id_t,
|
_kb: ffi::xcb_input_device_id_t,
|
||||||
mouse: ffi::xcb_input_device_id_t,
|
mouse: ffi::xcb_input_device_id_t,
|
||||||
removed: Cell<bool>,
|
removed: Cell<bool>,
|
||||||
cb: RefCell<Option<Rc<dyn Fn()>>>,
|
cb: RefCell<Option<Rc<dyn Fn()>>>,
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ impl Clients {
|
||||||
global: &Rc<State>,
|
global: &Rc<State>,
|
||||||
socket: OwnedFd,
|
socket: OwnedFd,
|
||||||
) -> Result<(), ClientError> {
|
) -> Result<(), ClientError> {
|
||||||
let (uid, pid) = unsafe {
|
let (uid, pid) = {
|
||||||
let mut cred = c::ucred {
|
let mut cred = c::ucred {
|
||||||
pid: 0,
|
pid: 0,
|
||||||
uid: 0,
|
uid: 0,
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ impl Objects {
|
||||||
self.buffers.clear();
|
self.buffers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
|
fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
|
||||||
where
|
where
|
||||||
ObjectId: Into<T>,
|
ObjectId: Into<T>,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ pub fn formats() -> AHashMap<u32, &'static Format> {
|
||||||
map
|
map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
const fn fourcc_code(a: char, b: char, c: char, d: char) -> u32 {
|
const fn fourcc_code(a: char, b: char, c: char, d: char) -> u32 {
|
||||||
(a as u32) | ((b as u32) << 8) | ((c as u32) << 16) | ((d as u32) << 24)
|
(a as u32) | ((b as u32) << 8) | ((c as u32) << 16) | ((d as u32) << 24)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ pub trait Global: GlobalBind {
|
||||||
fn singleton(&self) -> bool;
|
fn singleton(&self) -> bool;
|
||||||
fn interface(&self) -> Interface;
|
fn interface(&self) -> Interface;
|
||||||
fn version(&self) -> u32;
|
fn version(&self) -> u32;
|
||||||
fn pre_remove(&self);
|
|
||||||
fn break_loops(&self) {}
|
fn break_loops(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,8 +126,7 @@ impl Globals {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn remove(&self, state: &State, name: GlobalName) -> Result<(), GlobalError> {
|
pub async fn remove(&self, state: &State, name: GlobalName) -> Result<(), GlobalError> {
|
||||||
let global = self.take(name, true)?;
|
let _global = self.take(name, true)?;
|
||||||
global.pre_remove();
|
|
||||||
self.broadcast(state, |r| r.global_remove(name)).await;
|
self.broadcast(state, |r| r.global_remove(name)).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -187,6 +185,7 @@ impl Globals {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_output(&self, output: GlobalName) -> Result<Rc<WlOutputGlobal>, GlobalError> {
|
pub fn get_output(&self, output: GlobalName) -> Result<Rc<WlOutputGlobal>, GlobalError> {
|
||||||
match self.outputs.get(&output) {
|
match self.outputs.get(&output) {
|
||||||
Some(o) => Ok(o),
|
Some(o) => Ok(o),
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@ id!(WlBufferId);
|
||||||
|
|
||||||
pub struct WlBuffer {
|
pub struct WlBuffer {
|
||||||
id: WlBufferId,
|
id: WlBufferId,
|
||||||
client: Rc<Client>,
|
pub client: Rc<Client>,
|
||||||
offset: usize,
|
_offset: usize,
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
stride: u32,
|
_stride: u32,
|
||||||
format: &'static Format,
|
_format: &'static Format,
|
||||||
pub image: Rc<pixman::Image<ClientMemOffset>>,
|
pub image: Rc<pixman::Image<ClientMemOffset>>,
|
||||||
pub(super) surfaces: CopyHashMap<WlSurfaceId, Rc<WlSurface>>,
|
pub(super) surfaces: CopyHashMap<WlSurfaceId, Rc<WlSurface>>,
|
||||||
}
|
}
|
||||||
|
|
@ -54,11 +54,11 @@ impl WlBuffer {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
id,
|
id,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
offset,
|
_offset: offset,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
stride,
|
_stride: stride,
|
||||||
format,
|
_format: format,
|
||||||
image: Rc::new(image),
|
image: Rc::new(image),
|
||||||
surfaces: Default::default(),
|
surfaces: Default::default(),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,9 @@ pub struct WlCompositorGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WlCompositorObj {
|
pub struct WlCompositorObj {
|
||||||
global: Rc<WlCompositorGlobal>,
|
|
||||||
id: WlCompositorId,
|
id: WlCompositorId,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
version: u32,
|
_version: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WlCompositorGlobal {
|
impl WlCompositorGlobal {
|
||||||
|
|
@ -37,10 +36,9 @@ impl WlCompositorGlobal {
|
||||||
version: u32,
|
version: u32,
|
||||||
) -> Result<(), WlCompositorError> {
|
) -> Result<(), WlCompositorError> {
|
||||||
let obj = Rc::new(WlCompositorObj {
|
let obj = Rc::new(WlCompositorObj {
|
||||||
global: self,
|
|
||||||
id,
|
id,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
version,
|
_version: version,
|
||||||
});
|
});
|
||||||
client.add_client_obj(&obj)?;
|
client.add_client_obj(&obj)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -94,10 +92,6 @@ impl Global for WlCompositorGlobal {
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
4
|
4
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_remove(&self) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_request!(WlCompositorObj);
|
handle_request!(WlCompositorObj);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const MOTION: u32 = 4;
|
||||||
const DROP: u32 = 5;
|
const DROP: u32 = 5;
|
||||||
const SELECTION: u32 = 5;
|
const SELECTION: u32 = 5;
|
||||||
|
|
||||||
const ROLE: u32 = 0;
|
#[allow(dead_code)] const ROLE: u32 = 0;
|
||||||
|
|
||||||
id!(WlDataDeviceId);
|
id!(WlDataDeviceId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ use crate::ifs::wl_data_source::WlDataSource;
|
||||||
const CREATE_DATA_SOURCE: u32 = 0;
|
const CREATE_DATA_SOURCE: u32 = 0;
|
||||||
const GET_DATA_DEVICE: u32 = 1;
|
const GET_DATA_DEVICE: u32 = 1;
|
||||||
|
|
||||||
const DND_NONE: u32 = 0;
|
#[allow(dead_code)] const DND_NONE: u32 = 0;
|
||||||
const DND_COPY: u32 = 1;
|
#[allow(dead_code)] const DND_COPY: u32 = 1;
|
||||||
const DND_MOVE: u32 = 2;
|
#[allow(dead_code)] const DND_MOVE: u32 = 2;
|
||||||
const DND_ASK: u32 = 4;
|
#[allow(dead_code)] const DND_ASK: u32 = 4;
|
||||||
|
|
||||||
id!(WlDataDeviceManagerId);
|
id!(WlDataDeviceManagerId);
|
||||||
|
|
||||||
|
|
@ -98,10 +98,6 @@ impl Global for WlDataDeviceManagerGlobal {
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_remove(&self) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_request!(WlDataDeviceManagerObj);
|
handle_request!(WlDataDeviceManagerObj);
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ const OFFER: u32 = 0;
|
||||||
const SOURCE_ACTIONS: u32 = 1;
|
const SOURCE_ACTIONS: u32 = 1;
|
||||||
const ACTION: u32 = 2;
|
const ACTION: u32 = 2;
|
||||||
|
|
||||||
const INVALID_FINISH: u32 = 0;
|
#[allow(dead_code)] const INVALID_FINISH: u32 = 0;
|
||||||
const INVALID_ACTION_MASK: u32 = 1;
|
#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 1;
|
||||||
const INVALID_ACTION: u32 = 2;
|
#[allow(dead_code)] const INVALID_ACTION: u32 = 2;
|
||||||
const INVALID_OFFER: u32 = 3;
|
#[allow(dead_code)] const INVALID_OFFER: u32 = 3;
|
||||||
|
|
||||||
id!(WlDataOfferId);
|
id!(WlDataOfferId);
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ impl Object for WlDataOffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn interface(&self) -> Interface {
|
fn interface(&self) -> Interface {
|
||||||
Interface::WlDataSource
|
Interface::WlDataOffer
|
||||||
}
|
}
|
||||||
|
|
||||||
fn num_requests(&self) -> u32 {
|
fn num_requests(&self) -> u32 {
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ const DND_DROP_PERFORMED: u32 = 4;
|
||||||
const DND_FINISHED: u32 = 5;
|
const DND_FINISHED: u32 = 5;
|
||||||
const ACTION: u32 = 5;
|
const ACTION: u32 = 5;
|
||||||
|
|
||||||
const INVALID_ACTION_MASK: u32 = 0;
|
#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 0;
|
||||||
const INVALID_SOURCE: u32 = 1;
|
#[allow(dead_code)] const INVALID_SOURCE: u32 = 1;
|
||||||
|
|
||||||
id!(WlDataSourceId);
|
id!(WlDataSourceId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const DELETE_ID: u32 = 1;
|
||||||
|
|
||||||
const INVALID_OBJECT: u32 = 0;
|
const INVALID_OBJECT: u32 = 0;
|
||||||
const INVALID_METHOD: u32 = 1;
|
const INVALID_METHOD: u32 = 1;
|
||||||
const NO_MEMORY: u32 = 2;
|
#[allow(dead_code)] const NO_MEMORY: u32 = 2;
|
||||||
const IMPLEMENTATION: u32 = 3;
|
const IMPLEMENTATION: u32 = 3;
|
||||||
|
|
||||||
pub struct WlDisplay {
|
pub struct WlDisplay {
|
||||||
|
|
|
||||||
|
|
@ -22,23 +22,23 @@ const DONE: u32 = 2;
|
||||||
const SCALE: u32 = 3;
|
const SCALE: u32 = 3;
|
||||||
|
|
||||||
const SP_UNKNOWN: i32 = 0;
|
const SP_UNKNOWN: i32 = 0;
|
||||||
const SP_NONE: i32 = 1;
|
#[allow(dead_code)] const SP_NONE: i32 = 1;
|
||||||
const SP_HORIZONTAL_RGB: i32 = 2;
|
#[allow(dead_code)] const SP_HORIZONTAL_RGB: i32 = 2;
|
||||||
const SP_HORIZONTAL_BGR: i32 = 3;
|
#[allow(dead_code)] const SP_HORIZONTAL_BGR: i32 = 3;
|
||||||
const SP_VERTICAL_RGB: i32 = 4;
|
#[allow(dead_code)] const SP_VERTICAL_RGB: i32 = 4;
|
||||||
const SP_VERTICAL_BGR: i32 = 5;
|
#[allow(dead_code)] const SP_VERTICAL_BGR: i32 = 5;
|
||||||
|
|
||||||
const TF_NORMAL: i32 = 0;
|
const TF_NORMAL: i32 = 0;
|
||||||
const TF_90: i32 = 1;
|
#[allow(dead_code)] const TF_90: i32 = 1;
|
||||||
const TF_180: i32 = 2;
|
#[allow(dead_code)] const TF_180: i32 = 2;
|
||||||
const TF_270: i32 = 3;
|
#[allow(dead_code)] const TF_270: i32 = 3;
|
||||||
const TF_FLIPPED: i32 = 4;
|
#[allow(dead_code)] const TF_FLIPPED: i32 = 4;
|
||||||
const TF_FLIPPED_90: i32 = 5;
|
#[allow(dead_code)] const TF_FLIPPED_90: i32 = 5;
|
||||||
const TF_FLIPPED_180: i32 = 6;
|
#[allow(dead_code)] const TF_FLIPPED_180: i32 = 6;
|
||||||
const TF_FLIPPED_270: i32 = 7;
|
#[allow(dead_code)] const TF_FLIPPED_270: i32 = 7;
|
||||||
|
|
||||||
const MODE_CURRENT: u32 = 1;
|
const MODE_CURRENT: u32 = 1;
|
||||||
const MODE_PREFERRED: u32 = 2;
|
#[allow(dead_code)] const MODE_PREFERRED: u32 = 2;
|
||||||
|
|
||||||
pub struct WlOutputGlobal {
|
pub struct WlOutputGlobal {
|
||||||
name: GlobalName,
|
name: GlobalName,
|
||||||
|
|
@ -109,13 +109,18 @@ impl WlOutputGlobal {
|
||||||
global: self.clone(),
|
global: self.clone(),
|
||||||
id,
|
id,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
client.add_client_obj(&obj)?;
|
client.add_client_obj(&obj)?;
|
||||||
self.bindings.set((client.id, id), obj.clone());
|
self.bindings.set((client.id, id), obj.clone());
|
||||||
client.event(obj.geometry()).await?;
|
client.event(obj.geometry()).await?;
|
||||||
client.event(obj.mode()).await?;
|
client.event(obj.mode()).await?;
|
||||||
client.event(obj.scale()).await?;
|
if obj.send_scale() {
|
||||||
client.event(obj.done()).await?;
|
client.event(obj.scale()).await?;
|
||||||
|
}
|
||||||
|
if obj.send_done() {
|
||||||
|
client.event(obj.done()).await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -139,10 +144,6 @@ impl Global for WlOutputGlobal {
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_remove(&self) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
fn break_loops(&self) {
|
fn break_loops(&self) {
|
||||||
self.bindings.clear();
|
self.bindings.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -152,9 +153,18 @@ pub struct WlOutputObj {
|
||||||
global: Rc<WlOutputGlobal>,
|
global: Rc<WlOutputGlobal>,
|
||||||
id: WlOutputId,
|
id: WlOutputId,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
|
version: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WlOutputObj {
|
impl WlOutputObj {
|
||||||
|
fn send_done(&self) -> bool {
|
||||||
|
self.version >= 2
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_scale(&self) -> bool {
|
||||||
|
self.version >= 2
|
||||||
|
}
|
||||||
|
|
||||||
fn geometry(self: &Rc<Self>) -> DynEventFormatter {
|
fn geometry(self: &Rc<Self>) -> DynEventFormatter {
|
||||||
Box::new(Geometry {
|
Box::new(Geometry {
|
||||||
obj: self.clone(),
|
obj: self.clone(),
|
||||||
|
|
@ -222,7 +232,11 @@ impl Object for WlOutputObj {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn num_requests(&self) -> u32 {
|
fn num_requests(&self) -> u32 {
|
||||||
RELEASE + 1
|
if self.version < 3 {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
RELEASE + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn break_loops(&self) {
|
fn break_loops(&self) {
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,14 @@ const NAME: u32 = 1;
|
||||||
|
|
||||||
const POINTER: u32 = 1;
|
const POINTER: u32 = 1;
|
||||||
const KEYBOARD: u32 = 2;
|
const KEYBOARD: u32 = 2;
|
||||||
const TOUCH: u32 = 4;
|
#[allow(dead_code)] const TOUCH: u32 = 4;
|
||||||
|
|
||||||
const MISSING_CAPABILITY: u32 = 0;
|
#[allow(dead_code)] const MISSING_CAPABILITY: u32 = 0;
|
||||||
|
|
||||||
pub struct WlSeatGlobal {
|
pub struct WlSeatGlobal {
|
||||||
name: GlobalName,
|
name: GlobalName,
|
||||||
state: Rc<State>,
|
state: Rc<State>,
|
||||||
seat: Rc<dyn Seat>,
|
_seat: Rc<dyn Seat>,
|
||||||
move_: Cell<bool>,
|
move_: Cell<bool>,
|
||||||
move_start_pos: Cell<(Fixed, Fixed)>,
|
move_start_pos: Cell<(Fixed, Fixed)>,
|
||||||
extents_start_pos: Cell<(i32, i32)>,
|
extents_start_pos: Cell<(i32, i32)>,
|
||||||
|
|
@ -75,7 +75,7 @@ impl WlSeatGlobal {
|
||||||
Self {
|
Self {
|
||||||
name,
|
name,
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
seat: seat.clone(),
|
_seat: seat.clone(),
|
||||||
move_: Cell::new(false),
|
move_: Cell::new(false),
|
||||||
move_start_pos: Cell::new((Fixed(0), Fixed(0))),
|
move_start_pos: Cell::new((Fixed(0), Fixed(0))),
|
||||||
extents_start_pos: Cell::new((0, 0)),
|
extents_start_pos: Cell::new((0, 0)),
|
||||||
|
|
@ -217,7 +217,7 @@ impl WlSeatGlobal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn key_event(&self, key: u32, state: KeyState) {}
|
async fn key_event(&self, _key: u32, _state: KeyState) {}
|
||||||
|
|
||||||
async fn bind_(
|
async fn bind_(
|
||||||
self: Rc<Self>,
|
self: Rc<Self>,
|
||||||
|
|
@ -231,6 +231,7 @@ impl WlSeatGlobal {
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
pointers: Default::default(),
|
pointers: Default::default(),
|
||||||
keyboards: Default::default(),
|
keyboards: Default::default(),
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
client.add_client_obj(&obj)?;
|
client.add_client_obj(&obj)?;
|
||||||
client.event(obj.capabilities()).await?;
|
client.event(obj.capabilities()).await?;
|
||||||
|
|
@ -261,11 +262,7 @@ impl Global for WlSeatGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
3
|
7
|
||||||
}
|
|
||||||
|
|
||||||
fn pre_remove(&self) {
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn break_loops(&self) {
|
fn break_loops(&self) {
|
||||||
|
|
@ -279,6 +276,7 @@ pub struct WlSeatObj {
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>,
|
pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>,
|
||||||
keyboards: CopyHashMap<WlKeyboardId, Rc<WlKeyboard>>,
|
keyboards: CopyHashMap<WlKeyboardId, Rc<WlKeyboard>>,
|
||||||
|
version: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WlSeatObj {
|
impl WlSeatObj {
|
||||||
|
|
@ -369,7 +367,11 @@ impl Object for WlSeatObj {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn num_requests(&self) -> u32 {
|
fn num_requests(&self) -> u32 {
|
||||||
RELEASE + 1
|
if self.version < 5 {
|
||||||
|
GET_TOUCH + 1
|
||||||
|
} else {
|
||||||
|
RELEASE + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn break_loops(&self) {
|
fn break_loops(&self) {
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ const KEY: u32 = 3;
|
||||||
const MODIFIERS: u32 = 4;
|
const MODIFIERS: u32 = 4;
|
||||||
const REPEAT_INFO: u32 = 5;
|
const REPEAT_INFO: u32 = 5;
|
||||||
|
|
||||||
const NO_KEYMAP: u32 = 0;
|
#[allow(dead_code)] const NO_KEYMAP: u32 = 0;
|
||||||
pub(super) const XKB_V1: u32 = 1;
|
pub(super) const XKB_V1: u32 = 1;
|
||||||
|
|
||||||
const RELEASED: u32 = 0;
|
#[allow(dead_code)] const RELEASED: u32 = 0;
|
||||||
const PRESSED: u32 = 1;
|
#[allow(dead_code)] const PRESSED: u32 = 1;
|
||||||
|
|
||||||
id!(WlKeyboardId);
|
id!(WlKeyboardId);
|
||||||
|
|
||||||
|
|
@ -48,6 +48,7 @@ impl WlKeyboard {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn enter(
|
pub fn enter(
|
||||||
self: &Rc<Self>,
|
self: &Rc<Self>,
|
||||||
serial: u32,
|
serial: u32,
|
||||||
|
|
@ -62,6 +63,7 @@ impl WlKeyboard {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
||||||
Box::new(Leave {
|
Box::new(Leave {
|
||||||
obj: self.clone(),
|
obj: self.clone(),
|
||||||
|
|
@ -70,6 +72,7 @@ impl WlKeyboard {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn key(self: &Rc<Self>, serial: u32, time: u32, key: u32, state: u32) -> DynEventFormatter {
|
pub fn key(self: &Rc<Self>, serial: u32, time: u32, key: u32, state: u32) -> DynEventFormatter {
|
||||||
Box::new(Key {
|
Box::new(Key {
|
||||||
obj: self.clone(),
|
obj: self.clone(),
|
||||||
|
|
@ -80,6 +83,7 @@ impl WlKeyboard {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn modifiers(
|
pub fn modifiers(
|
||||||
self: &Rc<Self>,
|
self: &Rc<Self>,
|
||||||
serial: u32,
|
serial: u32,
|
||||||
|
|
@ -98,6 +102,7 @@ impl WlKeyboard {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn repeat_info(self: &Rc<Self>, rate: i32, delay: i32) -> DynEventFormatter {
|
pub fn repeat_info(self: &Rc<Self>, rate: i32, delay: i32) -> DynEventFormatter {
|
||||||
Box::new(RepeatInfo {
|
Box::new(RepeatInfo {
|
||||||
obj: self.clone(),
|
obj: self.clone(),
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ const AXIS_SOURCE: u32 = 6;
|
||||||
const AXIS_STOP: u32 = 7;
|
const AXIS_STOP: u32 = 7;
|
||||||
const AXIS_DISCRETE: u32 = 8;
|
const AXIS_DISCRETE: u32 = 8;
|
||||||
|
|
||||||
const ROLE: u32 = 0;
|
#[allow(dead_code)] const ROLE: u32 = 0;
|
||||||
|
|
||||||
pub(super) const RELEASED: u32 = 0;
|
pub(super) const RELEASED: u32 = 0;
|
||||||
pub(super) const PRESSED: u32 = 1;
|
pub(super) const PRESSED: u32 = 1;
|
||||||
|
|
@ -30,10 +30,10 @@ pub(super) const PRESSED: u32 = 1;
|
||||||
pub(super) const VERTICAL_SCROLL: u32 = 0;
|
pub(super) const VERTICAL_SCROLL: u32 = 0;
|
||||||
pub(super) const HORIZONTAL_SCROLL: u32 = 1;
|
pub(super) const HORIZONTAL_SCROLL: u32 = 1;
|
||||||
|
|
||||||
const WHEEL: u32 = 0;
|
#[allow(dead_code)] const WHEEL: u32 = 0;
|
||||||
const FINGER: u32 = 1;
|
#[allow(dead_code)] const FINGER: u32 = 1;
|
||||||
const CONTINUOUS: u32 = 2;
|
#[allow(dead_code)] const CONTINUOUS: u32 = 2;
|
||||||
const WHEEL_TILT: u32 = 3;
|
#[allow(dead_code)] const WHEEL_TILT: u32 = 3;
|
||||||
|
|
||||||
id!(WlPointerId);
|
id!(WlPointerId);
|
||||||
|
|
||||||
|
|
@ -108,10 +108,12 @@ impl WlPointer {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn frame(self: &Rc<Self>) -> DynEventFormatter {
|
pub fn frame(self: &Rc<Self>) -> DynEventFormatter {
|
||||||
Box::new(Frame { obj: self.clone() })
|
Box::new(Frame { obj: self.clone() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn axis_source(self: &Rc<Self>, axis_source: u32) -> DynEventFormatter {
|
pub fn axis_source(self: &Rc<Self>, axis_source: u32) -> DynEventFormatter {
|
||||||
Box::new(AxisSource {
|
Box::new(AxisSource {
|
||||||
obj: self.clone(),
|
obj: self.clone(),
|
||||||
|
|
@ -119,6 +121,7 @@ impl WlPointer {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn axis_stop(self: &Rc<Self>, time: u32, axis: u32) -> DynEventFormatter {
|
pub fn axis_stop(self: &Rc<Self>, time: u32, axis: u32) -> DynEventFormatter {
|
||||||
Box::new(AxisStop {
|
Box::new(AxisStop {
|
||||||
obj: self.clone(),
|
obj: self.clone(),
|
||||||
|
|
@ -127,6 +130,7 @@ impl WlPointer {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn axis_discrete(self: &Rc<Self>, axis: u32, discrete: i32) -> DynEventFormatter {
|
pub fn axis_discrete(self: &Rc<Self>, axis: u32, discrete: i32) -> DynEventFormatter {
|
||||||
Box::new(AxisDiscrete {
|
Box::new(AxisDiscrete {
|
||||||
obj: self.clone(),
|
obj: self.clone(),
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ pub use types::*;
|
||||||
|
|
||||||
const RELEASE: u32 = 0;
|
const RELEASE: u32 = 0;
|
||||||
|
|
||||||
const DOWN: u32 = 0;
|
#[allow(dead_code)] const DOWN: u32 = 0;
|
||||||
const UP: u32 = 1;
|
#[allow(dead_code)] const UP: u32 = 1;
|
||||||
const MOTION: u32 = 2;
|
#[allow(dead_code)] const MOTION: u32 = 2;
|
||||||
const FRAME: u32 = 3;
|
#[allow(dead_code)] const FRAME: u32 = 3;
|
||||||
const CANCEL: u32 = 4;
|
#[allow(dead_code)] const CANCEL: u32 = 4;
|
||||||
const SHAPE: u32 = 5;
|
#[allow(dead_code)] const SHAPE: u32 = 5;
|
||||||
const ORIENTATION: u32 = 6;
|
#[allow(dead_code)] const ORIENTATION: u32 = 6;
|
||||||
|
|
||||||
id!(WlTouchId);
|
id!(WlTouchId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ pub struct WlShmGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WlShmObj {
|
pub struct WlShmObj {
|
||||||
global: Rc<WlShmGlobal>,
|
_global: Rc<WlShmGlobal>,
|
||||||
id: WlShmId,
|
id: WlShmId,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ impl WlShmGlobal {
|
||||||
_version: u32,
|
_version: u32,
|
||||||
) -> Result<(), WlShmError> {
|
) -> Result<(), WlShmError> {
|
||||||
let obj = Rc::new(WlShmObj {
|
let obj = Rc::new(WlShmObj {
|
||||||
global: self,
|
_global: self,
|
||||||
id,
|
id,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
});
|
});
|
||||||
|
|
@ -100,10 +100,6 @@ impl Global for WlShmGlobal {
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_remove(&self) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_request!(WlShmObj);
|
handle_request!(WlShmObj);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ pub use types::*;
|
||||||
const DESTROY: u32 = 0;
|
const DESTROY: u32 = 0;
|
||||||
const GET_SUBSURFACE: u32 = 1;
|
const GET_SUBSURFACE: u32 = 1;
|
||||||
|
|
||||||
const BAD_SURFACE: u32 = 0;
|
#[allow(dead_code)] const BAD_SURFACE: u32 = 0;
|
||||||
|
|
||||||
id!(WlSubcompositorId);
|
id!(WlSubcompositorId);
|
||||||
|
|
||||||
|
|
@ -20,7 +20,6 @@ pub struct WlSubcompositorGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WlSubcompositorObj {
|
pub struct WlSubcompositorObj {
|
||||||
global: Rc<WlSubcompositorGlobal>,
|
|
||||||
id: WlSubcompositorId,
|
id: WlSubcompositorId,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +36,6 @@ impl WlSubcompositorGlobal {
|
||||||
_version: u32,
|
_version: u32,
|
||||||
) -> Result<(), WlSubcompositorError> {
|
) -> Result<(), WlSubcompositorError> {
|
||||||
let obj = Rc::new(WlSubcompositorObj {
|
let obj = Rc::new(WlSubcompositorObj {
|
||||||
global: self,
|
|
||||||
id,
|
id,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
});
|
});
|
||||||
|
|
@ -95,10 +93,6 @@ impl Global for WlSubcompositorGlobal {
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_remove(&self) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_request!(WlSubcompositorObj);
|
handle_request!(WlSubcompositorObj);
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,12 @@ const SET_BUFFER_TRANSFORM: u32 = 7;
|
||||||
const SET_BUFFER_SCALE: u32 = 8;
|
const SET_BUFFER_SCALE: u32 = 8;
|
||||||
const DAMAGE_BUFFER: u32 = 9;
|
const DAMAGE_BUFFER: u32 = 9;
|
||||||
|
|
||||||
const ENTER: u32 = 0;
|
#[allow(dead_code)] const ENTER: u32 = 0;
|
||||||
const LEAVE: u32 = 1;
|
#[allow(dead_code)] const LEAVE: u32 = 1;
|
||||||
|
|
||||||
const INVALID_SCALE: u32 = 0;
|
#[allow(dead_code)] const INVALID_SCALE: u32 = 0;
|
||||||
const INVALID_TRANSFORM: u32 = 1;
|
#[allow(dead_code)] const INVALID_TRANSFORM: u32 = 1;
|
||||||
const INVALID_SIZE: u32 = 2;
|
#[allow(dead_code)] const INVALID_SIZE: u32 = 2;
|
||||||
|
|
||||||
id!(WlSurfaceId);
|
id!(WlSurfaceId);
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ impl XdgSurfaceRoleData {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct XdgPopupData {
|
struct XdgPopupData {
|
||||||
popup: Rc<XdgPopup>,
|
_popup: Rc<XdgPopup>,
|
||||||
parent: Option<Rc<XdgSurface>>,
|
parent: Option<Rc<XdgSurface>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ impl WlSurface {
|
||||||
for surface in children.subsurfaces.values() {
|
for surface in children.subsurfaces.values() {
|
||||||
let rd = surface.role_data.borrow();
|
let rd = surface.role_data.borrow();
|
||||||
if let RoleData::Subsurface(ss) = &*rd {
|
if let RoleData::Subsurface(ss) = &*rd {
|
||||||
let mut ss_extents = surface.extents.get();
|
let ss_extents = surface.extents.get();
|
||||||
extents.x1 = extents.x1.min(ss_extents.x1 + ss.x);
|
extents.x1 = extents.x1.min(ss_extents.x1 + ss.x);
|
||||||
extents.y1 = extents.y1.min(ss_extents.y1 + ss.y);
|
extents.y1 = extents.y1.min(ss_extents.y1 + ss.y);
|
||||||
extents.x2 = extents.x2.max(ss_extents.x2 + ss.x);
|
extents.x2 = extents.x2.max(ss_extents.x2 + ss.x);
|
||||||
|
|
@ -249,10 +249,6 @@ impl WlSurface {
|
||||||
parent.calculate_extents();
|
parent.calculate_extents();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_subsurface(&self) -> bool {
|
|
||||||
self.role.get() == SurfaceRole::Subsurface
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_root(self: &Rc<Self>) -> Rc<WlSurface> {
|
pub fn get_root(self: &Rc<Self>) -> Rc<WlSurface> {
|
||||||
let mut root = self.clone();
|
let mut root = self.clone();
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -381,7 +377,7 @@ impl WlSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn damage(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageError> {
|
async fn damage(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageError> {
|
||||||
let req: Damage = self.parse(parser)?;
|
let _req: Damage = self.parse(parser)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -518,17 +514,17 @@ impl WlSurface {
|
||||||
&self,
|
&self,
|
||||||
parser: MsgParser<'_, '_>,
|
parser: MsgParser<'_, '_>,
|
||||||
) -> Result<(), SetBufferTransformError> {
|
) -> Result<(), SetBufferTransformError> {
|
||||||
let req: SetBufferTransform = self.parse(parser)?;
|
let _req: SetBufferTransform = self.parse(parser)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn set_buffer_scale(&self, parser: MsgParser<'_, '_>) -> Result<(), SetBufferScaleError> {
|
async fn set_buffer_scale(&self, parser: MsgParser<'_, '_>) -> Result<(), SetBufferScaleError> {
|
||||||
let req: SetBufferScale = self.parse(parser)?;
|
let _req: SetBufferScale = self.parse(parser)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn damage_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageBufferError> {
|
async fn damage_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageBufferError> {
|
||||||
let req: DamageBuffer = self.parse(parser)?;
|
let _req: DamageBuffer = self.parse(parser)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const PLACE_BELOW: u32 = 3;
|
||||||
const SET_SYNC: u32 = 4;
|
const SET_SYNC: u32 = 4;
|
||||||
const SET_DESYNC: u32 = 5;
|
const SET_DESYNC: u32 = 5;
|
||||||
|
|
||||||
const BAD_SURFACE: u32 = 0;
|
#[allow(dead_code)] const BAD_SURFACE: u32 = 0;
|
||||||
|
|
||||||
const MAX_SUBSURFACE_DEPTH: u32 = 100;
|
const MAX_SUBSURFACE_DEPTH: u32 = 100;
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ pub struct WlSubsurface {
|
||||||
pub(super) parent: Rc<WlSurface>,
|
pub(super) parent: Rc<WlSurface>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_children_sync(surface: &Rc<WlSurface>, sync: bool) -> Result<(), WlSubsurfaceError> {
|
fn update_children_sync(surface: &Rc<WlSurface>, sync: bool) {
|
||||||
let children = surface.children.borrow();
|
let children = surface.children.borrow();
|
||||||
if let Some(children) = &*children {
|
if let Some(children) = &*children {
|
||||||
for child in children.subsurfaces.values() {
|
for child in children.subsurfaces.values() {
|
||||||
|
|
@ -44,7 +44,6 @@ fn update_children_sync(surface: &Rc<WlSurface>, sync: bool) -> Result<(), WlSub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_children_attach(
|
fn update_children_attach(
|
||||||
|
|
@ -63,7 +62,7 @@ fn update_children_attach(
|
||||||
}
|
}
|
||||||
data.sync_ancestor = sync;
|
data.sync_ancestor = sync;
|
||||||
let sync = data.sync_ancestor || data.sync_requested;
|
let sync = data.sync_ancestor || data.sync_requested;
|
||||||
update_children_attach(child, sync, depth + 1);
|
update_children_attach(child, sync, depth + 1)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,16 @@ const ACK_CONFIGURE: u32 = 4;
|
||||||
|
|
||||||
const CONFIGURE: u32 = 0;
|
const CONFIGURE: u32 = 0;
|
||||||
|
|
||||||
const NOT_CONSTRUCTED: u32 = 1;
|
#[allow(dead_code)] const NOT_CONSTRUCTED: u32 = 1;
|
||||||
const ALREADY_CONSTRUCTED: u32 = 2;
|
const ALREADY_CONSTRUCTED: u32 = 2;
|
||||||
const UNCONFIGURED_BUFFER: u32 = 3;
|
#[allow(dead_code)] const UNCONFIGURED_BUFFER: u32 = 3;
|
||||||
|
|
||||||
id!(XdgSurfaceId);
|
id!(XdgSurfaceId);
|
||||||
|
|
||||||
pub struct XdgSurface {
|
pub struct XdgSurface {
|
||||||
id: XdgSurfaceId,
|
id: XdgSurfaceId,
|
||||||
wm_base: Rc<XdgWmBaseObj>,
|
base: Rc<XdgWmBaseObj>,
|
||||||
pub surface: Rc<WlSurface>,
|
pub surface: Rc<WlSurface>,
|
||||||
version: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XdgSurface {
|
impl XdgSurface {
|
||||||
|
|
@ -42,13 +41,11 @@ impl XdgSurface {
|
||||||
wm_base: &Rc<XdgWmBaseObj>,
|
wm_base: &Rc<XdgWmBaseObj>,
|
||||||
id: XdgSurfaceId,
|
id: XdgSurfaceId,
|
||||||
surface: &Rc<WlSurface>,
|
surface: &Rc<WlSurface>,
|
||||||
version: u32,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
wm_base: wm_base.clone(),
|
base: wm_base.clone(),
|
||||||
surface: surface.clone(),
|
surface: surface.clone(),
|
||||||
version,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,6 +61,7 @@ impl XdgSurface {
|
||||||
if !matches!(old_role, SurfaceRole::None | SurfaceRole::XdgSurface) {
|
if !matches!(old_role, SurfaceRole::None | SurfaceRole::XdgSurface) {
|
||||||
return Err(XdgSurfaceError::IncompatibleRole(self.surface.id, old_role));
|
return Err(XdgSurfaceError::IncompatibleRole(self.surface.id, old_role));
|
||||||
}
|
}
|
||||||
|
self.surface.role.set(SurfaceRole::XdgSurface);
|
||||||
let mut data = self.surface.role_data.borrow_mut();
|
let mut data = self.surface.role_data.borrow_mut();
|
||||||
if data.is_some() {
|
if data.is_some() {
|
||||||
return Err(XdgSurfaceError::AlreadyAttached(self.surface.id));
|
return Err(XdgSurfaceError::AlreadyAttached(self.surface.id));
|
||||||
|
|
@ -101,7 +99,7 @@ impl XdgSurface {
|
||||||
}
|
}
|
||||||
*data = RoleData::None;
|
*data = RoleData::None;
|
||||||
}
|
}
|
||||||
self.wm_base.surfaces.remove(&self.id);
|
self.base.surfaces.remove(&self.id);
|
||||||
self.surface.client.remove_obj(self).await?;
|
self.surface.client.remove_obj(self).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +126,7 @@ impl XdgSurface {
|
||||||
return Err(GetToplevelError::AlreadyConstructed);
|
return Err(GetToplevelError::AlreadyConstructed);
|
||||||
}
|
}
|
||||||
data.role = XdgSurfaceRole::Toplevel;
|
data.role = XdgSurfaceRole::Toplevel;
|
||||||
let toplevel = Rc::new(XdgToplevel::new(req.id, self, self.version));
|
let toplevel = Rc::new(XdgToplevel::new(req.id, self));
|
||||||
self.surface.client.add_client_obj(&toplevel)?;
|
self.surface.client.add_client_obj(&toplevel)?;
|
||||||
data.role_data = XdgSurfaceRoleData::Toplevel(XdgToplevelData {
|
data.role_data = XdgSurfaceRoleData::Toplevel(XdgToplevelData {
|
||||||
toplevel,
|
toplevel,
|
||||||
|
|
@ -161,7 +159,7 @@ impl XdgSurface {
|
||||||
return Err(GetPopupError::AlreadyConstructed);
|
return Err(GetPopupError::AlreadyConstructed);
|
||||||
}
|
}
|
||||||
data.role = XdgSurfaceRole::Popup;
|
data.role = XdgSurfaceRole::Popup;
|
||||||
let popup = Rc::new(XdgPopup::new(req.id, self, self.version));
|
let popup = Rc::new(XdgPopup::new(req.id, self));
|
||||||
self.surface.client.add_client_obj(&popup)?;
|
self.surface.client.add_client_obj(&popup)?;
|
||||||
if let Some(parent) = &parent {
|
if let Some(parent) = &parent {
|
||||||
let mut data = parent.surface.role_data.borrow_mut();
|
let mut data = parent.surface.role_data.borrow_mut();
|
||||||
|
|
@ -169,7 +167,7 @@ impl XdgSurface {
|
||||||
xdg.popups.set(self.surface.id, popup.clone());
|
xdg.popups.set(self.surface.id, popup.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { popup, parent });
|
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { _popup: popup, parent });
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,20 @@ const CONFIGURE: u32 = 0;
|
||||||
const POPUP_DONE: u32 = 1;
|
const POPUP_DONE: u32 = 1;
|
||||||
const REPOSITIONED: u32 = 2;
|
const REPOSITIONED: u32 = 2;
|
||||||
|
|
||||||
const INVALID_GRAB: u32 = 1;
|
#[allow(dead_code)] const INVALID_GRAB: u32 = 1;
|
||||||
|
|
||||||
id!(XdgPopupId);
|
id!(XdgPopupId);
|
||||||
|
|
||||||
pub struct XdgPopup {
|
pub struct XdgPopup {
|
||||||
id: XdgPopupId,
|
id: XdgPopupId,
|
||||||
pub(in super::super) surface: Rc<XdgSurface>,
|
pub(in super::super) surface: Rc<XdgSurface>,
|
||||||
version: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XdgPopup {
|
impl XdgPopup {
|
||||||
pub fn new(id: XdgPopupId, surface: &Rc<XdgSurface>, version: u32) -> Self {
|
pub fn new(id: XdgPopupId, surface: &Rc<XdgSurface>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
surface: surface.clone(),
|
surface: surface.clone(),
|
||||||
version,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,29 +40,27 @@ pub enum ResizeEdge {
|
||||||
BottomRight = 10,
|
BottomRight = 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
const STATE_MAXIMIZED: u32 = 1;
|
#[allow(dead_code)] const STATE_MAXIMIZED: u32 = 1;
|
||||||
const STATE_FULLSCREEN: u32 = 2;
|
#[allow(dead_code)] const STATE_FULLSCREEN: u32 = 2;
|
||||||
const STATE_RESIZING: u32 = 3;
|
#[allow(dead_code)] const STATE_RESIZING: u32 = 3;
|
||||||
const STATE_ACTIVATED: u32 = 4;
|
#[allow(dead_code)] const STATE_ACTIVATED: u32 = 4;
|
||||||
const STATE_TILED_LEFT: u32 = 5;
|
#[allow(dead_code)] const STATE_TILED_LEFT: u32 = 5;
|
||||||
const STATE_TILED_RIGHT: u32 = 6;
|
#[allow(dead_code)] const STATE_TILED_RIGHT: u32 = 6;
|
||||||
const STATE_TILED_TOP: u32 = 7;
|
#[allow(dead_code)] const STATE_TILED_TOP: u32 = 7;
|
||||||
const STATE_TILED_BOTTOM: u32 = 8;
|
#[allow(dead_code)] const STATE_TILED_BOTTOM: u32 = 8;
|
||||||
|
|
||||||
id!(XdgToplevelId);
|
id!(XdgToplevelId);
|
||||||
|
|
||||||
pub struct XdgToplevel {
|
pub struct XdgToplevel {
|
||||||
id: XdgToplevelId,
|
id: XdgToplevelId,
|
||||||
pub surface: Rc<XdgSurface>,
|
pub surface: Rc<XdgSurface>,
|
||||||
version: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XdgToplevel {
|
impl XdgToplevel {
|
||||||
pub fn new(id: XdgToplevelId, surface: &Rc<XdgSurface>, version: u32) -> Self {
|
pub fn new(id: XdgToplevelId, surface: &Rc<XdgSurface>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
surface: surface.clone(),
|
surface: surface.clone(),
|
||||||
version,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use num_traits::FromPrimitive;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::ifs::xdg_wm_base::XdgWmBaseObj;
|
||||||
|
|
||||||
const DESTROY: u32 = 0;
|
const DESTROY: u32 = 0;
|
||||||
const SET_SIZE: u32 = 1;
|
const SET_SIZE: u32 = 1;
|
||||||
|
|
@ -78,8 +79,8 @@ id!(XdgPositionerId);
|
||||||
|
|
||||||
pub struct XdgPositioner {
|
pub struct XdgPositioner {
|
||||||
id: XdgPositionerId,
|
id: XdgPositionerId,
|
||||||
|
base: Rc<XdgWmBaseObj>,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
version: u32,
|
|
||||||
position: RefCell<XdgPositioned>,
|
position: RefCell<XdgPositioned>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,15 +104,16 @@ pub struct XdgPositioned {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XdgPositioner {
|
impl XdgPositioner {
|
||||||
pub fn new(id: XdgPositionerId, client: &Rc<Client>, version: u32) -> Self {
|
pub fn new(base: &Rc<XdgWmBaseObj>, id: XdgPositionerId, client: &Rc<Client>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
version,
|
base: base.clone(),
|
||||||
position: RefCell::new(Default::default()),
|
position: RefCell::new(Default::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn clone(&self) -> Box<XdgPositioned> {
|
pub fn clone(&self) -> Box<XdgPositioned> {
|
||||||
Box::new(*self.position.borrow())
|
Box::new(*self.position.borrow())
|
||||||
}
|
}
|
||||||
|
|
@ -266,6 +268,10 @@ impl Object for XdgPositioner {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn num_requests(&self) -> u32 {
|
fn num_requests(&self) -> u32 {
|
||||||
SET_PARENT_CONFIGURE + 1
|
if self.base.version < 3 {
|
||||||
|
SET_OFFSET + 1
|
||||||
|
} else {
|
||||||
|
SET_PARENT_CONFIGURE + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@ const PONG: u32 = 3;
|
||||||
|
|
||||||
const PING: u32 = 0;
|
const PING: u32 = 0;
|
||||||
|
|
||||||
const ROLE: u32 = 0;
|
#[allow(dead_code)] const ROLE: u32 = 0;
|
||||||
const DEFUNCT_SURFACES: u32 = 1;
|
const DEFUNCT_SURFACES: u32 = 1;
|
||||||
const NOT_THE_TOPMOST_POPUP: u32 = 2;
|
#[allow(dead_code)] const NOT_THE_TOPMOST_POPUP: u32 = 2;
|
||||||
const INVALID_POPUP_PARENT: u32 = 3;
|
#[allow(dead_code)] const INVALID_POPUP_PARENT: u32 = 3;
|
||||||
const INVALID_SURFACE_STATE: u32 = 4;
|
#[allow(dead_code)] const INVALID_SURFACE_STATE: u32 = 4;
|
||||||
const INVALID_POSITIONER: u32 = 5;
|
#[allow(dead_code)] const INVALID_POSITIONER: u32 = 5;
|
||||||
|
|
||||||
id!(XdgWmBaseId);
|
id!(XdgWmBaseId);
|
||||||
|
|
||||||
|
|
@ -31,10 +31,9 @@ pub struct XdgWmBaseGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct XdgWmBaseObj {
|
pub struct XdgWmBaseObj {
|
||||||
global: Rc<XdgWmBaseGlobal>,
|
|
||||||
id: XdgWmBaseId,
|
id: XdgWmBaseId,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
version: u32,
|
pub version: u32,
|
||||||
pub(super) surfaces: CopyHashMap<XdgSurfaceId, Rc<XdgSurface>>,
|
pub(super) surfaces: CopyHashMap<XdgSurfaceId, Rc<XdgSurface>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +49,6 @@ impl XdgWmBaseGlobal {
|
||||||
version: u32,
|
version: u32,
|
||||||
) -> Result<(), XdgWmBaseError> {
|
) -> Result<(), XdgWmBaseError> {
|
||||||
let obj = Rc::new(XdgWmBaseObj {
|
let obj = Rc::new(XdgWmBaseObj {
|
||||||
global: self,
|
|
||||||
id,
|
id,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
version,
|
version,
|
||||||
|
|
@ -80,11 +78,11 @@ impl XdgWmBaseObj {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_positioner(
|
async fn create_positioner(
|
||||||
&self,
|
self: &Rc<Self>,
|
||||||
parser: MsgParser<'_, '_>,
|
parser: MsgParser<'_, '_>,
|
||||||
) -> Result<(), CreatePositionerError> {
|
) -> Result<(), CreatePositionerError> {
|
||||||
let req: CreatePositioner = self.client.parse(self, parser)?;
|
let req: CreatePositioner = self.client.parse(&**self, parser)?;
|
||||||
let pos = Rc::new(XdgPositioner::new(req.id, &self.client, 3));
|
let pos = Rc::new(XdgPositioner::new(self, req.id, &self.client));
|
||||||
self.client.add_client_obj(&pos)?;
|
self.client.add_client_obj(&pos)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +93,7 @@ impl XdgWmBaseObj {
|
||||||
) -> Result<(), GetXdgSurfaceError> {
|
) -> Result<(), GetXdgSurfaceError> {
|
||||||
let req: GetXdgSurface = self.client.parse(&**self, parser)?;
|
let req: GetXdgSurface = self.client.parse(&**self, parser)?;
|
||||||
let surface = self.client.get_surface(req.surface)?;
|
let surface = self.client.get_surface(req.surface)?;
|
||||||
let xdg_surface = Rc::new(XdgSurface::new(self, req.id, &surface, 3));
|
let xdg_surface = Rc::new(XdgSurface::new(self, req.id, &surface));
|
||||||
self.client.add_client_obj(&xdg_surface)?;
|
self.client.add_client_obj(&xdg_surface)?;
|
||||||
xdg_surface.install()?;
|
xdg_surface.install()?;
|
||||||
self.surfaces.set(req.id, xdg_surface);
|
self.surfaces.set(req.id, xdg_surface);
|
||||||
|
|
@ -141,10 +139,6 @@ impl Global for XdgWmBaseGlobal {
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_remove(&self) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_request!(XdgWmBaseObj);
|
handle_request!(XdgWmBaseObj);
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@ macro_rules! linear_ids {
|
||||||
pub struct $id(u32);
|
pub struct $id(u32);
|
||||||
|
|
||||||
impl $id {
|
impl $id {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn raw(&self) -> u32 {
|
pub fn raw(&self) -> u32 {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ pub const WL_DISPLAY_ID: ObjectId = ObjectId(1);
|
||||||
pub struct ObjectId(u32);
|
pub struct ObjectId(u32);
|
||||||
|
|
||||||
impl ObjectId {
|
impl ObjectId {
|
||||||
pub const NONE: Self = ObjectId(0);
|
|
||||||
|
|
||||||
pub fn from_raw(raw: u32) -> Self {
|
pub fn from_raw(raw: u32) -> Self {
|
||||||
Self(raw)
|
Self(raw)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,6 +350,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn memory(&self) -> &T {
|
pub fn memory(&self) -> &T {
|
||||||
&self.memory
|
&self.memory
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ impl OutputHandler {
|
||||||
ae.triggered().await;
|
ae.triggered().await;
|
||||||
}
|
}
|
||||||
self.state.outputs.remove(&self.output.id());
|
self.state.outputs.remove(&self.output.id());
|
||||||
self.state.globals.remove(&self.state, name).await;
|
let _ = self.state.globals.remove(&self.state, name).await;
|
||||||
self.state
|
self.state
|
||||||
.output_handlers
|
.output_handlers
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
@ -131,7 +131,7 @@ impl SeatHandler {
|
||||||
}
|
}
|
||||||
ae.triggered().await;
|
ae.triggered().await;
|
||||||
}
|
}
|
||||||
self.state.globals.remove(&self.state, name).await;
|
let _ = self.state.globals.remove(&self.state, name).await;
|
||||||
self.state
|
self.state
|
||||||
.seat_handlers
|
.seat_handlers
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::backend::{Output, OutputId};
|
use crate::backend::{Output, OutputId};
|
||||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
|
||||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||||
use crate::utils::copyhashmap::CopyHashMap;
|
use crate::utils::copyhashmap::CopyHashMap;
|
||||||
use crate::utils::linkedlist::{LinkedList, Node as LinkedNode};
|
use crate::utils::linkedlist::{LinkedList, Node as LinkedNode};
|
||||||
|
|
@ -47,12 +46,6 @@ pub enum NodeKind {
|
||||||
Container(Rc<ContainerNode>),
|
Container(Rc<ContainerNode>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NodeKind {
|
|
||||||
pub async fn leave(&self, seat: &WlSeatGlobal) {}
|
|
||||||
|
|
||||||
pub async fn enter(&self, seat: &WlSeatGlobal) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
||||||
pub struct NodeExtents {
|
pub struct NodeExtents {
|
||||||
pub x: i32,
|
pub x: i32,
|
||||||
|
|
@ -195,6 +188,7 @@ impl Node for ToplevelNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum ContainerSplit {
|
pub enum ContainerSplit {
|
||||||
Horizontal,
|
Horizontal,
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
||||||
self.int().map(|i| GlobalName::from_raw(i as u32))
|
self.int().map(|i| GlobalName::from_raw(i as u32))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn fixed(&mut self) -> Result<Fixed, MsgParserError> {
|
pub fn fixed(&mut self) -> Result<Fixed, MsgParserError> {
|
||||||
self.int().map(|i| Fixed(i))
|
self.int().map(|i| Fixed(i))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,6 @@ impl<K: Eq + Hash, V: Clone> CopyHashMap<K, V> {
|
||||||
self.map.borrow_mut().get(k).cloned()
|
self.map.borrow_mut().get(k).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_or_insert_default(&self, k: K) -> V
|
|
||||||
where
|
|
||||||
V: Default,
|
|
||||||
{
|
|
||||||
let mut map = self.map.borrow_mut();
|
|
||||||
map.entry(k).or_insert_with(|| Default::default()).clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn remove(&self, k: &K) -> Option<V> {
|
pub fn remove(&self, k: &K) -> Option<V> {
|
||||||
self.map.borrow_mut().remove(k)
|
self.map.borrow_mut().remove(k)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
use std::cell::{RefCell, RefMut};
|
|
||||||
use std::future::Future;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
use std::pin::Pin;
|
|
||||||
use std::task::{Context, Poll, Waker};
|
|
||||||
|
|
||||||
pub struct AsyncLock<T> {
|
|
||||||
data: RefCell<T>,
|
|
||||||
waiters: RefCell<Vec<Waker>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> AsyncLock<T> {
|
|
||||||
pub fn lock<'a>(&'a self) -> LockedFuture<'a, T> {
|
|
||||||
LockedFuture { lock: self }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct LockedFuture<'a, T> {
|
|
||||||
lock: &'a AsyncLock<T>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> Future for LockedFuture<'a, T> {
|
|
||||||
type Output = Locked<'a, T>;
|
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
|
||||||
if let Ok(data) = self.lock.data.try_borrow_mut() {
|
|
||||||
Poll::Ready(Locked {
|
|
||||||
data,
|
|
||||||
lock: self.lock,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
self.lock.waiters.borrow_mut().push(cx.waker().clone());
|
|
||||||
Poll::Pending
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Locked<'a, T> {
|
|
||||||
data: RefMut<'a, T>,
|
|
||||||
lock: &'a AsyncLock<T>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> Deref for Locked<'a, T> {
|
|
||||||
type Target = T;
|
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
self.data.deref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> DerefMut for Locked<'a, T> {
|
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
||||||
self.data.deref_mut()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> Drop for Locked<'a, T> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
for waiter in self.lock.waiters.borrow_mut().drain(..) {
|
|
||||||
waiter.wake();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,6 @@ pub mod asyncevent;
|
||||||
pub mod buffd;
|
pub mod buffd;
|
||||||
pub mod copyhashmap;
|
pub mod copyhashmap;
|
||||||
pub mod linkedlist;
|
pub mod linkedlist;
|
||||||
pub mod lock;
|
|
||||||
pub mod numcell;
|
pub mod numcell;
|
||||||
pub mod oneshot;
|
pub mod oneshot;
|
||||||
pub mod ptr_ext;
|
pub mod ptr_ext;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,5 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
cenum! {
|
|
||||||
XkbX11SetupXkbExtensionFlags, XKB_X11_SETUP_XKB_EXTENSION_FLAGS;
|
|
||||||
|
|
||||||
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS = 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
bitor!(XkbX11SetupXkbExtensionFlags);
|
|
||||||
|
|
||||||
cenum! {
|
cenum! {
|
||||||
XkbLogLevel, XKB_LOG_LEVEL;
|
XkbLogLevel, XKB_LOG_LEVEL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types, improper_ctypes)]
|
||||||
|
|
||||||
mod consts;
|
mod consts;
|
||||||
|
|
||||||
|
|
@ -11,21 +11,11 @@ use std::ops::Deref;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use crate::utils::ptr_ext::PtrExt;
|
use crate::utils::ptr_ext::PtrExt;
|
||||||
use libloading::Library;
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uapi::c;
|
use uapi::c;
|
||||||
use xcb_dl::ffi::xcb_connection_t;
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum XkbCommonError {
|
pub enum XkbCommonError {
|
||||||
#[error("xkbcommon-x11 could not be loaded")]
|
|
||||||
LoadXkbCommonX11(#[source] libloading::Error),
|
|
||||||
#[error("One of the xkbcommon-x11 symbols could not be loaded")]
|
|
||||||
LoadXkbCommonX11Sym(#[source] libloading::Error),
|
|
||||||
#[error("Could not create keymap from X11 device")]
|
|
||||||
CreateKeymapFromDevice,
|
|
||||||
#[error("Could not create state from X11 device")]
|
|
||||||
CreateStateFromDevice,
|
|
||||||
#[error("Could not create an xkbcommon context")]
|
#[error("Could not create an xkbcommon context")]
|
||||||
CreateContext,
|
CreateContext,
|
||||||
#[error("Could not create keymap from names")]
|
#[error("Could not create keymap from names")]
|
||||||
|
|
@ -81,10 +71,8 @@ extern "C" {
|
||||||
keymap: *mut xkb_keymap,
|
keymap: *mut xkb_keymap,
|
||||||
format: xkb_keymap_format,
|
format: xkb_keymap_format,
|
||||||
) -> *mut c::c_char;
|
) -> *mut c::c_char;
|
||||||
fn xkb_keymap_ref(keymap: *mut xkb_keymap) -> *mut xkb_keymap;
|
|
||||||
fn xkb_keymap_unref(keymap: *mut xkb_keymap);
|
fn xkb_keymap_unref(keymap: *mut xkb_keymap);
|
||||||
fn xkb_state_unref(state: *mut xkb_state);
|
fn xkb_state_unref(state: *mut xkb_state);
|
||||||
fn xkb_state_get_keymap(state: *mut xkb_state) -> *mut xkb_keymap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct XkbContext {
|
pub struct XkbContext {
|
||||||
|
|
@ -170,16 +158,6 @@ pub struct XkbState {
|
||||||
state: *mut xkb_state,
|
state: *mut xkb_state,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XkbState {
|
|
||||||
pub fn keymap(&self) -> XkbKeymap {
|
|
||||||
unsafe {
|
|
||||||
let res = xkb_state_get_keymap(self.state);
|
|
||||||
xkb_keymap_ref(res);
|
|
||||||
XkbKeymap { keymap: res }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for XkbState {
|
impl Drop for XkbState {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
@ -188,91 +166,6 @@ impl Drop for XkbState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct XkbCommonX11 {
|
|
||||||
library: Library,
|
|
||||||
fns: XkbCommonX11Fns,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct XkbCommonX11Fns {
|
|
||||||
xkb_x11_keymap_new_from_device: unsafe fn(
|
|
||||||
context: *mut xkb_context,
|
|
||||||
c: *mut xcb_connection_t,
|
|
||||||
device_id: i32,
|
|
||||||
flags: xkb_x11_setup_xkb_extension_flags,
|
|
||||||
) -> *mut xkb_keymap,
|
|
||||||
xkb_x11_state_new_from_device: unsafe fn(
|
|
||||||
keymap: *mut xkb_keymap,
|
|
||||||
c: *mut xcb_connection_t,
|
|
||||||
device_id: i32,
|
|
||||||
) -> *mut xkb_state,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl XkbCommonX11 {
|
|
||||||
pub fn load() -> Result<Self, XkbCommonError> {
|
|
||||||
let library = unsafe {
|
|
||||||
match Library::new("libxkbcommon-x11.so") {
|
|
||||||
Ok(l) => l,
|
|
||||||
Err(e) => return Err(XkbCommonError::LoadXkbCommonX11(e)),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let fns = match get_xkbcommon_x11_fns(&library) {
|
|
||||||
Ok(f) => f,
|
|
||||||
Err(e) => return Err(XkbCommonError::LoadXkbCommonX11Sym(e)),
|
|
||||||
};
|
|
||||||
Ok(Self { library, fns })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn keymap_from_device(
|
|
||||||
&self,
|
|
||||||
context: &XkbContext,
|
|
||||||
c: *mut xcb_connection_t,
|
|
||||||
device_id: i32,
|
|
||||||
flags: XkbX11SetupXkbExtensionFlags,
|
|
||||||
) -> Result<XkbKeymap, XkbCommonError> {
|
|
||||||
let res = (self.fns.xkb_x11_keymap_new_from_device)(
|
|
||||||
context.context,
|
|
||||||
c,
|
|
||||||
device_id,
|
|
||||||
flags.raw() as _,
|
|
||||||
);
|
|
||||||
if res.is_null() {
|
|
||||||
return Err(XkbCommonError::CreateKeymapFromDevice);
|
|
||||||
}
|
|
||||||
Ok(XkbKeymap { keymap: res })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn state_from_device(
|
|
||||||
&self,
|
|
||||||
keymap: &XkbKeymap,
|
|
||||||
c: *mut xcb_connection_t,
|
|
||||||
device_id: i32,
|
|
||||||
) -> Result<XkbState, XkbCommonError> {
|
|
||||||
let res = (self.fns.xkb_x11_state_new_from_device)(keymap.keymap, c, device_id);
|
|
||||||
if res.is_null() {
|
|
||||||
return Err(XkbCommonError::CreateStateFromDevice);
|
|
||||||
}
|
|
||||||
Ok(XkbState { state: res })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_xkbcommon_x11_fns(lib: &Library) -> Result<XkbCommonX11Fns, libloading::Error> {
|
|
||||||
macro_rules! syms {
|
|
||||||
($($sym:ident,)*) => {
|
|
||||||
Ok(XkbCommonX11Fns {
|
|
||||||
$(
|
|
||||||
$sym: std::mem::transmute(lib.get::<usize>(concat!(stringify!($sym), "\0").as_bytes())?.into_raw().into_raw()),
|
|
||||||
)*
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsafe {
|
|
||||||
syms! {
|
|
||||||
xkb_x11_keymap_new_from_device,
|
|
||||||
xkb_x11_state_new_from_device,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe extern "C" fn xkbcommon_logger(
|
unsafe extern "C" fn xkbcommon_logger(
|
||||||
_ctx: *mut xkb_context,
|
_ctx: *mut xkb_context,
|
||||||
level: xkb_log_level,
|
level: xkb_log_level,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue