xcon: move wire core into workspace crate
This commit is contained in:
parent
61ec13def0
commit
d8380b3dce
11 changed files with 138 additions and 99 deletions
14
Cargo.lock
generated
14
Cargo.lock
generated
|
|
@ -707,6 +707,7 @@ dependencies = [
|
|||
"jay-tracy",
|
||||
"jay-units",
|
||||
"jay-utils",
|
||||
"jay-xcon",
|
||||
"kbvm",
|
||||
"libloading",
|
||||
"linearize",
|
||||
|
|
@ -883,6 +884,19 @@ dependencies = [
|
|||
"uapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jay-xcon"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"jay-bufio",
|
||||
"jay-io-uring",
|
||||
"jay-utils",
|
||||
"log",
|
||||
"thiserror",
|
||||
"uapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.91"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ members = [
|
|||
"io-uring",
|
||||
"bufio",
|
||||
"dbus-core",
|
||||
"xcon",
|
||||
"toml-config",
|
||||
"algorithms",
|
||||
"toml-spec",
|
||||
|
|
@ -63,6 +64,7 @@ jay-async-engine = { version = "0.1.0", path = "async-engine" }
|
|||
jay-io-uring = { version = "0.1.0", path = "io-uring" }
|
||||
jay-bufio = { version = "0.1.0", path = "bufio" }
|
||||
jay-dbus-core = { version = "0.1.0", path = "dbus-core" }
|
||||
jay-xcon = { version = "0.1.0", path = "xcon" }
|
||||
|
||||
uapi = "0.2.13"
|
||||
thiserror = "2.0.11"
|
||||
|
|
|
|||
94
src/xcon.rs
94
src/xcon.rs
|
|
@ -1,21 +1,18 @@
|
|||
pub use crate::xcon::{
|
||||
formatter::Formatter,
|
||||
parser::Parser,
|
||||
wire_type::{Message, Request, XEvent},
|
||||
pub use jay_xcon::{
|
||||
consts, xauthority, Formatter, Message, Parser, Request, SendEvent, XEvent, XconError,
|
||||
};
|
||||
use {
|
||||
crate::{
|
||||
async_engine::{Phase, SpawnedFuture},
|
||||
compositor::DISPLAY,
|
||||
io_uring::IoUringError,
|
||||
state::State,
|
||||
utils::{
|
||||
buf::DynamicBuf,
|
||||
bufio::{BufIo, BufIoError, BufIoMessage},
|
||||
bufio::{BufIo, BufIoMessage},
|
||||
clonecell::CloneCell,
|
||||
errorfmt::ErrorFmt,
|
||||
numcell::NumCell,
|
||||
oserror::{OsError, OsErrorExt2},
|
||||
oserror::OsErrorExt2,
|
||||
queue::AsyncQueue,
|
||||
stack::Stack,
|
||||
vec_ext::VecExt,
|
||||
|
|
@ -29,7 +26,6 @@ use {
|
|||
consts::{IMAGE_FORMAT_Z_PIXMAP, RENDER_PICT_TYPE_DIRECT},
|
||||
incoming::handle_incoming,
|
||||
outgoing::handle_outgoing,
|
||||
wire_type::SendEvent,
|
||||
xauthority::{LOCAL, MIT_MAGIC_COOKIE, XAuthority},
|
||||
},
|
||||
},
|
||||
|
|
@ -49,93 +45,11 @@ use {
|
|||
rc::{Rc, Weak},
|
||||
task::{Context, Poll, Waker},
|
||||
},
|
||||
thiserror::Error,
|
||||
uapi::{OwnedFd, c},
|
||||
};
|
||||
|
||||
pub mod consts;
|
||||
mod formatter;
|
||||
mod incoming;
|
||||
mod outgoing;
|
||||
mod parser;
|
||||
mod wire_type;
|
||||
mod xauthority;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XconError {
|
||||
#[error("Unexpected EOF")]
|
||||
UnexpectedEof,
|
||||
#[error("Buffer slice is not properly aligned")]
|
||||
UnalignedSlice,
|
||||
#[error("Neither XAUTHORITY nor HOME is set")]
|
||||
HomeNotSet,
|
||||
#[error("Could not read Xauthority file")]
|
||||
ReadXAuthority(#[source] std::io::Error),
|
||||
#[error("Display field in Xauthority could not be parsed")]
|
||||
InvalidAuthorityDisplay,
|
||||
#[error("The DISPLAY is not set")]
|
||||
DisplayNotSet,
|
||||
#[error("DISPLAY contains an invalid value")]
|
||||
InvalidDisplayFormat,
|
||||
#[error("Could not create a unix socket")]
|
||||
CreateSocket(#[source] OsError),
|
||||
#[error("Could not connect to Xserver")]
|
||||
ConnectSocket(#[source] IoUringError),
|
||||
#[error("Could not retrive the hostname")]
|
||||
Hostname(#[source] OsError),
|
||||
#[error("Server did not send enough fds")]
|
||||
NotEnoughFds,
|
||||
#[error("Server rejected our connection attempt: {0}")]
|
||||
Connect(BString),
|
||||
#[error("Server requires additional authentication: {0}")]
|
||||
Authenticate(BString),
|
||||
#[error(transparent)]
|
||||
BufIoError(#[from] BufIoError),
|
||||
#[error("The server did not send a reply to a request")]
|
||||
MissingReply,
|
||||
#[error("The server did not send fds with a reply")]
|
||||
MissingFds,
|
||||
#[error("The server sent a message with an excessive size")]
|
||||
ExcessiveMessageSize,
|
||||
#[error(transparent)]
|
||||
XconError(Rc<XconError>),
|
||||
#[error("The server does not support the `{0}` extension")]
|
||||
ExtensionUnavailable(&'static str),
|
||||
#[error("The server returned error {0}")]
|
||||
CoreError(u8),
|
||||
#[error("The extension `{}` returned error {}", .0.name(), .1)]
|
||||
ExtensionError(Extension, u8),
|
||||
#[error("The connection to the server has already been closed")]
|
||||
Dead,
|
||||
#[error("Could not query the `{0}` extension")]
|
||||
QueryExtension(BString, #[source] Box<XconError>),
|
||||
#[error("All available xids have been used")]
|
||||
XidExhausted,
|
||||
#[error("Enum contains an unknown variant")]
|
||||
UnknownEnumVariant,
|
||||
#[error("Could not query the render pict formats")]
|
||||
QueryPictFormats(#[source] Box<XconError>),
|
||||
#[error("The server does not support the picture format for cursors")]
|
||||
CursorFormatNotSupported,
|
||||
#[error("Could not create a pixmap")]
|
||||
CreatePixmap(#[source] Box<XconError>),
|
||||
#[error("Could not create a graphics context")]
|
||||
CreateGc(#[source] Box<XconError>),
|
||||
#[error("Could not upload an image")]
|
||||
PutImage(#[source] Box<XconError>),
|
||||
#[error("Could not create a picture")]
|
||||
CreatePicture(#[source] Box<XconError>),
|
||||
#[error("Could not create a cursor")]
|
||||
CreateCursor(#[source] Box<XconError>),
|
||||
#[error("Property has an invalid type")]
|
||||
InvalidPropertyType,
|
||||
#[error("Property has an invalid format. Expected: {0}; Actual: {1}")]
|
||||
InvalidPropertyFormat(u8, u8),
|
||||
#[error("Length of the property data is not a multiple of its format")]
|
||||
IrregularPropertyLength,
|
||||
#[error("The property is not set")]
|
||||
PropertyUnavailable,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ExtensionIdRange {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ impl Incoming {
|
|||
break 'handle_error;
|
||||
};
|
||||
let e = match ext {
|
||||
Some(e) => XconError::ExtensionError(e, code),
|
||||
Some(e) => XconError::ExtensionError(e.name(), code),
|
||||
_ => XconError::CoreError(code),
|
||||
};
|
||||
if let Some(first) = reply_handlers.front()
|
||||
|
|
|
|||
15
xcon/Cargo.toml
Normal file
15
xcon/Cargo.toml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "jay-xcon"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "GPL-3.0-only"
|
||||
|
||||
[dependencies]
|
||||
jay-bufio = { version = "0.1.0", path = "../bufio" }
|
||||
jay-io-uring = { version = "0.1.0", path = "../io-uring" }
|
||||
jay-utils = { version = "0.1.0", path = "../utils" }
|
||||
|
||||
bstr = { version = "1.9.0", default-features = false, features = ["std"] }
|
||||
log = { version = "0.4.20", features = ["std"] }
|
||||
thiserror = "2.0.11"
|
||||
uapi = "0.2.13"
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
use {
|
||||
crate::{utils::buf::DynamicBuf, xcon::Message},
|
||||
crate::Message,
|
||||
jay_utils::buf::DynamicBuf,
|
||||
std::rc::Rc,
|
||||
uapi::{AssertPacked, OwnedFd, Packed},
|
||||
};
|
||||
95
xcon/src/lib.rs
Normal file
95
xcon/src/lib.rs
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
pub use {
|
||||
formatter::Formatter,
|
||||
parser::Parser,
|
||||
wire_type::{Message, Request, SendEvent, XEvent},
|
||||
};
|
||||
use {
|
||||
bstr::BString,
|
||||
jay_bufio::BufIoError,
|
||||
jay_io_uring::IoUringError,
|
||||
jay_utils::oserror::OsError,
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub mod consts;
|
||||
mod formatter;
|
||||
mod parser;
|
||||
mod wire_type;
|
||||
pub mod xauthority;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XconError {
|
||||
#[error("Unexpected EOF")]
|
||||
UnexpectedEof,
|
||||
#[error("Buffer slice is not properly aligned")]
|
||||
UnalignedSlice,
|
||||
#[error("Neither XAUTHORITY nor HOME is set")]
|
||||
HomeNotSet,
|
||||
#[error("Could not read Xauthority file")]
|
||||
ReadXAuthority(#[source] std::io::Error),
|
||||
#[error("Display field in Xauthority could not be parsed")]
|
||||
InvalidAuthorityDisplay,
|
||||
#[error("The DISPLAY is not set")]
|
||||
DisplayNotSet,
|
||||
#[error("DISPLAY contains an invalid value")]
|
||||
InvalidDisplayFormat,
|
||||
#[error("Could not create a unix socket")]
|
||||
CreateSocket(#[source] OsError),
|
||||
#[error("Could not connect to Xserver")]
|
||||
ConnectSocket(#[source] IoUringError),
|
||||
#[error("Could not retrive the hostname")]
|
||||
Hostname(#[source] OsError),
|
||||
#[error("Server did not send enough fds")]
|
||||
NotEnoughFds,
|
||||
#[error("Server rejected our connection attempt: {0}")]
|
||||
Connect(BString),
|
||||
#[error("Server requires additional authentication: {0}")]
|
||||
Authenticate(BString),
|
||||
#[error(transparent)]
|
||||
BufIoError(#[from] BufIoError),
|
||||
#[error("The server did not send a reply to a request")]
|
||||
MissingReply,
|
||||
#[error("The server did not send fds with a reply")]
|
||||
MissingFds,
|
||||
#[error("The server sent a message with an excessive size")]
|
||||
ExcessiveMessageSize,
|
||||
#[error(transparent)]
|
||||
XconError(Rc<XconError>),
|
||||
#[error("The server does not support the `{0}` extension")]
|
||||
ExtensionUnavailable(&'static str),
|
||||
#[error("The server returned error {0}")]
|
||||
CoreError(u8),
|
||||
#[error("The extension `{0}` returned error {1}")]
|
||||
ExtensionError(&'static str, u8),
|
||||
#[error("The connection to the server has already been closed")]
|
||||
Dead,
|
||||
#[error("Could not query the `{0}` extension")]
|
||||
QueryExtension(BString, #[source] Box<XconError>),
|
||||
#[error("All available xids have been used")]
|
||||
XidExhausted,
|
||||
#[error("Enum contains an unknown variant")]
|
||||
UnknownEnumVariant,
|
||||
#[error("Could not query the render pict formats")]
|
||||
QueryPictFormats(#[source] Box<XconError>),
|
||||
#[error("The server does not support the picture format for cursors")]
|
||||
CursorFormatNotSupported,
|
||||
#[error("Could not create a pixmap")]
|
||||
CreatePixmap(#[source] Box<XconError>),
|
||||
#[error("Could not create a graphics context")]
|
||||
CreateGc(#[source] Box<XconError>),
|
||||
#[error("Could not upload an image")]
|
||||
PutImage(#[source] Box<XconError>),
|
||||
#[error("Could not create a picture")]
|
||||
CreatePicture(#[source] Box<XconError>),
|
||||
#[error("Could not create a cursor")]
|
||||
CreateCursor(#[source] Box<XconError>),
|
||||
#[error("Property has an invalid type")]
|
||||
InvalidPropertyType,
|
||||
#[error("Property has an invalid format. Expected: {0}; Actual: {1}")]
|
||||
InvalidPropertyFormat(u8, u8),
|
||||
#[error("Length of the property data is not a multiple of its format")]
|
||||
IrregularPropertyLength,
|
||||
#[error("The property is not set")]
|
||||
PropertyUnavailable,
|
||||
}
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
utils::ptr_ext::PtrExt,
|
||||
xcon::{XconError, wire_type::Message},
|
||||
},
|
||||
crate::{Message, XconError},
|
||||
bstr::{BStr, ByteSlice},
|
||||
jay_utils::ptr_ext::PtrExt,
|
||||
std::{borrow::Cow, rc::Rc},
|
||||
uapi::{OwnedFd, Pod},
|
||||
};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::xcon::{XconError, formatter::Formatter, parser::Parser},
|
||||
crate::{Formatter, Parser, XconError},
|
||||
bstr::{BStr, ByteSlice},
|
||||
std::{borrow::Cow, fmt::Debug, rc::Rc},
|
||||
uapi::OwnedFd,
|
||||
|
|
@ -118,7 +118,7 @@ unsafe impl<'a> Message<'a> for Rc<OwnedFd> {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(super) struct SendEvent {
|
||||
pub struct SendEvent {
|
||||
pub propagate: u8,
|
||||
pub destination: u32,
|
||||
pub event_mask: u32,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::xcon::XconError,
|
||||
crate::XconError,
|
||||
bstr::{BString, ByteSlice},
|
||||
std::{fs::File, io::Read},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue