autocommit 2022-01-08 19:02:10 CET
This commit is contained in:
parent
d061a5c313
commit
3336f1ab6a
37 changed files with 243 additions and 136 deletions
|
|
@ -12,7 +12,6 @@ panic = "abort"
|
|||
[dependencies]
|
||||
uapi = "0.2.4"
|
||||
thiserror = "1.0.30"
|
||||
anyhow = "1.0.52"
|
||||
ahash = "0.7.6"
|
||||
log = "0.4.14"
|
||||
env_logger = "0.9.0"
|
||||
|
|
|
|||
2
build.rs
2
build.rs
|
|
@ -33,7 +33,7 @@ fn get_target() -> repc::Target {
|
|||
repc::TARGET_MAP
|
||||
.iter()
|
||||
.cloned()
|
||||
.find(|t| t.0 == &rustc_target)
|
||||
.find(|t| t.0 == rustc_target)
|
||||
.unwrap()
|
||||
.1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ mod task {
|
|||
Poll::Pending
|
||||
} else if task.state & EMPTIED == 0 {
|
||||
task.state |= EMPTIED;
|
||||
Poll::Ready(ptr::read(&mut *task.data.result))
|
||||
Poll::Ready(ptr::read(&*task.data.result))
|
||||
} else {
|
||||
panic!("Future polled after it has already been emptied");
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ mod task {
|
|||
}
|
||||
let f = Box::into_raw(f);
|
||||
SpawnedFuture {
|
||||
vtable: &SpawnedFutureVTableProxy::<T, F>::VTABLE,
|
||||
vtable: SpawnedFutureVTableProxy::<T, F>::VTABLE,
|
||||
data: f as _,
|
||||
}
|
||||
}
|
||||
|
|
@ -365,7 +365,7 @@ mod task {
|
|||
unsafe fn run(&mut self) {
|
||||
if self.state & CANCELLED == 0 {
|
||||
self.inc_ref_count();
|
||||
let raw_waker = RawWaker::new(self as *const _ as _, &Self::VTABLE);
|
||||
let raw_waker = RawWaker::new(self as *const _ as _, Self::VTABLE);
|
||||
let waker = Waker::from_raw(raw_waker);
|
||||
|
||||
let mut ctx = Context::from_waker(&waker);
|
||||
|
|
|
|||
|
|
@ -706,7 +706,9 @@ impl XorgBackend {
|
|||
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)));
|
||||
client.fatal_event(
|
||||
d.implementation_error(format!("Could not access memory: {:#}", e)),
|
||||
);
|
||||
} else {
|
||||
self.state.clients.kill(client.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ use crate::client::objects::Objects;
|
|||
use crate::ifs::wl_buffer::{WlBuffer, WlBufferError, WlBufferId};
|
||||
use crate::ifs::wl_callback::WlCallback;
|
||||
use crate::ifs::wl_compositor::{WlCompositorError, WlCompositorObj};
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceError};
|
||||
use crate::ifs::wl_data_device_manager::{WlDataDeviceManagerError, WlDataDeviceManagerObj};
|
||||
use crate::ifs::wl_data_offer::{WlDataOffer, WlDataOfferError};
|
||||
use crate::ifs::wl_data_source::{WlDataSource, WlDataSourceError};
|
||||
use crate::ifs::wl_display::{WlDisplay, WlDisplayError};
|
||||
use crate::ifs::wl_output::{WlOutputError, WlOutputObj};
|
||||
use crate::ifs::wl_region::{WlRegion, WlRegionError, WlRegionId};
|
||||
|
|
@ -27,8 +31,8 @@ use crate::utils::buffd::{BufFdError, MsgFormatter, MsgParser, MsgParserError};
|
|||
use crate::utils::numcell::NumCell;
|
||||
use crate::utils::oneshot::{oneshot, OneshotTx};
|
||||
use crate::utils::queue::AsyncQueue;
|
||||
use crate::ErrorFmt;
|
||||
use ahash::AHashMap;
|
||||
use anyhow::anyhow;
|
||||
use std::cell::{Cell, RefCell, RefMut};
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::future::Future;
|
||||
|
|
@ -36,10 +40,6 @@ use std::mem;
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, OwnedFd};
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceError};
|
||||
use crate::ifs::wl_data_device_manager::{WlDataDeviceManagerError, WlDataDeviceManagerObj};
|
||||
use crate::ifs::wl_data_offer::{WlDataOffer, WlDataOfferError};
|
||||
use crate::ifs::wl_data_source::{WlDataSourceError, WlDataSource};
|
||||
|
||||
mod objects;
|
||||
mod tasks;
|
||||
|
|
@ -161,17 +161,18 @@ efrom!(ClientError, WlSeatError, WlSeatError);
|
|||
efrom!(ClientError, WlTouchError, WlTouchError);
|
||||
efrom!(ClientError, WlPointerError, WlPointerError);
|
||||
efrom!(ClientError, WlKeyboardError, WlKeyboardError);
|
||||
efrom!(ClientError, WlDataDeviceManagerError, WlDataDeviceManagerError);
|
||||
efrom!(
|
||||
ClientError,
|
||||
WlDataDeviceManagerError,
|
||||
WlDataDeviceManagerError
|
||||
);
|
||||
efrom!(ClientError, WlDataDeviceError, WlDataDeviceError);
|
||||
efrom!(ClientError, WlDataSourceError, WlDataSourceError);
|
||||
efrom!(ClientError, WlDataOfferError, WlDataOfferError);
|
||||
|
||||
impl ClientError {
|
||||
fn peer_closed(&self) -> bool {
|
||||
match self {
|
||||
ClientError::Io(BufFdError::Closed) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, ClientError::Io(BufFdError::Closed))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -354,9 +355,9 @@ impl Client {
|
|||
Ok(d) => self.fatal_event(d.invalid_request(obj, request)),
|
||||
Err(e) => {
|
||||
log::error!(
|
||||
"Could not retrieve display of client {}: {:#}",
|
||||
"Could not retrieve display of client {}: {}",
|
||||
self.id,
|
||||
anyhow!(e)
|
||||
ErrorFmt(e),
|
||||
);
|
||||
self.state.clients.kill(self.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::object::ObjectId;
|
|||
use crate::utils::buffd::{BufFdIn, BufFdOut, MsgFormatter, MsgParser};
|
||||
use crate::utils::oneshot::OneshotRx;
|
||||
use crate::utils::vec_ext::VecExt;
|
||||
use anyhow::anyhow;
|
||||
use crate::ErrorFmt;
|
||||
use futures::{select, FutureExt};
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -28,7 +28,7 @@ pub async fn client(data: Rc<Client>, shutdown: OneshotRx<()>) {
|
|||
log::error!("Could not shut down client {} within 5 seconds", data.id.0);
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Could not create a timeout: {:#}", anyhow!(e));
|
||||
log::error!("Could not create a timeout: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
data.state.clients.kill(data.id);
|
||||
|
|
@ -39,11 +39,11 @@ async fn dispatch_fr(data: Rc<Client>) {
|
|||
let mut fr = data.dispatch_frame_requests.pop().await;
|
||||
loop {
|
||||
if let Err(e) = data.event(fr.done()).await {
|
||||
log::error!("Could not dispatch frame event: {:#}", anyhow!(e));
|
||||
log::error!("Could not dispatch frame event: {}", ErrorFmt(e));
|
||||
return;
|
||||
}
|
||||
if let Err(e) = data.remove_obj(&*fr).await {
|
||||
log::error!("Could not remove frame object: {:#}", anyhow!(e));
|
||||
log::error!("Could not remove frame object: {}", ErrorFmt(e));
|
||||
return;
|
||||
}
|
||||
fr = match data.dispatch_frame_requests.try_pop() {
|
||||
|
|
@ -52,7 +52,7 @@ async fn dispatch_fr(data: Rc<Client>) {
|
|||
};
|
||||
}
|
||||
if let Err(e) = data.event2(WlEvent::Flush).await {
|
||||
log::error!("Could not dispatch frame event: {:#}", anyhow!(e));
|
||||
log::error!("Could not dispatch frame event: {}", ErrorFmt(e));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -109,14 +109,14 @@ async fn receive(data: Rc<Client>) {
|
|||
log::info!("Client {} terminated the connection", data.id.0);
|
||||
data.state.clients.kill(data.id);
|
||||
} else {
|
||||
let e = anyhow!(e);
|
||||
let e = ErrorFmt(e);
|
||||
log::error!(
|
||||
"An error occurred while trying to handle a message from client {}: {:#}",
|
||||
"An error occurred while trying to handle a message from client {}: {}",
|
||||
data.id.0,
|
||||
e
|
||||
);
|
||||
if !data.shutdown_sent.get() {
|
||||
data.fatal_event(display.implementation_error(format!("{:#}", e)));
|
||||
data.fatal_event(display.implementation_error(e.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::pixman::PixmanMemory;
|
||||
use std::cell::{Cell, UnsafeCell};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{compiler_fence, Ordering};
|
||||
use std::{mem, ptr};
|
||||
use thiserror::Error;
|
||||
use uapi::c;
|
||||
use uapi::c::raise;
|
||||
|
|
@ -156,7 +156,7 @@ pub fn init() -> Result<(), ClientMemError> {
|
|||
unsafe {
|
||||
let mut action: c::sigaction = MaybeUninit::zeroed().assume_init();
|
||||
action.sa_sigaction =
|
||||
mem::transmute(sigbus as unsafe extern "C" fn(i32, &c::siginfo_t, *mut c::c_void));
|
||||
sigbus as unsafe extern "C" fn(i32, &c::siginfo_t, *mut c::c_void) as _;
|
||||
action.sa_flags = c::SA_NODEFER | c::SA_SIGINFO;
|
||||
let res = c::sigaction(c::SIGBUS, &action, ptr::null_mut());
|
||||
match uapi::map_err!(res) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::client::{Client, ClientError, DynEventFormatter, WlEvent};
|
||||
use crate::ifs::wl_compositor::WlCompositorError;
|
||||
use crate::ifs::wl_data_device_manager::WlDataDeviceManagerError;
|
||||
use crate::ifs::wl_output::{WlOutputError, WlOutputGlobal};
|
||||
use crate::ifs::wl_registry::WlRegistry;
|
||||
use crate::ifs::wl_seat::{WlSeatError, WlSeatGlobal};
|
||||
|
|
@ -8,14 +9,16 @@ use crate::ifs::wl_subcompositor::WlSubcompositorError;
|
|||
use crate::ifs::xdg_wm_base::XdgWmBaseError;
|
||||
use crate::object::{Interface, ObjectId};
|
||||
use crate::utils::copyhashmap::CopyHashMap;
|
||||
use crate::{NumCell, State, WlCompositorGlobal, WlDataDeviceManagerGlobal, WlShmGlobal, WlSubcompositorGlobal, XdgWmBaseGlobal};
|
||||
use crate::{
|
||||
NumCell, State, WlCompositorGlobal, WlDataDeviceManagerGlobal, WlShmGlobal,
|
||||
WlSubcompositorGlobal, XdgWmBaseGlobal,
|
||||
};
|
||||
use ahash::AHashSet;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::wl_data_device_manager::WlDataDeviceManagerError;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GlobalError {
|
||||
|
|
@ -47,7 +50,11 @@ efrom!(GlobalError, WlSubcompositorError, WlSubcompositorError);
|
|||
efrom!(GlobalError, XdgWmBaseError, XdgWmBaseError);
|
||||
efrom!(GlobalError, WlOutputError, WlOutputError);
|
||||
efrom!(GlobalError, WlSeatError, WlSeatError);
|
||||
efrom!(GlobalError, WlDataDeviceManagerError, WlDataDeviceManagerError);
|
||||
efrom!(
|
||||
GlobalError,
|
||||
WlDataDeviceManagerError,
|
||||
WlDataDeviceManagerError
|
||||
);
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct GlobalName(u32);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ pub mod wl_callback;
|
|||
pub mod wl_compositor;
|
||||
pub mod wl_data_device;
|
||||
pub mod wl_data_device_manager;
|
||||
pub mod wl_data_offer;
|
||||
pub mod wl_data_source;
|
||||
pub mod wl_display;
|
||||
pub mod wl_output;
|
||||
|
|
@ -15,4 +16,3 @@ pub mod wl_subcompositor;
|
|||
pub mod wl_surface;
|
||||
pub mod xdg_positioner;
|
||||
pub mod xdg_wm_base;
|
||||
pub mod wl_data_offer;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ pub struct WlBuffer {
|
|||
}
|
||||
|
||||
impl WlBuffer {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
id: WlBufferId,
|
||||
client: &Rc<Client>,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ const MOTION: u32 = 4;
|
|||
const DROP: u32 = 5;
|
||||
const SELECTION: u32 = 5;
|
||||
|
||||
#[allow(dead_code)] const ROLE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
||||
id!(WlDataDeviceId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, DATA_OFFER, DROP, ENTER, LEAVE, MOTION, SELECTION};
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
use crate::ifs::wl_data_source::WlDataSourceId;
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::Object;
|
||||
|
|
@ -8,7 +9,6 @@ use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
|||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataDeviceError {
|
||||
|
|
|
|||
|
|
@ -2,20 +2,24 @@ mod types;
|
|||
|
||||
use crate::client::{AddObj, Client};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_source::WlDataSource;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_source::WlDataSource;
|
||||
|
||||
const CREATE_DATA_SOURCE: u32 = 0;
|
||||
const GET_DATA_DEVICE: u32 = 1;
|
||||
|
||||
#[allow(dead_code)] const DND_NONE: u32 = 0;
|
||||
#[allow(dead_code)] const DND_COPY: u32 = 1;
|
||||
#[allow(dead_code)] const DND_MOVE: u32 = 2;
|
||||
#[allow(dead_code)] const DND_ASK: u32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const DND_NONE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const DND_COPY: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const DND_MOVE: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const DND_ASK: u32 = 4;
|
||||
|
||||
id!(WlDataDeviceManagerId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::ifs::wl_data_device::WlDataDeviceId;
|
||||
use crate::ifs::wl_data_source::WlDataSourceId;
|
||||
use crate::ifs::wl_seat::WlSeatId;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
use crate::ifs::wl_data_device::WlDataDeviceId;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataDeviceManagerError {
|
||||
|
|
|
|||
|
|
@ -16,10 +16,14 @@ const OFFER: u32 = 0;
|
|||
const SOURCE_ACTIONS: u32 = 1;
|
||||
const ACTION: u32 = 2;
|
||||
|
||||
#[allow(dead_code)] const INVALID_FINISH: u32 = 0;
|
||||
#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 1;
|
||||
#[allow(dead_code)] const INVALID_ACTION: u32 = 2;
|
||||
#[allow(dead_code)] const INVALID_OFFER: u32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_FINISH: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_ACTION_MASK: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_ACTION: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_OFFER: u32 = 3;
|
||||
|
||||
id!(WlDataOfferId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_data_offer::{WlDataOffer, ACTION, OFFER, SOURCE_ACTIONS};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use bstr::{BStr, BString};
|
||||
|
|
@ -6,7 +7,6 @@ use std::fmt::{Debug, Formatter};
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::ifs::wl_data_offer::{ACTION, OFFER, SOURCE_ACTIONS, WlDataOffer};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataOfferError {
|
||||
|
|
@ -89,7 +89,11 @@ impl<'a> RequestParser<'a> for Accept<'a> {
|
|||
}
|
||||
impl Debug for Accept<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "accept(serial: {}, mime_type: {:?})", self.serial, self.mime_type)
|
||||
write!(
|
||||
f,
|
||||
"accept(serial: {}, mime_type: {:?})",
|
||||
self.serial, self.mime_type
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +111,12 @@ impl<'a> RequestParser<'a> for Receive<'a> {
|
|||
}
|
||||
impl Debug for Receive<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "receive(mime_type: {:?}, fd: {})", self.mime_type, self.fd.raw())
|
||||
write!(
|
||||
f,
|
||||
"receive(mime_type: {:?}, fd: {})",
|
||||
self.mime_type,
|
||||
self.fd.raw()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +158,11 @@ impl<'a> RequestParser<'a> for SetActions {
|
|||
}
|
||||
impl Debug for SetActions {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_actions(dnd_actions: {}, preferred_action: {})", self.dnd_actions, self.preferred_action)
|
||||
write!(
|
||||
f,
|
||||
"set_actions(dnd_actions: {}, preferred_action: {})",
|
||||
self.dnd_actions, self.preferred_action
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,11 +199,7 @@ impl EventFormatter for SourceActions {
|
|||
}
|
||||
impl Debug for SourceActions {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"source_actions(source_actions: {})",
|
||||
self.source_actions,
|
||||
)
|
||||
write!(f, "source_actions(source_actions: {})", self.source_actions,)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,8 +209,7 @@ pub(super) struct Action {
|
|||
}
|
||||
impl EventFormatter for Action {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, ACTION)
|
||||
.uint(self.dnd_action);
|
||||
fmt.header(self.obj.id, ACTION).uint(self.dnd_action);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
|
|
@ -209,10 +217,6 @@ impl EventFormatter for Action {
|
|||
}
|
||||
impl Debug for Action {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"action(dnd_action: {})",
|
||||
self.dnd_action,
|
||||
)
|
||||
write!(f, "action(dnd_action: {})", self.dnd_action,)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@ const DND_DROP_PERFORMED: u32 = 4;
|
|||
const DND_FINISHED: u32 = 5;
|
||||
const ACTION: u32 = 5;
|
||||
|
||||
#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 0;
|
||||
#[allow(dead_code)] const INVALID_SOURCE: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_ACTION_MASK: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_SOURCE: u32 = 1;
|
||||
|
||||
id!(WlDataSourceId);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ const DELETE_ID: u32 = 1;
|
|||
|
||||
const INVALID_OBJECT: u32 = 0;
|
||||
const INVALID_METHOD: u32 = 1;
|
||||
#[allow(dead_code)] const NO_MEMORY: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const NO_MEMORY: u32 = 2;
|
||||
const IMPLEMENTATION: u32 = 3;
|
||||
|
||||
pub struct WlDisplay {
|
||||
|
|
@ -45,7 +46,7 @@ impl WlDisplay {
|
|||
|
||||
async fn sync(&self, parser: MsgParser<'_, '_>) -> Result<(), SyncError> {
|
||||
let sync: Sync = self.client.parse(self, parser)?;
|
||||
let cb = Rc::new(WlCallback::new(sync.callback.into()));
|
||||
let cb = Rc::new(WlCallback::new(sync.callback));
|
||||
self.client.add_client_obj(&cb)?;
|
||||
self.client.event(cb.done()).await?;
|
||||
self.client.remove_obj(&*cb).await?;
|
||||
|
|
|
|||
|
|
@ -22,23 +22,36 @@ const DONE: u32 = 2;
|
|||
const SCALE: u32 = 3;
|
||||
|
||||
const SP_UNKNOWN: i32 = 0;
|
||||
#[allow(dead_code)] const SP_NONE: i32 = 1;
|
||||
#[allow(dead_code)] const SP_HORIZONTAL_RGB: i32 = 2;
|
||||
#[allow(dead_code)] const SP_HORIZONTAL_BGR: i32 = 3;
|
||||
#[allow(dead_code)] const SP_VERTICAL_RGB: i32 = 4;
|
||||
#[allow(dead_code)] const SP_VERTICAL_BGR: i32 = 5;
|
||||
#[allow(dead_code)]
|
||||
const SP_NONE: i32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const SP_HORIZONTAL_RGB: i32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const SP_HORIZONTAL_BGR: i32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const SP_VERTICAL_RGB: i32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const SP_VERTICAL_BGR: i32 = 5;
|
||||
|
||||
const TF_NORMAL: i32 = 0;
|
||||
#[allow(dead_code)] const TF_90: i32 = 1;
|
||||
#[allow(dead_code)] const TF_180: i32 = 2;
|
||||
#[allow(dead_code)] const TF_270: i32 = 3;
|
||||
#[allow(dead_code)] const TF_FLIPPED: i32 = 4;
|
||||
#[allow(dead_code)] const TF_FLIPPED_90: i32 = 5;
|
||||
#[allow(dead_code)] const TF_FLIPPED_180: i32 = 6;
|
||||
#[allow(dead_code)] const TF_FLIPPED_270: i32 = 7;
|
||||
#[allow(dead_code)]
|
||||
const TF_90: i32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const TF_180: i32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const TF_270: i32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const TF_FLIPPED: i32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const TF_FLIPPED_90: i32 = 5;
|
||||
#[allow(dead_code)]
|
||||
const TF_FLIPPED_180: i32 = 6;
|
||||
#[allow(dead_code)]
|
||||
const TF_FLIPPED_270: i32 = 7;
|
||||
|
||||
const MODE_CURRENT: u32 = 1;
|
||||
#[allow(dead_code)] const MODE_PREFERRED: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const MODE_PREFERRED: u32 = 2;
|
||||
|
||||
pub struct WlOutputGlobal {
|
||||
name: GlobalName,
|
||||
|
|
|
|||
|
|
@ -36,9 +36,11 @@ const NAME: u32 = 1;
|
|||
|
||||
const POINTER: u32 = 1;
|
||||
const KEYBOARD: u32 = 2;
|
||||
#[allow(dead_code)] const TOUCH: u32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const TOUCH: u32 = 4;
|
||||
|
||||
#[allow(dead_code)] const MISSING_CAPABILITY: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const MISSING_CAPABILITY: u32 = 0;
|
||||
|
||||
pub struct WlSeatGlobal {
|
||||
name: GlobalName,
|
||||
|
|
@ -178,10 +180,10 @@ impl WlSeatGlobal {
|
|||
x += Fixed::from_int(ee.x1);
|
||||
y += Fixed::from_int(ee.y1);
|
||||
if enter {
|
||||
self.tl_pointer_event(&tl, |p| p.enter(0, tl.surface.surface.surface.id, x, y))
|
||||
self.tl_pointer_event(tl, |p| p.enter(0, tl.surface.surface.surface.id, x, y))
|
||||
.await;
|
||||
}
|
||||
self.tl_pointer_event(&tl, |p| p.motion(0, x, y)).await;
|
||||
self.tl_pointer_event(tl, |p| p.motion(0, x, y)).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,9 +239,7 @@ impl WlSeatGlobal {
|
|||
client.event(obj.capabilities()).await?;
|
||||
{
|
||||
let mut bindings = self.bindings.borrow_mut();
|
||||
let bindings = bindings
|
||||
.entry(client.id)
|
||||
.or_insert_with(|| Default::default());
|
||||
let bindings = bindings.entry(client.id).or_insert_with(Default::default);
|
||||
bindings.insert(id, obj.clone());
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -18,11 +18,14 @@ const KEY: u32 = 3;
|
|||
const MODIFIERS: u32 = 4;
|
||||
const REPEAT_INFO: u32 = 5;
|
||||
|
||||
#[allow(dead_code)] const NO_KEYMAP: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const NO_KEYMAP: u32 = 0;
|
||||
pub(super) const XKB_V1: u32 = 1;
|
||||
|
||||
#[allow(dead_code)] const RELEASED: u32 = 0;
|
||||
#[allow(dead_code)] const PRESSED: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const RELEASED: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const PRESSED: u32 = 1;
|
||||
|
||||
id!(WlKeyboardId);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ const AXIS_SOURCE: u32 = 6;
|
|||
const AXIS_STOP: u32 = 7;
|
||||
const AXIS_DISCRETE: u32 = 8;
|
||||
|
||||
#[allow(dead_code)] const ROLE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
||||
pub(super) const RELEASED: u32 = 0;
|
||||
pub(super) const PRESSED: u32 = 1;
|
||||
|
|
@ -30,10 +31,14 @@ pub(super) const PRESSED: u32 = 1;
|
|||
pub(super) const VERTICAL_SCROLL: u32 = 0;
|
||||
pub(super) const HORIZONTAL_SCROLL: u32 = 1;
|
||||
|
||||
#[allow(dead_code)] const WHEEL: u32 = 0;
|
||||
#[allow(dead_code)] const FINGER: u32 = 1;
|
||||
#[allow(dead_code)] const CONTINUOUS: u32 = 2;
|
||||
#[allow(dead_code)] const WHEEL_TILT: u32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const WHEEL: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const FINGER: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const CONTINUOUS: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const WHEEL_TILT: u32 = 3;
|
||||
|
||||
id!(WlPointerId);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,20 @@ pub use types::*;
|
|||
|
||||
const RELEASE: u32 = 0;
|
||||
|
||||
#[allow(dead_code)] const DOWN: u32 = 0;
|
||||
#[allow(dead_code)] const UP: u32 = 1;
|
||||
#[allow(dead_code)] const MOTION: u32 = 2;
|
||||
#[allow(dead_code)] const FRAME: u32 = 3;
|
||||
#[allow(dead_code)] const CANCEL: u32 = 4;
|
||||
#[allow(dead_code)] const SHAPE: u32 = 5;
|
||||
#[allow(dead_code)] const ORIENTATION: u32 = 6;
|
||||
#[allow(dead_code)]
|
||||
const DOWN: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const UP: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const MOTION: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const FRAME: u32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const CANCEL: u32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const SHAPE: u32 = 5;
|
||||
#[allow(dead_code)]
|
||||
const ORIENTATION: u32 = 6;
|
||||
|
||||
id!(WlTouchId);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ pub use types::*;
|
|||
const DESTROY: u32 = 0;
|
||||
const GET_SUBSURFACE: u32 = 1;
|
||||
|
||||
#[allow(dead_code)] const BAD_SURFACE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const BAD_SURFACE: u32 = 0;
|
||||
|
||||
id!(WlSubcompositorId);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,12 +33,17 @@ const SET_BUFFER_TRANSFORM: u32 = 7;
|
|||
const SET_BUFFER_SCALE: u32 = 8;
|
||||
const DAMAGE_BUFFER: u32 = 9;
|
||||
|
||||
#[allow(dead_code)] const ENTER: u32 = 0;
|
||||
#[allow(dead_code)] const LEAVE: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const ENTER: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const LEAVE: u32 = 1;
|
||||
|
||||
#[allow(dead_code)] const INVALID_SCALE: u32 = 0;
|
||||
#[allow(dead_code)] const INVALID_TRANSFORM: u32 = 1;
|
||||
#[allow(dead_code)] const INVALID_SIZE: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_SCALE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_TRANSFORM: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_SIZE: u32 = 2;
|
||||
|
||||
id!(WlSurfaceId);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ const PLACE_BELOW: u32 = 3;
|
|||
const SET_SYNC: u32 = 4;
|
||||
const SET_DESYNC: u32 = 5;
|
||||
|
||||
#[allow(dead_code)] const BAD_SURFACE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const BAD_SURFACE: u32 = 0;
|
||||
|
||||
const MAX_SUBSURFACE_DEPTH: u32 = 100;
|
||||
|
||||
|
|
@ -108,7 +109,7 @@ impl WlSubsurface {
|
|||
}
|
||||
let node = {
|
||||
let mut data = self.parent.children.borrow_mut();
|
||||
let data = data.get_or_insert_with(|| Default::default());
|
||||
let data = data.get_or_insert_with(Default::default);
|
||||
data.subsurfaces
|
||||
.insert(self.surface.id, self.surface.clone());
|
||||
data.above.add_first(StackElement {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,11 @@ const ACK_CONFIGURE: u32 = 4;
|
|||
|
||||
const CONFIGURE: u32 = 0;
|
||||
|
||||
#[allow(dead_code)] const NOT_CONSTRUCTED: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const NOT_CONSTRUCTED: u32 = 1;
|
||||
const ALREADY_CONSTRUCTED: u32 = 2;
|
||||
#[allow(dead_code)] const UNCONFIGURED_BUFFER: u32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const UNCONFIGURED_BUFFER: u32 = 3;
|
||||
|
||||
id!(XdgSurfaceId);
|
||||
|
||||
|
|
@ -37,11 +39,7 @@ pub struct XdgSurface {
|
|||
}
|
||||
|
||||
impl XdgSurface {
|
||||
pub fn new(
|
||||
wm_base: &Rc<XdgWmBaseObj>,
|
||||
id: XdgSurfaceId,
|
||||
surface: &Rc<WlSurface>,
|
||||
) -> Self {
|
||||
pub fn new(wm_base: &Rc<XdgWmBaseObj>, id: XdgSurfaceId, surface: &Rc<WlSurface>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
base: wm_base.clone(),
|
||||
|
|
@ -167,7 +165,10 @@ impl XdgSurface {
|
|||
xdg.popups.set(self.surface.id, popup.clone());
|
||||
}
|
||||
}
|
||||
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { _popup: popup, parent });
|
||||
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData {
|
||||
_popup: popup,
|
||||
parent,
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ const CONFIGURE: u32 = 0;
|
|||
const POPUP_DONE: u32 = 1;
|
||||
const REPOSITIONED: u32 = 2;
|
||||
|
||||
#[allow(dead_code)] const INVALID_GRAB: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_GRAB: u32 = 1;
|
||||
|
||||
id!(XdgPopupId);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,14 +40,22 @@ pub enum ResizeEdge {
|
|||
BottomRight = 10,
|
||||
}
|
||||
|
||||
#[allow(dead_code)] const STATE_MAXIMIZED: u32 = 1;
|
||||
#[allow(dead_code)] const STATE_FULLSCREEN: u32 = 2;
|
||||
#[allow(dead_code)] const STATE_RESIZING: u32 = 3;
|
||||
#[allow(dead_code)] const STATE_ACTIVATED: u32 = 4;
|
||||
#[allow(dead_code)] const STATE_TILED_LEFT: u32 = 5;
|
||||
#[allow(dead_code)] const STATE_TILED_RIGHT: u32 = 6;
|
||||
#[allow(dead_code)] const STATE_TILED_TOP: u32 = 7;
|
||||
#[allow(dead_code)] const STATE_TILED_BOTTOM: u32 = 8;
|
||||
#[allow(dead_code)]
|
||||
const STATE_MAXIMIZED: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const STATE_FULLSCREEN: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const STATE_RESIZING: u32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const STATE_ACTIVATED: u32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const STATE_TILED_LEFT: u32 = 5;
|
||||
#[allow(dead_code)]
|
||||
const STATE_TILED_RIGHT: u32 = 6;
|
||||
#[allow(dead_code)]
|
||||
const STATE_TILED_TOP: u32 = 7;
|
||||
#[allow(dead_code)]
|
||||
const STATE_TILED_BOTTOM: u32 = 8;
|
||||
|
||||
id!(XdgToplevelId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{AddObj, Client};
|
||||
use crate::ifs::xdg_wm_base::XdgWmBaseObj;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use bitflags::bitflags;
|
||||
|
|
@ -9,7 +10,6 @@ use num_traits::FromPrimitive;
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::ifs::xdg_wm_base::XdgWmBaseObj;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const SET_SIZE: u32 = 1;
|
||||
|
|
|
|||
|
|
@ -17,12 +17,17 @@ const PONG: u32 = 3;
|
|||
|
||||
const PING: u32 = 0;
|
||||
|
||||
#[allow(dead_code)] const ROLE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
const DEFUNCT_SURFACES: u32 = 1;
|
||||
#[allow(dead_code)] const NOT_THE_TOPMOST_POPUP: u32 = 2;
|
||||
#[allow(dead_code)] const INVALID_POPUP_PARENT: u32 = 3;
|
||||
#[allow(dead_code)] const INVALID_SURFACE_STATE: u32 = 4;
|
||||
#[allow(dead_code)] const INVALID_POSITIONER: u32 = 5;
|
||||
#[allow(dead_code)]
|
||||
const NOT_THE_TOPMOST_POPUP: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_POPUP_PARENT: u32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_SURFACE_STATE: u32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_POSITIONER: u32 = 5;
|
||||
|
||||
id!(XdgWmBaseId);
|
||||
|
||||
|
|
|
|||
13
src/main.rs
13
src/main.rs
|
|
@ -4,6 +4,13 @@
|
|||
never_type,
|
||||
c_variadic
|
||||
)]
|
||||
#![allow(
|
||||
clippy::len_zero,
|
||||
clippy::needless_lifetimes,
|
||||
clippy::enum_variant_names,
|
||||
clippy::useless_format,
|
||||
clippy::redundant_clone
|
||||
)]
|
||||
|
||||
use crate::acceptor::AcceptorError;
|
||||
use crate::async_engine::AsyncError;
|
||||
|
|
@ -13,24 +20,24 @@ use crate::clientmem::ClientMemError;
|
|||
use crate::event_loop::EventLoopError;
|
||||
use crate::globals::{AddGlobal, Globals};
|
||||
use crate::ifs::wl_compositor::WlCompositorGlobal;
|
||||
use crate::ifs::wl_data_device_manager::WlDataDeviceManagerGlobal;
|
||||
use crate::ifs::wl_shm::WlShmGlobal;
|
||||
use crate::ifs::wl_subcompositor::WlSubcompositorGlobal;
|
||||
use crate::ifs::xdg_wm_base::XdgWmBaseGlobal;
|
||||
use crate::sighand::SighandError;
|
||||
use crate::state::State;
|
||||
use crate::tree::{DisplayNode, NodeIds};
|
||||
use crate::utils::errorfmt::ErrorFmt;
|
||||
use crate::utils::numcell::NumCell;
|
||||
use crate::utils::queue::AsyncQueue;
|
||||
use crate::wheel::WheelError;
|
||||
use acceptor::Acceptor;
|
||||
use anyhow::anyhow;
|
||||
use async_engine::AsyncEngine;
|
||||
use event_loop::EventLoop;
|
||||
use log::LevelFilter;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use wheel::Wheel;
|
||||
use crate::ifs::wl_data_device_manager::WlDataDeviceManagerGlobal;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
|
@ -62,7 +69,7 @@ fn main() {
|
|||
.filter_level(LevelFilter::Trace)
|
||||
.init();
|
||||
if let Err(e) = main_() {
|
||||
log::error!("A fatal error occurred: {:#}", anyhow!(e));
|
||||
log::error!("A fatal error occurred: {}", ErrorFmt(e));
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,6 +234,7 @@ where
|
|||
self.fill_rect(r, g, b, a, 0, 0, self.width as _, self.height as _)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn fill_rect(
|
||||
&self,
|
||||
r: u8,
|
||||
|
|
@ -260,6 +261,7 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn fill_insert_border(
|
||||
&self,
|
||||
r: u8,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
|||
|
||||
#[allow(dead_code)]
|
||||
pub fn fixed(&mut self) -> Result<Fixed, MsgParserError> {
|
||||
self.int().map(|i| Fixed(i))
|
||||
self.int().map(Fixed)
|
||||
}
|
||||
|
||||
pub fn string(&mut self) -> Result<&'b BStr, MsgParserError> {
|
||||
|
|
|
|||
21
src/utils/errorfmt.rs
Normal file
21
src/utils/errorfmt.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
pub struct ErrorFmt<E>(pub E);
|
||||
|
||||
impl<E: Error> Display for ErrorFmt<E> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let mut e_opt = Some(&self.0 as &dyn Error);
|
||||
let mut first = true;
|
||||
while let Some(e) = e_opt {
|
||||
if first {
|
||||
write!(f, "{}", e)?;
|
||||
first = false;
|
||||
} else {
|
||||
write!(f, ": {}", e)?;
|
||||
}
|
||||
e_opt = e.source();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
pub mod asyncevent;
|
||||
pub mod buffd;
|
||||
pub mod copyhashmap;
|
||||
pub mod errorfmt;
|
||||
pub mod linkedlist;
|
||||
pub mod numcell;
|
||||
pub mod oneshot;
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ impl Wheel {
|
|||
}
|
||||
let el_id = self.el.id();
|
||||
let pd = Rc::new(PeriodicDispatcher {
|
||||
fd: fd,
|
||||
fd,
|
||||
id: el_id,
|
||||
el: self.el.clone(),
|
||||
dispatcher,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue