autocommit 2022-02-06 16:33:54 CET
This commit is contained in:
parent
c92346324b
commit
dc2cb71012
104 changed files with 2563 additions and 4617 deletions
|
|
@ -4,6 +4,7 @@ use crate::utils::buffd::{BufFdError, MsgParserError};
|
|||
use crate::AsyncError;
|
||||
use std::error::Error;
|
||||
use thiserror::Error;
|
||||
use crate::wire::WlDisplayId;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ClientError {
|
||||
|
|
@ -36,7 +37,7 @@ pub enum ClientError {
|
|||
#[error("The client object id is out of bounds")]
|
||||
ClientIdOutOfBounds,
|
||||
#[error("Object {0} is not a display")]
|
||||
NotADisplay(ObjectId),
|
||||
NotADisplay(WlDisplayId),
|
||||
#[error(transparent)]
|
||||
ObjectError(ObjectError),
|
||||
#[error(transparent)]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::client::error::LookupError;
|
|||
use crate::client::objects::Objects;
|
||||
use crate::ifs::wl_callback::WlCallback;
|
||||
use crate::ifs::wl_display::WlDisplay;
|
||||
use crate::ifs::wl_registry::{WlRegistry, WlRegistryId};
|
||||
use crate::ifs::wl_registry::{WlRegistry};
|
||||
use crate::object::{Interface, Object, ObjectId, WL_DISPLAY_ID};
|
||||
use crate::state::State;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
|
|
@ -19,6 +19,7 @@ use std::fmt::{Debug, Display, Formatter};
|
|||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use uapi::{c, OwnedFd};
|
||||
use crate::wire::WlRegistryId;
|
||||
|
||||
mod error;
|
||||
mod objects;
|
||||
|
|
@ -307,15 +308,11 @@ impl Client {
|
|||
}
|
||||
|
||||
pub fn log_event(&self, event: &dyn EventFormatter) {
|
||||
if !event.should_log() {
|
||||
return;
|
||||
}
|
||||
let obj = event.obj();
|
||||
log::trace!(
|
||||
"Client {} <= {}@{}.{:?}",
|
||||
self.id,
|
||||
obj.interface().name(),
|
||||
obj.id(),
|
||||
event.interface().name(),
|
||||
event.id(),
|
||||
event,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::ifs::wl_buffer::{WlBuffer, WlBufferId};
|
||||
use crate::ifs::wl_data_source::{WlDataSource, WlDataSourceId};
|
||||
use crate::ifs::wl_buffer::{WlBuffer};
|
||||
use crate::ifs::wl_data_source::{WlDataSource};
|
||||
use crate::ifs::wl_display::WlDisplay;
|
||||
use crate::ifs::wl_region::{WlRegion, WlRegionId};
|
||||
use crate::ifs::wl_registry::{WlRegistry, WlRegistryId};
|
||||
use crate::ifs::wl_seat::{WlSeat, WlSeatId};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::{XdgToplevel, XdgToplevelId};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceId};
|
||||
use crate::ifs::wl_surface::{WlSurface, WlSurfaceId};
|
||||
use crate::ifs::xdg_positioner::{XdgPositioner, XdgPositionerId};
|
||||
use crate::ifs::xdg_wm_base::{XdgWmBase, XdgWmBaseId};
|
||||
use crate::ifs::wl_region::{WlRegion};
|
||||
use crate::ifs::wl_registry::{WlRegistry};
|
||||
use crate::ifs::wl_seat::{WlSeat};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::{XdgToplevel};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface};
|
||||
use crate::ifs::wl_surface::{WlSurface};
|
||||
use crate::ifs::xdg_positioner::{XdgPositioner};
|
||||
use crate::ifs::xdg_wm_base::{XdgWmBase};
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{
|
||||
ZwpPrimarySelectionSourceV1, ZwpPrimarySelectionSourceV1Id,
|
||||
ZwpPrimarySelectionSourceV1,
|
||||
};
|
||||
use crate::object::{Object, ObjectId};
|
||||
use crate::tree::Node;
|
||||
|
|
@ -21,6 +21,7 @@ use ahash::AHashMap;
|
|||
use std::cell::{RefCell, RefMut};
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use crate::wire::{WlBufferId, WlDataSourceId, WlRegionId, WlRegistryId, WlSeatId, WlSurfaceId, XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwpPrimarySelectionSourceV1Id};
|
||||
|
||||
pub struct Objects {
|
||||
pub display: CloneCell<Option<Rc<WlDisplay>>>,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
use std::rc::Rc;
|
||||
use crate::format::Format;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
pub struct DmaBufPlane {
|
||||
pub offset: u32,
|
||||
pub stride: u32,
|
||||
pub fd: OwnedFd,
|
||||
pub fd: Rc<OwnedFd>,
|
||||
}
|
||||
|
||||
pub struct DmaBuf {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use crate::drm::drm::{Drm, DrmError};
|
|||
use crate::drm::{ModifiedFormat, INVALID_MODIFIER};
|
||||
use crate::format::formats;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, OwnedFd};
|
||||
|
||||
|
|
@ -102,7 +103,7 @@ unsafe fn export_bo(bo: *mut Bo) -> Result<DmaBuf, GbmError> {
|
|||
planes.push(DmaBufPlane {
|
||||
offset,
|
||||
stride,
|
||||
fd: OwnedFd::new(fd),
|
||||
fd: Rc::new(OwnedFd::new(fd)),
|
||||
})
|
||||
}
|
||||
planes
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::org_kde_kwin_server_decoration::*;
|
||||
|
||||
mod types;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::OrgKdeKwinServerDecorationId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const NONE: u32 = 0;
|
||||
|
|
@ -71,3 +71,36 @@ impl Object for OrgKdeKwinServerDecoration {
|
|||
}
|
||||
|
||||
simple_add_obj!(OrgKdeKwinServerDecoration);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OrgKdeKwinServerDecorationError {
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error("Could not process a `request_mode` request")]
|
||||
RequestModeError(#[from] RequestModeError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(OrgKdeKwinServerDecorationError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(ReleaseError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum RequestModeError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Mode {0} does not exist")]
|
||||
InvalidMode(u32),
|
||||
}
|
||||
efrom!(RequestModeError, ClientError);
|
||||
efrom!(RequestModeError, ParseError, MsgParserError);
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::org_kde_kwin_server_decoration::{OrgKdeKwinServerDecoration, MODE};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OrgKdeKwinServerDecorationError {
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error("Could not process a `request_mode` request")]
|
||||
RequestModeError(#[from] RequestModeError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(OrgKdeKwinServerDecorationError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(ReleaseError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum RequestModeError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Mode {0} does not exist")]
|
||||
InvalidMode(u32),
|
||||
}
|
||||
efrom!(RequestModeError, ClientError);
|
||||
efrom!(RequestModeError, ParseError, MsgParserError);
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecoration;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::org_kde_kwin_server_decoration_manager::*;
|
||||
|
||||
mod types;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::OrgKdeKwinServerDecorationManagerId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const NONE: u32 = 0;
|
||||
|
|
@ -25,7 +25,7 @@ impl OrgKdeKwinServerDecorationManagerGlobal {
|
|||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: OrgKdeKwinServerDecorationManagerGlobalId,
|
||||
id: OrgKdeKwinServerDecorationManagerId,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), OrgKdeKwinServerDecorationManagerError> {
|
||||
|
|
@ -59,7 +59,7 @@ impl Global for OrgKdeKwinServerDecorationManagerGlobal {
|
|||
simple_add_global!(OrgKdeKwinServerDecorationManagerGlobal);
|
||||
|
||||
pub struct OrgKdeKwinServerDecorationManager {
|
||||
id: OrgKdeKwinServerDecorationManagerGlobalId,
|
||||
id: OrgKdeKwinServerDecorationManagerId,
|
||||
client: Rc<Client>,
|
||||
_version: u32,
|
||||
}
|
||||
|
|
@ -95,3 +95,26 @@ impl Object for OrgKdeKwinServerDecorationManager {
|
|||
}
|
||||
|
||||
simple_add_obj!(OrgKdeKwinServerDecorationManager);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OrgKdeKwinServerDecorationManagerError {
|
||||
#[error("Could not process a `create` request")]
|
||||
CreateError(#[from] CreateError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(
|
||||
OrgKdeKwinServerDecorationManagerError,
|
||||
ClientError,
|
||||
ClientError
|
||||
);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(CreateError, ClientError);
|
||||
efrom!(CreateError, ParseError, MsgParserError);
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecorationId;
|
||||
use crate::ifs::org_kde_kwin_server_decoration_manager::{
|
||||
OrgKdeKwinServerDecorationManager, DEFAULT_MODE,
|
||||
};
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OrgKdeKwinServerDecorationManagerError {
|
||||
#[error("Could not process a `create` request")]
|
||||
CreateError(#[from] CreateError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(
|
||||
OrgKdeKwinServerDecorationManagerError,
|
||||
ClientError,
|
||||
ClientError
|
||||
);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(CreateError, ClientError);
|
||||
efrom!(CreateError, ParseError, MsgParserError);
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::clientmem::{ClientMem, ClientMemOffset};
|
||||
use crate::format::Format;
|
||||
use crate::object::Object;
|
||||
|
|
@ -10,8 +8,11 @@ use crate::utils::buffd::MsgParser;
|
|||
use crate::utils::clonecell::CloneCell;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_buffer::*;
|
||||
pub use types::*;
|
||||
use crate::{ClientMemError, RenderError};
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlBufferId;
|
||||
|
||||
pub enum WlBufferStorage {
|
||||
Shm { mem: ClientMemOffset, stride: i32 },
|
||||
|
|
@ -135,3 +136,29 @@ impl Object for WlBuffer {
|
|||
}
|
||||
|
||||
dedicated_add_obj!(WlBuffer, WlBufferId, buffers);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlBufferError {
|
||||
#[error("The requested memory region is out of bounds for the pool")]
|
||||
OutOfBounds,
|
||||
#[error("The stride does not fit all pixels in a row")]
|
||||
StrideTooSmall,
|
||||
#[error("Could not handle a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not access the client memory")]
|
||||
ClientMemError(#[source] Box<ClientMemError>),
|
||||
#[error("GLES could not import the client image")]
|
||||
GlesError(#[source] Box<RenderError>),
|
||||
}
|
||||
efrom!(WlBufferError, ClientMemError);
|
||||
efrom!(WlBufferError, GlesError, RenderError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_buffer::{WlBuffer, RELEASE};
|
||||
use crate::object::Object;
|
||||
use crate::render::RenderError;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use crate::ClientMemError;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlBufferError {
|
||||
#[error("The requested memory region is out of bounds for the pool")]
|
||||
OutOfBounds,
|
||||
#[error("The stride does not fit all pixels in a row")]
|
||||
StrideTooSmall,
|
||||
#[error("Could not handle a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not access the client memory")]
|
||||
ClientMemError(#[source] Box<ClientMemError>),
|
||||
#[error("GLES could not import the client image")]
|
||||
GlesError(#[source] Box<RenderError>),
|
||||
}
|
||||
efrom!(WlBufferError, ClientMemError);
|
||||
efrom!(WlBufferError, GlesError, RenderError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::object::Object;
|
||||
use std::rc::Rc;
|
||||
use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_callback::*;
|
||||
use crate::wire::WlCallbackId;
|
||||
|
||||
pub struct WlCallback {
|
||||
id: WlCallbackId,
|
||||
|
|
@ -31,3 +30,6 @@ impl Object for WlCallback {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlCallback);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlCallbackError {}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
use crate::client::EventFormatter;
|
||||
use crate::ifs::wl_callback::{WlCallback, DONE};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgFormatter;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlCallbackError {}
|
||||
|
|
@ -1,18 +1,14 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_region::WlRegion;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const CREATE_SURFACE: u32 = 0;
|
||||
const CREATE_REGION: u32 = 1;
|
||||
|
||||
id!(WlCompositorId);
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_compositor::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlCompositorId;
|
||||
|
||||
pub struct WlCompositorGlobal {
|
||||
name: GlobalName,
|
||||
|
|
@ -89,3 +85,39 @@ impl Object for WlCompositor {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlCompositor);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlCompositorError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `create_surface` request")]
|
||||
CreateSurfaceError(#[source] Box<CreateSurfaceError>),
|
||||
#[error("Could not process `create_region` request")]
|
||||
CreateRegionError(#[source] Box<CreateRegionError>),
|
||||
}
|
||||
|
||||
efrom!(WlCompositorError, ClientError);
|
||||
efrom!(WlCompositorError, CreateSurfaceError);
|
||||
efrom!(WlCompositorError, CreateRegionError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateSurfaceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
|
||||
efrom!(CreateSurfaceError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateSurfaceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateRegionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
|
||||
efrom!(CreateRegionError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateRegionError, ClientError, ClientError);
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::ifs::wl_region::WlRegionId;
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlCompositorError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `create_surface` request")]
|
||||
CreateSurfaceError(#[source] Box<CreateSurfaceError>),
|
||||
#[error("Could not process `create_region` request")]
|
||||
CreateRegionError(#[source] Box<CreateRegionError>),
|
||||
}
|
||||
|
||||
efrom!(WlCompositorError, ClientError);
|
||||
efrom!(WlCompositorError, CreateSurfaceError);
|
||||
efrom!(WlCompositorError, CreateRegionError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateSurfaceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
|
||||
efrom!(CreateSurfaceError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateSurfaceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateRegionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
|
||||
efrom!(CreateRegionError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateRegionError, ClientError, ClientError);
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::client::{ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_data_device_manager::WlDataDeviceManager;
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::wl_data_source::WlDataSourceError;
|
||||
use crate::wire::wl_data_device::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::{WlDataDeviceId, WlDataOfferId};
|
||||
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
|
@ -85,3 +85,49 @@ impl Object for WlDataDevice {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlDataDevice);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataDeviceError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `start_drag` request")]
|
||||
StartDragError(#[from] StartDragError),
|
||||
#[error("Could not process `set_selection` request")]
|
||||
SetSelectionError(#[from] SetSelectionError),
|
||||
#[error("Could not process `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
}
|
||||
efrom!(WlDataDeviceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum StartDragError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(StartDragError, ParseFailed, MsgParserError);
|
||||
efrom!(StartDragError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSelectionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WlDataSourceError(Box<WlDataSourceError>),
|
||||
}
|
||||
efrom!(SetSelectionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetSelectionError, ClientError);
|
||||
efrom!(SetSelectionError, WlDataSourceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseFailed, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError);
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
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::{WlDataSourceError, WlDataSourceId};
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataDeviceError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `start_drag` request")]
|
||||
StartDragError(#[from] StartDragError),
|
||||
#[error("Could not process `set_selection` request")]
|
||||
SetSelectionError(#[from] SetSelectionError),
|
||||
#[error("Could not process `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
}
|
||||
efrom!(WlDataDeviceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum StartDragError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(StartDragError, ParseFailed, MsgParserError);
|
||||
efrom!(StartDragError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSelectionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WlDataSourceError(Box<WlDataSourceError>),
|
||||
}
|
||||
efrom!(SetSelectionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetSelectionError, ClientError);
|
||||
efrom!(SetSelectionError, WlDataSourceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseFailed, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError);
|
||||
|
|
@ -1,14 +1,15 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_source::WlDataSource;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_data_device_manager::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlDataDeviceManagerId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const DND_NONE: u32 = 0;
|
||||
|
|
@ -103,3 +104,34 @@ impl Object for WlDataDeviceManager {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlDataDeviceManager);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataDeviceManagerError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `create_data_source` request")]
|
||||
CreateDataSourceError(#[from] CreateDataSourceError),
|
||||
#[error("Could not process `get_data_device` request")]
|
||||
GetDataDeviceError(#[from] GetDataDeviceError),
|
||||
}
|
||||
efrom!(WlDataDeviceManagerError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateDataSourceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateDataSourceError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateDataSourceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetDataDeviceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetDataDeviceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetDataDeviceError, ClientError);
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
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;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataDeviceManagerError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `create_data_source` request")]
|
||||
CreateDataSourceError(#[from] CreateDataSourceError),
|
||||
#[error("Could not process `get_data_device` request")]
|
||||
GetDataDeviceError(#[from] GetDataDeviceError),
|
||||
}
|
||||
efrom!(WlDataDeviceManagerError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateDataSourceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateDataSourceError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateDataSourceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetDataDeviceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetDataDeviceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetDataDeviceError, ClientError);
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_data_source::WlDataSource;
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::object::Object;
|
||||
|
|
@ -8,8 +7,10 @@ use crate::utils::buffd::MsgParser;
|
|||
use crate::utils::clonecell::CloneCell;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_data_offer::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlDataOfferId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_FINISH: u32 = 0;
|
||||
|
|
@ -133,3 +134,70 @@ impl Object for WlDataOffer {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlDataOffer);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataOfferError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `accept` request")]
|
||||
AcceptError(#[from] AcceptError),
|
||||
#[error("Could not process `receive` request")]
|
||||
ReceiveError(#[from] ReceiveError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `finish` request")]
|
||||
FinishError(#[from] FinishError),
|
||||
#[error("Could not process `set_actions` request")]
|
||||
SetActionsError(#[from] SetActionsError),
|
||||
}
|
||||
efrom!(WlDataOfferError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AcceptError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(AcceptError, ParseFailed, MsgParserError);
|
||||
efrom!(AcceptError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReceiveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReceiveError, ParseFailed, MsgParserError);
|
||||
efrom!(ReceiveError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FinishError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(FinishError, ParseFailed, MsgParserError);
|
||||
efrom!(FinishError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetActionsError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, ClientError);
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
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;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataOfferError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `accept` request")]
|
||||
AcceptError(#[from] AcceptError),
|
||||
#[error("Could not process `receive` request")]
|
||||
ReceiveError(#[from] ReceiveError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `finish` request")]
|
||||
FinishError(#[from] FinishError),
|
||||
#[error("Could not process `set_actions` request")]
|
||||
SetActionsError(#[from] SetActionsError),
|
||||
}
|
||||
efrom!(WlDataOfferError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AcceptError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(AcceptError, ParseFailed, MsgParserError);
|
||||
efrom!(AcceptError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReceiveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReceiveError, ParseFailed, MsgParserError);
|
||||
efrom!(ReceiveError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FinishError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(FinishError, ParseFailed, MsgParserError);
|
||||
efrom!(FinishError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetActionsError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, ClientError);
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_data_offer::{DataOfferRole, WlDataOffer};
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::object::Object;
|
||||
|
|
@ -9,9 +8,11 @@ use crate::utils::clonecell::{CloneCell, UnsafeCellCloneSafe};
|
|||
use ahash::AHashSet;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::wire::wl_data_source::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlDataSourceId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_ACTION_MASK: u32 = 0;
|
||||
|
|
@ -159,3 +160,48 @@ impl Object for WlDataSource {
|
|||
}
|
||||
|
||||
dedicated_add_obj!(WlDataSource, WlDataSourceId, wl_data_source);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataSourceError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `offer` request")]
|
||||
OfferError(#[from] OfferError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `set_actions` request")]
|
||||
SetActionsError(#[from] SetActionsError),
|
||||
#[error("The data source is already attached")]
|
||||
AlreadyAttached,
|
||||
}
|
||||
efrom!(WlDataSourceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OfferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(OfferError, ParseFailed, MsgParserError);
|
||||
efrom!(OfferError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetActionsError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, ClientError);
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_data_source::{
|
||||
WlDataSource, ACTION, CANCELLED, DND_DROP_PERFORMED, DND_FINISHED, SEND, TARGET,
|
||||
};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use bstr::BString;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataSourceError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `offer` request")]
|
||||
OfferError(#[from] OfferError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `set_actions` request")]
|
||||
SetActionsError(#[from] SetActionsError),
|
||||
#[error("The data source is already attached")]
|
||||
AlreadyAttached,
|
||||
}
|
||||
efrom!(WlDataSourceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OfferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(OfferError, ParseFailed, MsgParserError);
|
||||
efrom!(OfferError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetActionsError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, ClientError);
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_callback::WlCallback;
|
||||
use crate::ifs::wl_registry::WlRegistry;
|
||||
use crate::object::{Object, ObjectId, WL_DISPLAY_ID};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::globals::GlobalsError;
|
||||
use crate::wire::wl_display::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlDisplayId;
|
||||
|
||||
const INVALID_OBJECT: u32 = 0;
|
||||
const INVALID_METHOD: u32 = 1;
|
||||
|
|
@ -102,3 +104,39 @@ impl Object for WlDisplay {
|
|||
GET_REGISTRY + 1
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDisplayError {
|
||||
#[error("Could not process a get_registry request")]
|
||||
GetRegistryError(#[source] Box<GetRegistryError>),
|
||||
#[error("A client error occurred")]
|
||||
SyncError(#[source] Box<SyncError>),
|
||||
}
|
||||
|
||||
efrom!(WlDisplayError, GetRegistryError);
|
||||
efrom!(WlDisplayError, SyncError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetRegistryError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("An error occurred while processing globals")]
|
||||
GlobalsError(#[source] Box<GlobalsError>),
|
||||
}
|
||||
|
||||
efrom!(GetRegistryError, ParseFailed, MsgParserError);
|
||||
efrom!(GetRegistryError, GlobalsError);
|
||||
efrom!(GetRegistryError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SyncError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
|
||||
efrom!(SyncError, ParseFailed, MsgParserError);
|
||||
efrom!(SyncError, ClientError);
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::globals::GlobalsError;
|
||||
use crate::ifs::wl_callback::WlCallbackId;
|
||||
use crate::ifs::wl_display::{WlDisplay, DELETE_ID, ERROR};
|
||||
use crate::ifs::wl_registry::WlRegistryId;
|
||||
use crate::object::{Object, ObjectId, WL_DISPLAY_ID};
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDisplayError {
|
||||
#[error("Could not process a get_registry request")]
|
||||
GetRegistryError(#[source] Box<GetRegistryError>),
|
||||
#[error("A client error occurred")]
|
||||
SyncError(#[source] Box<SyncError>),
|
||||
}
|
||||
|
||||
efrom!(WlDisplayError, GetRegistryError);
|
||||
efrom!(WlDisplayError, SyncError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetRegistryError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("An error occurred while processing globals")]
|
||||
GlobalsError(#[source] Box<GlobalsError>),
|
||||
}
|
||||
|
||||
efrom!(GetRegistryError, ParseFailed, MsgParserError);
|
||||
efrom!(GetRegistryError, GlobalsError);
|
||||
efrom!(GetRegistryError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SyncError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
|
||||
efrom!(SyncError, ParseFailed, MsgParserError);
|
||||
efrom!(SyncError, ClientError);
|
||||
|
|
@ -1,14 +1,15 @@
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::ffi::CString;
|
||||
use std::rc::Rc;
|
||||
use bstr::ByteSlice;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_drm::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlDrmId;
|
||||
|
||||
mod types;
|
||||
|
||||
const PRIME: u32 = 1;
|
||||
|
||||
|
|
@ -115,3 +116,41 @@ impl Object for WlDrm {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlDrm);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDrmError {
|
||||
#[error("Could not process a `authenticate` request")]
|
||||
AuthenticateError(#[from] AuthenticateError),
|
||||
#[error("Could not process a `create_buffer` request")]
|
||||
CreateBufferError(#[from] CreateBufferError),
|
||||
#[error("Could not process a `create_planar_buffer` request")]
|
||||
CreatePlanarBufferError(#[from] CreatePlanarBufferError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlDrmError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AuthenticateError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(AuthenticateError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("This api is not supported")]
|
||||
Unsupported,
|
||||
}
|
||||
efrom!(CreateBufferError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreatePlanarBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("This api is not supported")]
|
||||
Unsupported,
|
||||
}
|
||||
efrom!(CreatePlanarBufferError, ParseError, MsgParserError);
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_buffer::WlBufferId;
|
||||
use crate::ifs::wl_drm::{WlDrm, AUTHENTICATED, CAPABILITIES, DEVICE, FORMAT};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::ffi::CString;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDrmError {
|
||||
#[error("Could not process a `authenticate` request")]
|
||||
AuthenticateError(#[from] AuthenticateError),
|
||||
#[error("Could not process a `create_buffer` request")]
|
||||
CreateBufferError(#[from] CreateBufferError),
|
||||
#[error("Could not process a `create_planar_buffer` request")]
|
||||
CreatePlanarBufferError(#[from] CreatePlanarBufferError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlDrmError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AuthenticateError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(AuthenticateError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("This api is not supported")]
|
||||
Unsupported,
|
||||
}
|
||||
efrom!(CreateBufferError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreatePlanarBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("This api is not supported")]
|
||||
Unsupported,
|
||||
}
|
||||
efrom!(CreatePlanarBufferError, ParseError, MsgParserError);
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
mod types;
|
||||
|
||||
use crate::backend::Output;
|
||||
use crate::client::{Client, ClientId, DynEventFormatter, WlEvent};
|
||||
use crate::client::{Client, ClientError, ClientId, DynEventFormatter, WlEvent};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
|
|
@ -10,8 +9,10 @@ use std::cell::{Cell, RefCell};
|
|||
use std::collections::hash_map::Entry;
|
||||
use std::iter;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_output::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlOutputId;
|
||||
|
||||
const SP_UNKNOWN: i32 = 0;
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -163,8 +164,8 @@ impl WlOutput {
|
|||
}
|
||||
|
||||
fn geometry(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Geometry {
|
||||
obj: self.clone(),
|
||||
Box::new(GeometryOut {
|
||||
self_id: self.id,
|
||||
x: 0,
|
||||
y: 0,
|
||||
physical_width: self.global.width.get() as _,
|
||||
|
|
@ -235,3 +236,22 @@ impl Object for WlOutput {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlOutput);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlOutputError {
|
||||
#[error("Could not handle `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlOutputError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_output::{WlOutput, DONE, GEOMETRY, MODE, SCALE};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlOutputError {
|
||||
#[error("Could not handle `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlOutputError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::object::Object;
|
||||
use crate::pixman::Region;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_region::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlRegionId;
|
||||
|
||||
pub struct WlRegion {
|
||||
id: WlRegionId,
|
||||
|
|
@ -75,3 +76,41 @@ impl Object for WlRegion {
|
|||
}
|
||||
|
||||
dedicated_add_obj!(WlRegion, WlRegionId, regions);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlRegionError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `add` request")]
|
||||
AddError(#[from] AddError),
|
||||
#[error("Could not process `subtract` request")]
|
||||
SubtractError(#[from] SubtractError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AddError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error("width and/or height are negative")]
|
||||
NegativeExtents,
|
||||
}
|
||||
efrom!(AddError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SubtractError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error("width and/or height are negative")]
|
||||
NegativeExtents,
|
||||
}
|
||||
efrom!(SubtractError, ParseFailed, MsgParserError);
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlRegionError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `add` request")]
|
||||
AddError(#[from] AddError),
|
||||
#[error("Could not process `subtract` request")]
|
||||
SubtractError(#[from] SubtractError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AddError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error("width and/or height are negative")]
|
||||
NegativeExtents,
|
||||
}
|
||||
efrom!(AddError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SubtractError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error("width and/or height are negative")]
|
||||
NegativeExtents,
|
||||
}
|
||||
efrom!(SubtractError, ParseFailed, MsgParserError);
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::object::Object;
|
||||
use crate::globals::{Global, GlobalName, GlobalsError};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_registry::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlRegistryId;
|
||||
|
||||
pub struct WlRegistry {
|
||||
id: WlRegistryId,
|
||||
|
|
@ -38,8 +39,8 @@ impl WlRegistry {
|
|||
}
|
||||
|
||||
fn bind(&self, parser: MsgParser<'_, '_>) -> Result<(), BindError> {
|
||||
let bind: Bind = self.client.parse(self, parser)?;
|
||||
let global = self.client.state.globals.get(bind.name)?;
|
||||
let bind: BindIn = self.client.parse(self, parser)?;
|
||||
let global = self.client.state.globals.get(GlobalName::from_raw(bind.name))?;
|
||||
if global.interface().name() != bind.interface {
|
||||
return Err(BindError::InvalidInterface(InterfaceError {
|
||||
name: global.name(),
|
||||
|
|
@ -73,3 +74,41 @@ impl Object for WlRegistry {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlRegistry);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlRegistryError {
|
||||
#[error("Could not process bind request")]
|
||||
BindError(#[source] Box<BindError>),
|
||||
}
|
||||
|
||||
efrom!(WlRegistryError, BindError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum BindError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
GlobalsError(Box<GlobalsError>),
|
||||
#[error("Tried to bind to global {} of type {} using interface {}", .0.name, .0.interface.name(), .0.actual)]
|
||||
InvalidInterface(InterfaceError),
|
||||
#[error("Tried to bind to global {} of type {} and version {} using version {}", .0.name, .0.interface.name(), .0.version, .0.actual)]
|
||||
InvalidVersion(VersionError),
|
||||
}
|
||||
efrom!(BindError, ParseError, MsgParserError);
|
||||
efrom!(BindError, GlobalsError);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InterfaceError {
|
||||
pub name: GlobalName,
|
||||
pub interface: Interface,
|
||||
pub actual: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VersionError {
|
||||
pub name: GlobalName,
|
||||
pub interface: Interface,
|
||||
pub version: u32,
|
||||
pub actual: u32,
|
||||
}
|
||||
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
use crate::client::{EventFormatter, RequestParser};
|
||||
use crate::globals::{Global, GlobalName, GlobalsError};
|
||||
use crate::ifs::wl_registry::{WlRegistry, GLOBAL, GLOBAL_REMOVE};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use bstr::BStr;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlRegistryError {
|
||||
#[error("Could not process bind request")]
|
||||
BindError(#[source] Box<BindError>),
|
||||
}
|
||||
|
||||
efrom!(WlRegistryError, BindError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum BindError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
GlobalsError(Box<GlobalsError>),
|
||||
#[error("Tried to bind to global {} of type {} using interface {}", .0.name, .0.interface.name(), .0.actual)]
|
||||
InvalidInterface(InterfaceError),
|
||||
#[error("Tried to bind to global {} of type {} and version {} using version {}", .0.name, .0.interface.name(), .0.version, .0.actual)]
|
||||
InvalidVersion(VersionError),
|
||||
}
|
||||
efrom!(BindError, ParseError, MsgParserError);
|
||||
efrom!(BindError, GlobalsError);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InterfaceError {
|
||||
pub name: GlobalName,
|
||||
pub interface: Interface,
|
||||
pub actual: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VersionError {
|
||||
pub name: GlobalName,
|
||||
pub interface: Interface,
|
||||
pub version: u32,
|
||||
pub actual: u32,
|
||||
}
|
||||
|
||||
|
|
@ -1,28 +1,24 @@
|
|||
mod handling;
|
||||
mod types;
|
||||
pub mod wl_keyboard;
|
||||
pub mod wl_pointer;
|
||||
pub mod wl_touch;
|
||||
|
||||
use crate::backend::{Seat, SeatId};
|
||||
use crate::client::{Client, ClientId, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, ClientId, DynEventFormatter};
|
||||
use crate::cursor::{Cursor, KnownCursor};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceId};
|
||||
use crate::ifs::wl_data_offer::{DataOfferRole, WlDataOfferId};
|
||||
use crate::ifs::wl_data_device::{WlDataDevice};
|
||||
use crate::ifs::wl_data_offer::{DataOfferRole};
|
||||
use crate::ifs::wl_data_source::{WlDataSource, WlDataSourceError};
|
||||
use crate::ifs::wl_seat::wl_keyboard::{WlKeyboard, WlKeyboardId, REPEAT_INFO_SINCE};
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, WlPointerId};
|
||||
use crate::ifs::wl_seat::wl_keyboard::{WlKeyboard, REPEAT_INFO_SINCE, WlKeyboardError};
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer};
|
||||
use crate::ifs::wl_seat::wl_touch::WlTouch;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::ifs::zwp_primary_selection_device_v1::{
|
||||
ZwpPrimarySelectionDeviceV1, ZwpPrimarySelectionDeviceV1Id,
|
||||
};
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{
|
||||
ZwpPrimarySelectionSourceV1, ZwpPrimarySelectionSourceV1Error,
|
||||
ZwpPrimarySelectionDeviceV1,
|
||||
};
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{ZwpPrimarySelectionSourceV1, ZwpPrimarySelectionSourceV1Error};
|
||||
use crate::object::Object;
|
||||
use crate::tree::{FloatNode, FoundNode, Node};
|
||||
use crate::utils::asyncevent::AsyncEvent;
|
||||
|
|
@ -41,9 +37,11 @@ use std::collections::hash_map::Entry;
|
|||
use std::io::Write;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, OwnedFd};
|
||||
use crate::wire::wl_seat::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::{WlDataDeviceId, WlDataOfferId, WlKeyboardId, WlPointerId, WlSeatId, ZwpPrimarySelectionDeviceV1Id, ZwpPrimarySelectionOfferV1Id};
|
||||
|
||||
const POINTER: u32 = 1;
|
||||
const KEYBOARD: u32 = 2;
|
||||
|
|
@ -431,3 +429,61 @@ impl Object for WlSeat {
|
|||
}
|
||||
|
||||
dedicated_add_obj!(WlSeat, WlSeatId, seats);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSeatError {
|
||||
#[error("Could not handle `get_pointer` request")]
|
||||
GetPointerError(#[from] GetPointerError),
|
||||
#[error("Could not handle `get_keyboard` request")]
|
||||
GetKeyboardError(#[from] GetKeyboardError),
|
||||
#[error("Could not handle `get_touch` request")]
|
||||
GetTouchError(#[from] GetTouchError),
|
||||
#[error("Could not handle `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlSeatError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetPointerError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetPointerError, ClientError);
|
||||
efrom!(GetPointerError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetKeyboardError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WlKeyboardError(Box<WlKeyboardError>),
|
||||
}
|
||||
efrom!(GetKeyboardError, ClientError);
|
||||
efrom!(GetKeyboardError, ParseError, MsgParserError);
|
||||
efrom!(GetKeyboardError, WlKeyboardError, WlKeyboardError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetTouchError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetTouchError, ClientError, ClientError);
|
||||
efrom!(GetTouchError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
|
@ -2,7 +2,6 @@ use crate::backend::{KeyState, OutputId, ScrollAxis, SeatEvent, SeatId};
|
|||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
use crate::ifs::wl_seat::wl_keyboard::WlKeyboard;
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, POINTER_FRAME_SINCE_VERSION};
|
||||
use crate::ifs::wl_seat::{
|
||||
|
|
@ -13,12 +12,12 @@ use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
|||
use crate::ifs::wl_surface::xdg_surface::XdgSurface;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::ifs::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
use crate::tree::{FloatNode, FoundNode, Node};
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
use crate::wire::{WlDataOfferId, ZwpPrimarySelectionOfferV1Id};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeSeatState {
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_seat::wl_keyboard::{WlKeyboardError, WlKeyboardId};
|
||||
use crate::ifs::wl_seat::wl_pointer::WlPointerId;
|
||||
use crate::ifs::wl_seat::wl_touch::WlTouchId;
|
||||
use crate::ifs::wl_seat::{WlSeat, CAPABILITIES, NAME};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSeatError {
|
||||
#[error("Could not handle `get_pointer` request")]
|
||||
GetPointerError(#[from] GetPointerError),
|
||||
#[error("Could not handle `get_keyboard` request")]
|
||||
GetKeyboardError(#[from] GetKeyboardError),
|
||||
#[error("Could not handle `get_touch` request")]
|
||||
GetTouchError(#[from] GetTouchError),
|
||||
#[error("Could not handle `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlSeatError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetPointerError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetPointerError, ClientError);
|
||||
efrom!(GetPointerError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetKeyboardError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WlKeyboardError(Box<WlKeyboardError>),
|
||||
}
|
||||
efrom!(GetKeyboardError, ClientError);
|
||||
efrom!(GetKeyboardError, ParseError, MsgParserError);
|
||||
efrom!(GetKeyboardError, WlKeyboardError, WlKeyboardError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetTouchError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetTouchError, ClientError, ClientError);
|
||||
efrom!(GetTouchError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::client::{ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, Errno, OwnedFd};
|
||||
use crate::wire::wl_keyboard::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::{WlKeyboardId, WlSurfaceId};
|
||||
|
||||
pub const REPEAT_INFO_SINCE: u32 = 4;
|
||||
|
||||
|
|
@ -150,3 +150,26 @@ impl Object for WlKeyboard {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlKeyboard);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlKeyboardError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error("Could not create a keymap memfd")]
|
||||
KeymapMemfd(#[source] std::io::Error),
|
||||
#[error("Could not copy the keymap")]
|
||||
KeymapCopy(#[source] std::io::Error),
|
||||
}
|
||||
efrom!(WlKeyboardError, ClientError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_seat::wl_keyboard::{
|
||||
WlKeyboard, ENTER, KEY, KEYMAP, LEAVE, MODIFIERS, REPEAT_INFO,
|
||||
};
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlKeyboardError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
#[error("Could not create a keymap memfd")]
|
||||
KeymapMemfd(#[source] std::io::Error),
|
||||
#[error("Could not copy the keymap")]
|
||||
KeymapCopy(#[source] std::io::Error),
|
||||
}
|
||||
efrom!(WlKeyboardError, ClientError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::client::{ClientError, DynEventFormatter};
|
||||
use crate::cursor::Cursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::wl_surface::WlSurfaceError;
|
||||
use crate::wire::wl_pointer::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::{WlPointerId, WlSurfaceId};
|
||||
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
|
@ -178,3 +179,37 @@ impl Object for WlPointer {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlPointer);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlPointerError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `set_cursor` request")]
|
||||
SetCursorError(#[from] SetCursorError),
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
}
|
||||
efrom!(WlPointerError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetCursorError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
}
|
||||
efrom!(SetCursorError, ParseError, MsgParserError);
|
||||
efrom!(SetCursorError, ClientError);
|
||||
efrom!(SetCursorError, WlSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::wl_pointer::{
|
||||
WlPointer, AXIS, AXIS_DISCRETE, AXIS_SOURCE, AXIS_STOP, BUTTON, ENTER, FRAME, LEAVE, MOTION,
|
||||
};
|
||||
use crate::ifs::wl_surface::{WlSurfaceError, WlSurfaceId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlPointerError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `set_cursor` request")]
|
||||
SetCursorError(#[from] SetCursorError),
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
}
|
||||
efrom!(WlPointerError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetCursorError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
}
|
||||
efrom!(SetCursorError, ParseError, MsgParserError);
|
||||
efrom!(SetCursorError, ClientError);
|
||||
efrom!(SetCursorError, WlSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
mod types;
|
||||
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const RELEASE: u32 = 0;
|
||||
use thiserror::Error;
|
||||
use crate::client::ClientError;
|
||||
use crate::wire::wl_touch::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlTouchId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const DOWN: u32 = 0;
|
||||
|
|
@ -23,8 +24,6 @@ const SHAPE: u32 = 5;
|
|||
#[allow(dead_code)]
|
||||
const ORIENTATION: u32 = 6;
|
||||
|
||||
id!(WlTouchId);
|
||||
|
||||
pub struct WlTouch {
|
||||
id: WlTouchId,
|
||||
seat: Rc<WlSeat>,
|
||||
|
|
@ -58,3 +57,22 @@ impl Object for WlTouch {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlTouch);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlTouchError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
}
|
||||
efrom!(WlTouchError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlTouchError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `release` request")]
|
||||
ReleaseError(#[from] ReleaseError),
|
||||
}
|
||||
efrom!(WlTouchError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReleaseError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError);
|
||||
|
||||
pub(super) struct Release;
|
||||
impl RequestParser<'_> for Release {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Release {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()",)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,15 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::format::FORMATS;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_shm_pool::WlShmPool;
|
||||
use crate::ifs::wl_shm_pool::{WlShmPool, WlShmPoolError};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const CREATE_POOL: u32 = 0;
|
||||
|
||||
const FORMAT: u32 = 0;
|
||||
|
||||
id!(WlShmId);
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_shm::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlShmId;
|
||||
|
||||
pub struct WlShmGlobal {
|
||||
name: GlobalName,
|
||||
|
|
@ -43,9 +39,9 @@ impl WlShmGlobal {
|
|||
});
|
||||
client.add_client_obj(&obj)?;
|
||||
for format in FORMATS {
|
||||
client.event(Box::new(FormatE {
|
||||
obj: obj.clone(),
|
||||
format,
|
||||
client.event(Box::new(Format {
|
||||
self_id: id,
|
||||
format: format.wl_id.unwrap_or(format.drm),
|
||||
}));
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -96,3 +92,27 @@ impl Object for WlShm {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlShm);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlShmError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `create_pool` request")]
|
||||
CreatePoolError(#[from] CreatePoolError),
|
||||
}
|
||||
efrom!(WlShmError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreatePoolError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("The passed size is negative")]
|
||||
NegativeSize,
|
||||
#[error(transparent)]
|
||||
WlShmPoolError(Box<WlShmPoolError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreatePoolError, ParseError, MsgParserError);
|
||||
efrom!(CreatePoolError, WlShmPoolError);
|
||||
efrom!(CreatePoolError, ClientError);
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::format::Format;
|
||||
use crate::ifs::wl_shm::{WlShm, FORMAT};
|
||||
use crate::ifs::wl_shm_pool::{WlShmPoolError, WlShmPoolId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlShmError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `create_pool` request")]
|
||||
CreatePoolError(#[from] CreatePoolError),
|
||||
}
|
||||
efrom!(WlShmError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreatePoolError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("The passed size is negative")]
|
||||
NegativeSize,
|
||||
#[error(transparent)]
|
||||
WlShmPoolError(Box<WlShmPoolError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreatePoolError, ParseError, MsgParserError);
|
||||
efrom!(CreatePoolError, WlShmPoolError);
|
||||
efrom!(CreatePoolError, ClientError);
|
||||
|
||||
pub(super) struct CreatePool {
|
||||
pub id: WlShmPoolId,
|
||||
pub fd: OwnedFd,
|
||||
pub size: i32,
|
||||
}
|
||||
impl RequestParser<'_> for CreatePool {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
fd: parser.fd()?,
|
||||
size: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreatePool {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"create_pool(id: {}, fd: {}, size: {})",
|
||||
self.id,
|
||||
self.fd.raw(),
|
||||
self.size
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct FormatE {
|
||||
pub obj: Rc<WlShm>,
|
||||
pub format: &'static Format,
|
||||
}
|
||||
impl EventFormatter for FormatE {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, FORMAT)
|
||||
.uint(self.format.wl_id.unwrap_or(self.format.drm));
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for FormatE {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"format(format: \"{}\" (0x{:x}))",
|
||||
self.format.name,
|
||||
self.format.wl_id.unwrap_or(self.format.drm),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +1,23 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::clientmem::ClientMem;
|
||||
use crate::format::{formats, map_wayland_format_id};
|
||||
use crate::ifs::wl_buffer::WlBuffer;
|
||||
use crate::ifs::wl_buffer::{WlBuffer, WlBufferError};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
const CREATE_BUFFER: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
const RESIZE: u32 = 2;
|
||||
|
||||
id!(WlShmPoolId);
|
||||
use crate::ClientMemError;
|
||||
use crate::wire::wl_shm_pool::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlShmPoolId;
|
||||
|
||||
pub struct WlShmPool {
|
||||
id: WlShmPoolId,
|
||||
client: Rc<Client>,
|
||||
fd: OwnedFd,
|
||||
fd: Rc<OwnedFd>,
|
||||
mem: CloneCell<Rc<ClientMem>>,
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +25,7 @@ impl WlShmPool {
|
|||
pub fn new(
|
||||
id: WlShmPoolId,
|
||||
client: &Rc<Client>,
|
||||
fd: OwnedFd,
|
||||
fd: Rc<OwnedFd>,
|
||||
len: usize,
|
||||
) -> Result<Self, WlShmPoolError> {
|
||||
Ok(Self {
|
||||
|
|
@ -98,3 +95,60 @@ impl Object for WlShmPool {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlShmPool);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlShmPoolError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `create_buffer` request")]
|
||||
CreateBufferError(#[from] CreateBufferError),
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `resize` request")]
|
||||
ResizeError(#[from] ResizeError),
|
||||
#[error(transparent)]
|
||||
ClientMemError(Box<ClientMemError>),
|
||||
}
|
||||
efrom!(WlShmPoolError, ClientError);
|
||||
efrom!(WlShmPoolError, ClientMemError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Format {0} is not supported")]
|
||||
InvalidFormat(u32),
|
||||
#[error("All parameters in a create_buffer request must be non-negative")]
|
||||
NegativeParameters,
|
||||
#[error(transparent)]
|
||||
WlBufferError(Box<WlBufferError>),
|
||||
}
|
||||
efrom!(CreateBufferError, ParseError, MsgParserError);
|
||||
efrom!(CreateBufferError, ClientError);
|
||||
efrom!(CreateBufferError, WlBufferError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ResizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Tried to shrink the pool")]
|
||||
CannotShrink,
|
||||
#[error("Requested size is negative")]
|
||||
NegativeSize,
|
||||
#[error(transparent)]
|
||||
ClientMemError(Box<ClientMemError>),
|
||||
}
|
||||
efrom!(ResizeError, ParseError, MsgParserError);
|
||||
efrom!(ResizeError, ClientMemError);
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::clientmem::ClientMemError;
|
||||
use crate::ifs::wl_buffer::{WlBufferError, WlBufferId};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlShmPoolError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `create_buffer` request")]
|
||||
CreateBufferError(#[from] CreateBufferError),
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `resize` request")]
|
||||
ResizeError(#[from] ResizeError),
|
||||
#[error(transparent)]
|
||||
ClientMemError(Box<ClientMemError>),
|
||||
}
|
||||
efrom!(WlShmPoolError, ClientError);
|
||||
efrom!(WlShmPoolError, ClientMemError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Format {0} is not supported")]
|
||||
InvalidFormat(u32),
|
||||
#[error("All parameters in a create_buffer request must be non-negative")]
|
||||
NegativeParameters,
|
||||
#[error(transparent)]
|
||||
WlBufferError(Box<WlBufferError>),
|
||||
}
|
||||
efrom!(CreateBufferError, ParseError, MsgParserError);
|
||||
efrom!(CreateBufferError, ClientError);
|
||||
efrom!(CreateBufferError, WlBufferError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ResizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Tried to shrink the pool")]
|
||||
CannotShrink,
|
||||
#[error("Requested size is negative")]
|
||||
NegativeSize,
|
||||
#[error(transparent)]
|
||||
ClientMemError(Box<ClientMemError>),
|
||||
}
|
||||
efrom!(ResizeError, ParseError, MsgParserError);
|
||||
efrom!(ResizeError, ClientMemError);
|
||||
|
||||
pub(super) struct CreateBuffer {
|
||||
pub id: WlBufferId,
|
||||
pub offset: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub stride: i32,
|
||||
pub format: u32,
|
||||
}
|
||||
impl RequestParser<'_> for CreateBuffer {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
offset: parser.int()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
stride: parser.int()?,
|
||||
format: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateBuffer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"create_buffer(id: {}, offset: {}, width: {}, height: {}, stride: {}, format: {})",
|
||||
self.id, self.offset, self.width, self.height, self.stride, self.format,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()",)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Resize {
|
||||
pub size: i32,
|
||||
}
|
||||
impl RequestParser<'_> for Resize {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
size: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Resize {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "resize(size: {})", self.size,)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,18 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_surface::wl_subsurface::WlSubsurface;
|
||||
use crate::ifs::wl_surface::wl_subsurface::{WlSubsurface, WlSubsurfaceError};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const GET_SUBSURFACE: u32 = 1;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_subcompositor::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlSubcompositorId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const BAD_SURFACE: u32 = 0;
|
||||
|
||||
id!(WlSubcompositorId);
|
||||
|
||||
pub struct WlSubcompositorGlobal {
|
||||
name: GlobalName,
|
||||
}
|
||||
|
|
@ -91,3 +88,37 @@ impl Object for WlSubcompositor {
|
|||
}
|
||||
|
||||
simple_add_obj!(WlSubcompositor);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSubcompositorError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `get_subsurface` request")]
|
||||
GetSubsurfaceError(#[from] GetSubsurfaceError),
|
||||
}
|
||||
efrom!(WlSubcompositorError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetSubsurfaceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
SubsurfaceError(Box<WlSubsurfaceError>),
|
||||
}
|
||||
efrom!(GetSubsurfaceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetSubsurfaceError, ClientError);
|
||||
efrom!(GetSubsurfaceError, SubsurfaceError, WlSubsurfaceError);
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::ifs::wl_surface::wl_subsurface::{WlSubsurfaceError, WlSubsurfaceId};
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSubcompositorError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `get_subsurface` request")]
|
||||
GetSubsurfaceError(#[from] GetSubsurfaceError),
|
||||
}
|
||||
efrom!(WlSubcompositorError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetSubsurfaceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
SubsurfaceError(Box<WlSubsurfaceError>),
|
||||
}
|
||||
efrom!(GetSubsurfaceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetSubsurfaceError, ClientError);
|
||||
efrom!(GetSubsurfaceError, SubsurfaceError, WlSubsurfaceError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetSubsurface {
|
||||
pub id: WlSubsurfaceId,
|
||||
pub surface: WlSurfaceId,
|
||||
pub parent: WlSurfaceId,
|
||||
}
|
||||
impl RequestParser<'_> for GetSubsurface {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
surface: parser.object()?,
|
||||
parent: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetSubsurface {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"get_subsurface(id: {}, surface: {}, parent: {})",
|
||||
self.id, self.surface, self.parent,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,16 @@
|
|||
pub mod cursor;
|
||||
mod types;
|
||||
pub mod wl_subsurface;
|
||||
pub mod xdg_surface;
|
||||
|
||||
use crate::backend::{KeyState, ScrollAxis, SeatId};
|
||||
use crate::client::{Client, DynEventFormatter, RequestParser};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter, RequestParser};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_buffer::WlBuffer;
|
||||
use crate::ifs::wl_callback::WlCallback;
|
||||
use crate::ifs::wl_output::WlOutputId;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::cursor::CursorSurface;
|
||||
use crate::ifs::wl_surface::wl_subsurface::WlSubsurface;
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceRole};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceRole};
|
||||
use crate::object::Object;
|
||||
use crate::pixman::Region;
|
||||
use crate::rect::Rect;
|
||||
|
|
@ -29,23 +27,9 @@ use std::cell::{Cell, RefCell};
|
|||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const ATTACH: u32 = 1;
|
||||
const DAMAGE: u32 = 2;
|
||||
const FRAME: u32 = 3;
|
||||
const SET_OPAQUE_REGION: u32 = 4;
|
||||
const SET_INPUT_REGION: u32 = 5;
|
||||
const COMMIT: u32 = 6;
|
||||
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;
|
||||
use thiserror::Error;
|
||||
use crate::wire::wl_surface::*;
|
||||
use crate::wire::{WlOutputId, WlSurfaceId};
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_SCALE: u32 = 0;
|
||||
|
|
@ -54,8 +38,6 @@ const INVALID_TRANSFORM: u32 = 1;
|
|||
#[allow(dead_code)]
|
||||
const INVALID_SIZE: u32 = 2;
|
||||
|
||||
id!(WlSurfaceId);
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum SurfaceRole {
|
||||
None,
|
||||
|
|
@ -232,7 +214,7 @@ impl WlSurface {
|
|||
|
||||
fn enter_event(self: &Rc<Self>, output: WlOutputId) -> DynEventFormatter {
|
||||
Box::new(Enter {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
output,
|
||||
})
|
||||
}
|
||||
|
|
@ -652,3 +634,146 @@ impl Node for WlSurface {
|
|||
Some(self.client.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSurfaceError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
XdgSurfaceError(Box<XdgSurfaceError>),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[source] Box<DestroyError>),
|
||||
#[error("Could not process `attach` request")]
|
||||
AttachError(#[source] Box<AttachError>),
|
||||
#[error("Could not process `damage` request")]
|
||||
DamageError(#[source] Box<DamageError>),
|
||||
#[error("Could not process `frame` request")]
|
||||
FrameError(#[source] Box<FrameError>),
|
||||
#[error("Could not process `set_opaque_region` request")]
|
||||
SetOpaqueRegionError(#[source] Box<SetOpaqueRegionError>),
|
||||
#[error("Could not process `set_input_region` request")]
|
||||
SetInputRegionError(#[source] Box<SetInputRegionError>),
|
||||
#[error("Could not process `commit` request")]
|
||||
CommitError(#[source] Box<CommitError>),
|
||||
#[error("Could not process `set_buffer_transform` request")]
|
||||
SetBufferTransformError(#[source] Box<SetBufferTransformError>),
|
||||
#[error("Could not process `set_buffer_scale_error` request")]
|
||||
SetBufferScaleError(#[source] Box<SetBufferScaleError>),
|
||||
#[error("Could not process `damage_buffer` request")]
|
||||
DamageBufferError(#[source] Box<DamageBufferError>),
|
||||
#[error("Surface {} cannot be assigned the role {} because it already has the role {}", .id, .new.name(), .old.name())]
|
||||
IncompatibleRole {
|
||||
id: WlSurfaceId,
|
||||
old: SurfaceRole,
|
||||
new: SurfaceRole,
|
||||
},
|
||||
}
|
||||
efrom!(WlSurfaceError, ClientError);
|
||||
efrom!(WlSurfaceError, XdgSurfaceError);
|
||||
efrom!(WlSurfaceError, DestroyError);
|
||||
efrom!(WlSurfaceError, AttachError);
|
||||
efrom!(WlSurfaceError, DamageError);
|
||||
efrom!(WlSurfaceError, FrameError);
|
||||
efrom!(WlSurfaceError, SetOpaqueRegionError);
|
||||
efrom!(WlSurfaceError, SetInputRegionError);
|
||||
efrom!(WlSurfaceError, CommitError);
|
||||
efrom!(
|
||||
WlSurfaceError,
|
||||
SetBufferTransformError,
|
||||
SetBufferTransformError
|
||||
);
|
||||
efrom!(WlSurfaceError, SetBufferScaleError);
|
||||
efrom!(WlSurfaceError, DamageBufferError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Cannot destroy a `wl_surface` before its role object")]
|
||||
ReloObjectStillExists,
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AttachError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(AttachError, ParseFailed, MsgParserError);
|
||||
efrom!(AttachError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DamageError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(DamageError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FrameError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(FrameError, ParseFailed, MsgParserError);
|
||||
efrom!(FrameError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetOpaqueRegionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetOpaqueRegionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetOpaqueRegionError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetInputRegionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetInputRegionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetInputRegionError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CommitError {
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CommitError, WlSurfaceError);
|
||||
efrom!(CommitError, ParseFailed, MsgParserError);
|
||||
efrom!(CommitError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetBufferTransformError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetBufferTransformError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetBufferScaleError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetBufferScaleError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DamageBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(DamageBufferError, ParseFailed, MsgParserError);
|
||||
|
|
@ -1,353 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_callback::WlCallbackId;
|
||||
use crate::ifs::wl_output::WlOutputId;
|
||||
use crate::ifs::wl_region::WlRegionId;
|
||||
use crate::ifs::wl_surface::xdg_surface::XdgSurfaceError;
|
||||
use crate::ifs::wl_surface::{SurfaceRole, WlSurface, WlSurfaceId, ENTER};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSurfaceError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
XdgSurfaceError(Box<XdgSurfaceError>),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[source] Box<DestroyError>),
|
||||
#[error("Could not process `attach` request")]
|
||||
AttachError(#[source] Box<AttachError>),
|
||||
#[error("Could not process `damage` request")]
|
||||
DamageError(#[source] Box<DamageError>),
|
||||
#[error("Could not process `frame` request")]
|
||||
FrameError(#[source] Box<FrameError>),
|
||||
#[error("Could not process `set_opaque_region` request")]
|
||||
SetOpaqueRegionError(#[source] Box<SetOpaqueRegionError>),
|
||||
#[error("Could not process `set_input_region` request")]
|
||||
SetInputRegionError(#[source] Box<SetInputRegionError>),
|
||||
#[error("Could not process `commit` request")]
|
||||
CommitError(#[source] Box<CommitError>),
|
||||
#[error("Could not process `set_buffer_transform` request")]
|
||||
SetBufferTransformError(#[source] Box<SetBufferTransformError>),
|
||||
#[error("Could not process `set_buffer_scale_error` request")]
|
||||
SetBufferScaleError(#[source] Box<SetBufferScaleError>),
|
||||
#[error("Could not process `damage_buffer` request")]
|
||||
DamageBufferError(#[source] Box<DamageBufferError>),
|
||||
#[error("Surface {} cannot be assigned the role {} because it already has the role {}", .id, .new.name(), .old.name())]
|
||||
IncompatibleRole {
|
||||
id: WlSurfaceId,
|
||||
old: SurfaceRole,
|
||||
new: SurfaceRole,
|
||||
},
|
||||
}
|
||||
efrom!(WlSurfaceError, ClientError);
|
||||
efrom!(WlSurfaceError, XdgSurfaceError);
|
||||
efrom!(WlSurfaceError, DestroyError);
|
||||
efrom!(WlSurfaceError, AttachError);
|
||||
efrom!(WlSurfaceError, DamageError);
|
||||
efrom!(WlSurfaceError, FrameError);
|
||||
efrom!(WlSurfaceError, SetOpaqueRegionError);
|
||||
efrom!(WlSurfaceError, SetInputRegionError);
|
||||
efrom!(WlSurfaceError, CommitError);
|
||||
efrom!(
|
||||
WlSurfaceError,
|
||||
SetBufferTransformError,
|
||||
SetBufferTransformError
|
||||
);
|
||||
efrom!(WlSurfaceError, SetBufferScaleError);
|
||||
efrom!(WlSurfaceError, DamageBufferError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Cannot destroy a `wl_surface` before its role object")]
|
||||
ReloObjectStillExists,
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AttachError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(AttachError, ParseFailed, MsgParserError);
|
||||
efrom!(AttachError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DamageError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(DamageError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FrameError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(FrameError, ParseFailed, MsgParserError);
|
||||
efrom!(FrameError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetOpaqueRegionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetOpaqueRegionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetOpaqueRegionError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetInputRegionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetInputRegionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetInputRegionError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CommitError {
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CommitError, WlSurfaceError);
|
||||
efrom!(CommitError, ParseFailed, MsgParserError);
|
||||
efrom!(CommitError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetBufferTransformError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetBufferTransformError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetBufferScaleError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetBufferScaleError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DamageBufferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(DamageBufferError, ParseFailed, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Attach {
|
||||
pub buffer: crate::ifs::wl_buffer::WlBufferId,
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
}
|
||||
impl RequestParser<'_> for Attach {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
buffer: parser.object()?,
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Attach {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"attach(buffer: {}, x: {}, y: {})",
|
||||
self.buffer, self.x, self.y
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Damage {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for Damage {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Damage {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"damage(x: {}, y: {}, width: {}, height: {})",
|
||||
self.x, self.y, self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Frame {
|
||||
pub callback: WlCallbackId,
|
||||
}
|
||||
impl RequestParser<'_> for Frame {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
callback: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Frame {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "frame(callback: {})", self.callback)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetOpaqueRegion {
|
||||
pub region: WlRegionId,
|
||||
}
|
||||
impl RequestParser<'_> for SetOpaqueRegion {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
region: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetOpaqueRegion {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_opaque_region(region: {})", self.region)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetInputRegion {
|
||||
pub region: WlRegionId,
|
||||
}
|
||||
impl RequestParser<'_> for SetInputRegion {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
region: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetInputRegion {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_input_region(region: {})", self.region)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Commit;
|
||||
impl RequestParser<'_> for Commit {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Commit {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "commit()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetBufferTransform {
|
||||
pub transform: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetBufferTransform {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
transform: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetBufferTransform {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_buffer_transform(transform: {})", self.transform)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetBufferScale {
|
||||
pub scale: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetBufferScale {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
scale: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetBufferScale {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_buffer_scale(scale: {})", self.scale)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DamageBuffer {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for DamageBuffer {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for DamageBuffer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"damage_buffer(x: {}, y: {}, width: {}, height: {})",
|
||||
self.x, self.y, self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Enter {
|
||||
pub obj: Rc<WlSurface>,
|
||||
pub output: WlOutputId,
|
||||
}
|
||||
impl EventFormatter for Enter {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, ENTER).object(self.output);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Enter {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "enter(output: {})", self.output)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
mod types;
|
||||
|
||||
use crate::ifs::wl_surface::{
|
||||
CommitAction, CommitContext, StackElement, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
|
|
@ -12,22 +11,17 @@ use crate::NumCell;
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const SET_POSITION: u32 = 1;
|
||||
const PLACE_ABOVE: u32 = 2;
|
||||
const PLACE_BELOW: u32 = 3;
|
||||
const SET_SYNC: u32 = 4;
|
||||
const SET_DESYNC: u32 = 5;
|
||||
use thiserror::Error;
|
||||
use crate::client::ClientError;
|
||||
use crate::wire::wl_subsurface::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::WlSubsurfaceId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const BAD_SURFACE: u32 = 0;
|
||||
|
||||
const MAX_SUBSURFACE_DEPTH: u32 = 100;
|
||||
|
||||
id!(WlSubsurfaceId);
|
||||
|
||||
pub struct WlSubsurface {
|
||||
id: WlSubsurfaceId,
|
||||
pub surface: Rc<WlSurface>,
|
||||
|
|
@ -295,3 +289,87 @@ impl SurfaceExt for WlSubsurface {
|
|||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSubsurfaceError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `set_position` request")]
|
||||
SetPosition(#[from] SetPositionError),
|
||||
#[error("Could not process `place_above` request")]
|
||||
PlaceAbove(#[from] PlaceAboveError),
|
||||
#[error("Could not process `place_below` request")]
|
||||
PlaceBelow(#[from] PlaceBelowError),
|
||||
#[error("Could not process `set_sync` request")]
|
||||
SetSync(#[from] SetSyncError),
|
||||
#[error("Could not process `set_desync` request")]
|
||||
SetDesync(#[from] SetDesyncError),
|
||||
#[error("Surface {0} already has an attached `wl_subsurface`")]
|
||||
AlreadyAttached(WlSurfaceId),
|
||||
#[error("Surface {0} cannot be made its own parent")]
|
||||
OwnParent(WlSurfaceId),
|
||||
#[error("Surface {0} cannot be made a subsurface of {1} because it's an ancestor of {1}")]
|
||||
Ancestor(WlSurfaceId, WlSurfaceId),
|
||||
#[error("Subsurfaces cannot be nested deeper than 100 levels")]
|
||||
MaxDepthExceeded,
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
}
|
||||
efrom!(WlSubsurfaceError, WlSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetPositionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetPositionError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PlaceAboveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
PlacementError(#[from] PlacementError),
|
||||
}
|
||||
efrom!(PlaceAboveError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PlacementError {
|
||||
#[error("Cannot place {0} above/below itself")]
|
||||
AboveSelf(WlSurfaceId),
|
||||
#[error("{0} is not a sibling of {1}")]
|
||||
NotASibling(WlSurfaceId, WlSurfaceId),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PlaceBelowError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
PlacementError(#[from] PlacementError),
|
||||
}
|
||||
efrom!(PlaceBelowError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSyncError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetSyncError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetDesyncError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetDesyncError, ParseFailed, MsgParserError);
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::ifs::wl_surface::{WlSurfaceError, WlSurfaceId};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSubsurfaceError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `set_position` request")]
|
||||
SetPosition(#[from] SetPositionError),
|
||||
#[error("Could not process `place_above` request")]
|
||||
PlaceAbove(#[from] PlaceAboveError),
|
||||
#[error("Could not process `place_below` request")]
|
||||
PlaceBelow(#[from] PlaceBelowError),
|
||||
#[error("Could not process `set_sync` request")]
|
||||
SetSync(#[from] SetSyncError),
|
||||
#[error("Could not process `set_desync` request")]
|
||||
SetDesync(#[from] SetDesyncError),
|
||||
#[error("Surface {0} already has an attached `wl_subsurface`")]
|
||||
AlreadyAttached(WlSurfaceId),
|
||||
#[error("Surface {0} cannot be made its own parent")]
|
||||
OwnParent(WlSurfaceId),
|
||||
#[error("Surface {0} cannot be made a subsurface of {1} because it's an ancestor of {1}")]
|
||||
Ancestor(WlSurfaceId, WlSurfaceId),
|
||||
#[error("Subsurfaces cannot be nested deeper than 100 levels")]
|
||||
MaxDepthExceeded,
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
}
|
||||
efrom!(WlSubsurfaceError, WlSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetPositionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetPositionError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PlaceAboveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
PlacementError(#[from] PlacementError),
|
||||
}
|
||||
efrom!(PlaceAboveError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PlacementError {
|
||||
#[error("Cannot place {0} above/below itself")]
|
||||
AboveSelf(WlSurfaceId),
|
||||
#[error("{0} is not a sibling of {1}")]
|
||||
NotASibling(WlSurfaceId, WlSurfaceId),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PlaceBelowError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
PlacementError(#[from] PlacementError),
|
||||
}
|
||||
efrom!(PlaceBelowError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSyncError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetSyncError, ParseFailed, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetDesyncError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetDesyncError, ParseFailed, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetPosition {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetPosition {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetPosition {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_position(x: {}, y: {})", self.x, self.y)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct PlaceAbove {
|
||||
pub sibling: WlSurfaceId,
|
||||
}
|
||||
impl RequestParser<'_> for PlaceAbove {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
sibling: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for PlaceAbove {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "place_above(sibling: {})", self.sibling,)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct PlaceBelow {
|
||||
pub sibling: WlSurfaceId,
|
||||
}
|
||||
impl RequestParser<'_> for PlaceBelow {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
sibling: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for PlaceBelow {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "place_below(sibling: {})", self.sibling,)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetSync;
|
||||
impl RequestParser<'_> for SetSync {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for SetSync {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_sync()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetDesync;
|
||||
impl RequestParser<'_> for SetDesync {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for SetDesync {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_desync()")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,388 +0,0 @@
|
|||
mod types;
|
||||
pub mod xdg_popup;
|
||||
pub mod xdg_toplevel;
|
||||
|
||||
use crate::backend::SeatId;
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::{XdgPopup, XdgPopupId};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::ifs::wl_surface::{
|
||||
CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
};
|
||||
use crate::ifs::xdg_wm_base::XdgWmBase;
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::tree::{FindTreeResult, FoundNode, Node, WorkspaceNode};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::copyhashmap::CopyHashMap;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::NumCell;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const GET_TOPLEVEL: u32 = 1;
|
||||
const GET_POPUP: u32 = 2;
|
||||
const SET_WINDOW_GEOMETRY: u32 = 3;
|
||||
const ACK_CONFIGURE: u32 = 4;
|
||||
|
||||
const CONFIGURE: u32 = 0;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const NOT_CONSTRUCTED: u32 = 1;
|
||||
const ALREADY_CONSTRUCTED: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const UNCONFIGURED_BUFFER: u32 = 3;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum XdgSurfaceRole {
|
||||
None,
|
||||
XdgPopup,
|
||||
XdgToplevel,
|
||||
}
|
||||
|
||||
impl XdgSurfaceRole {
|
||||
fn name(self) -> &'static str {
|
||||
match self {
|
||||
XdgSurfaceRole::None => "none",
|
||||
XdgSurfaceRole::XdgPopup => "xdg_popup",
|
||||
XdgSurfaceRole::XdgToplevel => "xdg_toplevel",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
id!(XdgSurfaceId);
|
||||
|
||||
pub struct XdgSurface {
|
||||
id: XdgSurfaceId,
|
||||
base: Rc<XdgWmBase>,
|
||||
role: Cell<XdgSurfaceRole>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
requested_serial: NumCell<u32>,
|
||||
acked_serial: Cell<Option<u32>>,
|
||||
geometry: Cell<Option<Rect>>,
|
||||
extents: Cell<Rect>,
|
||||
pub absolute_desired_extents: Cell<Rect>,
|
||||
ext: CloneCell<Option<Rc<dyn XdgSurfaceExt>>>,
|
||||
popups: CopyHashMap<XdgPopupId, Rc<XdgPopup>>,
|
||||
pending: PendingXdgSurfaceData,
|
||||
pub(super) focus_surface: SmallMap<SeatId, Rc<WlSurface>, 1>,
|
||||
seat_state: NodeSeatState,
|
||||
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct PendingXdgSurfaceData {
|
||||
geometry: Cell<Option<Rect>>,
|
||||
}
|
||||
|
||||
trait XdgSurfaceExt {
|
||||
fn initial_configure(self: Rc<Self>) -> Result<(), XdgSurfaceError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn into_node(self: Rc<Self>) -> Option<Rc<dyn Node>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn extents_changed(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn surface_active_changed(self: Rc<Self>, active: bool) {
|
||||
let _ = active;
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgSurface {
|
||||
pub fn new(wm_base: &Rc<XdgWmBase>, id: XdgSurfaceId, surface: &Rc<WlSurface>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
base: wm_base.clone(),
|
||||
role: Cell::new(XdgSurfaceRole::None),
|
||||
surface: surface.clone(),
|
||||
requested_serial: NumCell::new(0),
|
||||
acked_serial: Cell::new(None),
|
||||
geometry: Cell::new(None),
|
||||
extents: Cell::new(Default::default()),
|
||||
absolute_desired_extents: Cell::new(Default::default()),
|
||||
ext: Default::default(),
|
||||
popups: Default::default(),
|
||||
pending: Default::default(),
|
||||
focus_surface: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
workspace: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_absolute_desired_extents(&self, ext: &Rect) {
|
||||
let prev = self.absolute_desired_extents.replace(*ext);
|
||||
if ext.x1() != prev.x1() || ext.y1() != prev.y1() {
|
||||
let (mut x1, mut y1) = (ext.x1(), ext.y1());
|
||||
if let Some(geo) = self.geometry.get() {
|
||||
x1 -= geo.x1();
|
||||
y1 -= geo.y1();
|
||||
}
|
||||
self.surface.set_absolute_position(x1, y1);
|
||||
self.update_popup_positions();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn surface_active_changed(&self, active: bool) {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.surface_active_changed(active);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn role(&self) -> XdgSurfaceRole {
|
||||
self.role.get()
|
||||
}
|
||||
|
||||
fn set_workspace(&self, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
let pu = self.popups.lock();
|
||||
for pu in pu.values() {
|
||||
pu.xdg.set_workspace(ws);
|
||||
}
|
||||
}
|
||||
|
||||
fn set_role(&self, role: XdgSurfaceRole) -> Result<(), XdgSurfaceError> {
|
||||
use XdgSurfaceRole::*;
|
||||
match (self.role.get(), role) {
|
||||
(None, _) => {}
|
||||
(old, new) if old == new => {}
|
||||
(old, new) => {
|
||||
return Err(XdgSurfaceError::IncompatibleRole {
|
||||
id: self.id,
|
||||
old,
|
||||
new,
|
||||
})
|
||||
}
|
||||
}
|
||||
self.role.set(role);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn focus_surface(&self, seat: &WlSeatGlobal) -> Rc<WlSurface> {
|
||||
self.focus_surface
|
||||
.get(&seat.id())
|
||||
.unwrap_or_else(|| self.surface.clone())
|
||||
}
|
||||
|
||||
fn destroy_node(&self) {
|
||||
self.workspace.set(None);
|
||||
self.surface.destroy_node(false);
|
||||
let popups = self.popups.lock();
|
||||
for popup in popups.values() {
|
||||
popup.destroy_node(true);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn geometry(&self) -> Option<Rect> {
|
||||
self.geometry.get()
|
||||
}
|
||||
|
||||
pub fn send_configure(self: &Rc<Self>) {
|
||||
let serial = self.requested_serial.fetch_add(1) + 1;
|
||||
self.surface.client.event(self.configure(serial));
|
||||
}
|
||||
|
||||
pub fn configure(self: &Rc<Self>, serial: u32) -> DynEventFormatter {
|
||||
Box::new(Configure {
|
||||
obj: self.clone(),
|
||||
serial,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn install(self: &Rc<Self>) -> Result<(), XdgSurfaceError> {
|
||||
self.surface.set_role(SurfaceRole::XdgSurface)?;
|
||||
if self.surface.ext.get().is_some() {
|
||||
return Err(XdgSurfaceError::AlreadyAttached(self.surface.id));
|
||||
}
|
||||
self.surface.ext.set(self.clone());
|
||||
self.surface.set_xdg_surface(Some(self.clone()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.surface.client.parse(self, parser)?;
|
||||
if self.ext.get().is_some() {
|
||||
return Err(DestroyError::RoleNotYetDestroyed(self.id));
|
||||
}
|
||||
{
|
||||
let children = self.popups.lock();
|
||||
if !children.is_empty() {
|
||||
return Err(DestroyError::PopupsNotYetDestroyed);
|
||||
}
|
||||
}
|
||||
self.surface.set_xdg_surface(None);
|
||||
self.surface.unset_ext();
|
||||
self.base.surfaces.remove(&self.id);
|
||||
self.surface.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_toplevel(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), GetToplevelError> {
|
||||
let req: GetToplevel = self.surface.client.parse(&**self, parser)?;
|
||||
self.set_role(XdgSurfaceRole::XdgToplevel)?;
|
||||
if self.ext.get().is_some() {
|
||||
self.surface.client.protocol_error(
|
||||
&**self,
|
||||
ALREADY_CONSTRUCTED,
|
||||
format!(
|
||||
"wl_surface {} already has an assigned xdg_toplevel",
|
||||
self.surface.id
|
||||
),
|
||||
);
|
||||
return Err(GetToplevelError::AlreadyConstructed);
|
||||
}
|
||||
let toplevel = Rc::new(XdgToplevel::new(req.id, self));
|
||||
self.surface.client.add_client_obj(&toplevel)?;
|
||||
self.ext.set(Some(toplevel));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_popup(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), GetPopupError> {
|
||||
let req: GetPopup = self.surface.client.parse(&**self, parser)?;
|
||||
self.set_role(XdgSurfaceRole::XdgPopup)?;
|
||||
let mut parent = None;
|
||||
if req.parent.is_some() {
|
||||
parent = Some(self.surface.client.lookup(req.parent)?);
|
||||
}
|
||||
let positioner = self.surface.client.lookup(req.positioner)?;
|
||||
if self.ext.get().is_some() {
|
||||
self.surface.client.protocol_error(
|
||||
&**self,
|
||||
ALREADY_CONSTRUCTED,
|
||||
format!(
|
||||
"wl_surface {} already has an assigned xdg_popup",
|
||||
self.surface.id
|
||||
),
|
||||
);
|
||||
return Err(GetPopupError::AlreadyConstructed);
|
||||
}
|
||||
let popup = Rc::new(XdgPopup::new(req.id, self, parent.as_ref(), &positioner)?);
|
||||
self.surface.client.add_client_obj(&popup)?;
|
||||
if let Some(parent) = &parent {
|
||||
parent.popups.set(req.id, popup.clone());
|
||||
}
|
||||
self.ext.set(Some(popup));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_window_geometry(&self, parser: MsgParser<'_, '_>) -> Result<(), SetWindowGeometryError> {
|
||||
let req: SetWindowGeometry = self.surface.client.parse(self, parser)?;
|
||||
if req.height <= 0 || req.width <= 0 {
|
||||
return Err(SetWindowGeometryError::NonPositiveWidthHeight);
|
||||
}
|
||||
let extents = Rect::new_sized(req.x, req.y, req.width, req.height).unwrap();
|
||||
self.pending.geometry.set(Some(extents));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ack_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), AckConfigureError> {
|
||||
let req: AckConfigure = self.surface.client.parse(self, parser)?;
|
||||
if self.requested_serial.get() == req.serial {
|
||||
self.acked_serial.set(Some(req.serial));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_extents(&self) {
|
||||
let old_extents = self.extents.get();
|
||||
let mut new_extents = self.surface.extents.get();
|
||||
if let Some(geometry) = self.geometry.get() {
|
||||
new_extents = new_extents.intersect(geometry);
|
||||
}
|
||||
self.extents.set(new_extents);
|
||||
if old_extents != new_extents {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.extents_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, mut x: i32, mut y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
if let Some(geo) = self.geometry.get() {
|
||||
let (xt, yt) = geo.translate_inv(x, y);
|
||||
x = xt;
|
||||
y = yt;
|
||||
}
|
||||
match self.surface.find_surface_at(x, y) {
|
||||
Some((node, x, y)) => {
|
||||
tree.push(FoundNode { node, x, y });
|
||||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
_ => FindTreeResult::Other,
|
||||
}
|
||||
}
|
||||
|
||||
fn update_popup_positions(&self) {
|
||||
let popups = self.popups.lock();
|
||||
for popup in popups.values() {
|
||||
popup.update_absolute_position();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
XdgSurface, XdgSurfaceError;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_TOPLEVEL => get_toplevel,
|
||||
GET_POPUP => get_popup,
|
||||
SET_WINDOW_GEOMETRY => set_window_geometry,
|
||||
ACK_CONFIGURE => ack_configure,
|
||||
}
|
||||
|
||||
impl Object for XdgSurface {
|
||||
fn num_requests(&self) -> u32 {
|
||||
ACK_CONFIGURE + 1
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.focus_surface.take();
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(XdgSurface, XdgSurfaceId, xdg_surfaces);
|
||||
|
||||
impl SurfaceExt for XdgSurface {
|
||||
fn pre_commit(self: Rc<Self>, _ctx: CommitContext) -> Result<CommitAction, WlSurfaceError> {
|
||||
{
|
||||
let ase = self.acked_serial.get();
|
||||
let rse = self.requested_serial.get();
|
||||
if ase != Some(rse) {
|
||||
if ase.is_none() {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.initial_configure()?;
|
||||
}
|
||||
self.surface.client.event(self.configure(rse));
|
||||
}
|
||||
// return CommitAction::AbortCommit;
|
||||
}
|
||||
}
|
||||
if let Some(geometry) = self.pending.geometry.take() {
|
||||
self.geometry.set(Some(geometry));
|
||||
self.update_extents();
|
||||
}
|
||||
Ok(CommitAction::ContinueCommit)
|
||||
}
|
||||
|
||||
fn post_commit(&self) {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.post_commit();
|
||||
}
|
||||
}
|
||||
|
||||
fn extents_changed(&self) {
|
||||
self.update_extents();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,226 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::{XdgPopupError, XdgPopupId};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevelId;
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceId, XdgSurfaceRole, CONFIGURE};
|
||||
use crate::ifs::wl_surface::{WlSurfaceError, WlSurfaceId};
|
||||
use crate::ifs::xdg_positioner::XdgPositionerId;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgSurfaceError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `get_toplevel` request")]
|
||||
GetToplevelError(#[from] GetToplevelError),
|
||||
#[error("Could not process `get_popup` request")]
|
||||
GetPopupError(#[from] GetPopupError),
|
||||
#[error("Could not process `set_window_geometry` request")]
|
||||
SetWindowGeometryError(#[from] SetWindowGeometryError),
|
||||
#[error("Could not process `ack_configure` request")]
|
||||
AckConfigureError(#[from] AckConfigureError),
|
||||
#[error("Surface {0} cannot be turned into a xdg_surface because it already has an attached xdg_surface")]
|
||||
AlreadyAttached(WlSurfaceId),
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
#[error(transparent)]
|
||||
XdgPopupError(#[from] XdgPopupError),
|
||||
#[error("Surface {} cannot be assigned the role {} because it already has the role {}", .id, .new.name(), .old.name())]
|
||||
IncompatibleRole {
|
||||
id: XdgSurfaceId,
|
||||
old: XdgSurfaceRole,
|
||||
new: XdgSurfaceRole,
|
||||
},
|
||||
}
|
||||
efrom!(XdgSurfaceError, WlSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Cannot destroy xdg_surface {0} because it's associated xdg_toplevel/popup is not yet destroyed")]
|
||||
RoleNotYetDestroyed(XdgSurfaceId),
|
||||
#[error("The surface still has popups attached")]
|
||||
PopupsNotYetDestroyed,
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetToplevelError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The surface already has an assigned xdg_toplevel")]
|
||||
AlreadyConstructed,
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
#[error(transparent)]
|
||||
XdgSurfaceError(Box<XdgSurfaceError>),
|
||||
}
|
||||
efrom!(GetToplevelError, ParseFailed, MsgParserError);
|
||||
efrom!(GetToplevelError, ClientError);
|
||||
efrom!(GetToplevelError, WlSurfaceError);
|
||||
efrom!(GetToplevelError, XdgSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetPopupError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The surface already has an assigned xdg_popup")]
|
||||
AlreadyConstructed,
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
#[error(transparent)]
|
||||
XdgPopupError(Box<XdgPopupError>),
|
||||
#[error(transparent)]
|
||||
XdgSurfaceError(Box<XdgSurfaceError>),
|
||||
}
|
||||
efrom!(GetPopupError, ParseFailed, MsgParserError);
|
||||
efrom!(GetPopupError, ClientError);
|
||||
efrom!(GetPopupError, XdgPopupError);
|
||||
efrom!(GetPopupError, WlSurfaceError);
|
||||
efrom!(GetPopupError, XdgSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetWindowGeometryError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Tried no set a non-positive width/height")]
|
||||
NonPositiveWidthHeight,
|
||||
}
|
||||
efrom!(SetWindowGeometryError, ParseFailed, MsgParserError);
|
||||
efrom!(SetWindowGeometryError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AckConfigureError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(AckConfigureError, ParseFailed, MsgParserError);
|
||||
efrom!(AckConfigureError, ClientError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetToplevel {
|
||||
pub id: XdgToplevelId,
|
||||
}
|
||||
impl RequestParser<'_> for GetToplevel {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetToplevel {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_toplevel(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetPopup {
|
||||
pub id: XdgPopupId,
|
||||
pub parent: XdgSurfaceId,
|
||||
pub positioner: XdgPositionerId,
|
||||
}
|
||||
impl RequestParser<'_> for GetPopup {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
parent: parser.object()?,
|
||||
positioner: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetPopup {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"get_popup(id: {}, parent: {}, positioner: {})",
|
||||
self.id, self.parent, self.positioner
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetWindowGeometry {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetWindowGeometry {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetWindowGeometry {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_window_geometry(x: {}, y: {}, width: {}, height: {})",
|
||||
self.x, self.y, self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct AckConfigure {
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for AckConfigure {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for AckConfigure {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "ack_configure(serial: {})", self.serial)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Configure {
|
||||
pub obj: Rc<XdgSurface>,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl EventFormatter for Configure {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CONFIGURE).uint(self.serial);
|
||||
}
|
||||
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Configure {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "configure(serial: {})", self.serial)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
|
|
@ -15,21 +14,15 @@ use crate::utils::clonecell::CloneCell;
|
|||
use crate::utils::linkedlist::LinkedNode;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const GRAB: u32 = 1;
|
||||
const REPOSITION: u32 = 2;
|
||||
|
||||
const CONFIGURE: u32 = 0;
|
||||
const POPUP_DONE: u32 = 1;
|
||||
const REPOSITIONED: u32 = 2;
|
||||
use thiserror::Error;
|
||||
use crate::wire::xdg_popup::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::XdgPopupId;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_GRAB: u32 = 1;
|
||||
|
||||
tree_id!(PopupId);
|
||||
id!(XdgPopupId);
|
||||
|
||||
pub struct XdgPopup {
|
||||
id: XdgPopupId,
|
||||
|
|
@ -67,7 +60,7 @@ impl XdgPopup {
|
|||
|
||||
fn configure(self: &Rc<Self>, x: i32, y: i32, width: i32, height: i32) -> DynEventFormatter {
|
||||
Box::new(Configure {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
|
|
@ -77,13 +70,13 @@ impl XdgPopup {
|
|||
|
||||
fn repositioned(self: &Rc<Self>, token: u32) -> DynEventFormatter {
|
||||
Box::new(Repositioned {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
token,
|
||||
})
|
||||
}
|
||||
|
||||
fn popup_done(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(PopupDone { obj: self.clone() })
|
||||
Box::new(PopupDone { self_id: self.id })
|
||||
}
|
||||
|
||||
fn update_position(&self, parent: &XdgSurface) -> Result<(), XdgPopupError> {
|
||||
|
|
@ -355,3 +348,51 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
self.xdg.surface.client.state.tree_changed();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgPopupError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `grab` request")]
|
||||
GrabError(#[from] GrabError),
|
||||
#[error("Could not process `reposition` request")]
|
||||
RepositionError(#[from] RepositionError),
|
||||
#[error("The `xdg_positioner` is incomplete")]
|
||||
Incomplete,
|
||||
#[error("The anchor rectangle of the `xdg_positioner` extends outside the parent")]
|
||||
#[allow(dead_code)]
|
||||
AnchorRectOutside,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GrabError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GrabError, ParseFailed, MsgParserError);
|
||||
efrom!(GrabError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum RepositionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
XdgPopupError(Box<XdgPopupError>),
|
||||
}
|
||||
efrom!(RepositionError, ParseFailed, MsgParserError);
|
||||
efrom!(RepositionError, ClientError);
|
||||
efrom!(RepositionError, XdgPopupError);
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_seat::WlSeatId;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::{
|
||||
XdgPopup, CONFIGURE, POPUP_DONE, REPOSITIONED,
|
||||
};
|
||||
use crate::ifs::xdg_positioner::XdgPositionerId;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgPopupError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `grab` request")]
|
||||
GrabError(#[from] GrabError),
|
||||
#[error("Could not process `reposition` request")]
|
||||
RepositionError(#[from] RepositionError),
|
||||
#[error("The `xdg_positioner` is incomplete")]
|
||||
Incomplete,
|
||||
#[error("The anchor rectangle of the `xdg_positioner` extends outside the parent")]
|
||||
#[allow(dead_code)]
|
||||
AnchorRectOutside,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GrabError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GrabError, ParseFailed, MsgParserError);
|
||||
efrom!(GrabError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum RepositionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
XdgPopupError(Box<XdgPopupError>),
|
||||
}
|
||||
efrom!(RepositionError, ParseFailed, MsgParserError);
|
||||
efrom!(RepositionError, ClientError);
|
||||
efrom!(RepositionError, XdgPopupError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Grab {
|
||||
pub seat: WlSeatId,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Grab {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
seat: parser.object()?,
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Grab {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "grab(seat: {}, serial: {})", self.seat, self.serial)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Reposition {
|
||||
pub positioner: XdgPositionerId,
|
||||
pub token: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Reposition {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
positioner: parser.object()?,
|
||||
token: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Reposition {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"reposition(positioner: {}, token: {})",
|
||||
self.positioner, self.token,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Configure {
|
||||
pub obj: Rc<XdgPopup>,
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl EventFormatter for Configure {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CONFIGURE)
|
||||
.int(self.x)
|
||||
.int(self.y)
|
||||
.int(self.width)
|
||||
.int(self.height);
|
||||
}
|
||||
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Configure {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"configure(x: {}, y: {}, width: {}, height: {})",
|
||||
self.x, self.y, self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct PopupDone {
|
||||
pub obj: Rc<XdgPopup>,
|
||||
}
|
||||
impl EventFormatter for PopupDone {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, POPUP_DONE);
|
||||
}
|
||||
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for PopupDone {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "popup_done()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Repositioned {
|
||||
pub obj: Rc<XdgPopup>,
|
||||
pub token: u32,
|
||||
}
|
||||
impl EventFormatter for Repositioned {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, REPOSITIONED).uint(self.token);
|
||||
}
|
||||
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Repositioned {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "repositioned(token: {})", self.token)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
mod types;
|
||||
|
||||
use crate::backend::SeatId;
|
||||
use crate::bugs::Bugs;
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
|
|
@ -18,30 +17,14 @@ use crate::utils::linkedlist::LinkedNode;
|
|||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::{bugs, NumCell};
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
use bstr::ByteSlice;
|
||||
use num_derive::FromPrimitive;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const SET_PARENT: u32 = 1;
|
||||
const SET_TITLE: u32 = 2;
|
||||
const SET_APP_ID: u32 = 3;
|
||||
const SHOW_WINDOW_MENU: u32 = 4;
|
||||
const MOVE: u32 = 5;
|
||||
const RESIZE: u32 = 6;
|
||||
const SET_MAX_SIZE: u32 = 7;
|
||||
const SET_MIN_SIZE: u32 = 8;
|
||||
const SET_MAXIMIZED: u32 = 9;
|
||||
const UNSET_MAXIMIZED: u32 = 10;
|
||||
const SET_FULLSCREEN: u32 = 11;
|
||||
const UNSET_FULLSCREEN: u32 = 12;
|
||||
const SET_MINIMIZED: u32 = 13;
|
||||
|
||||
const CONFIGURE: u32 = 0;
|
||||
const CLOSE: u32 = 1;
|
||||
use thiserror::Error;
|
||||
use crate::wire::xdg_toplevel::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::XdgToplevelId;
|
||||
|
||||
#[derive(Copy, Clone, Debug, FromPrimitive)]
|
||||
pub enum ResizeEdge {
|
||||
|
|
@ -73,8 +56,6 @@ const STATE_TILED_TOP: u32 = 7;
|
|||
#[allow(dead_code)]
|
||||
const STATE_TILED_BOTTOM: u32 = 8;
|
||||
|
||||
id!(XdgToplevelId);
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum Decoration {
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -172,8 +153,8 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn configure(self: &Rc<Self>, width: i32, height: i32) -> DynEventFormatter {
|
||||
Box::new(Configure {
|
||||
obj: self.clone(),
|
||||
Box::new(ConfigureOut {
|
||||
self_id: self.id,
|
||||
width,
|
||||
height,
|
||||
states: self.states.borrow().iter().copied().collect(),
|
||||
|
|
@ -207,15 +188,13 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn set_title(&self, parser: MsgParser<'_, '_>) -> Result<(), SetTitleError> {
|
||||
let _req: SetTitle = self.xdg.surface.client.parse(self, parser)?;
|
||||
let _req: SetTitleIn = self.xdg.surface.client.parse(self, parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_app_id(&self, parser: MsgParser<'_, '_>) -> Result<(), SetAppIdError> {
|
||||
let req: SetAppId = self.xdg.surface.client.parse(self, parser)?;
|
||||
if let Ok(s) = req.app_id.to_str() {
|
||||
self.bugs.set(bugs::get(s));
|
||||
}
|
||||
let req: SetAppIdIn = self.xdg.surface.client.parse(self, parser)?;
|
||||
self.bugs.set(bugs::get(req.app_id));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -560,3 +539,179 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgToplevelError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `set_parent` request")]
|
||||
SetParentError(#[from] SetParentError),
|
||||
#[error("Could not process `set_title` request")]
|
||||
SetTitleError(#[from] SetTitleError),
|
||||
#[error("Could not process `set_app_id` request")]
|
||||
SetAppIdError(#[from] SetAppIdError),
|
||||
#[error("Could not process `show_window_menu` request")]
|
||||
ShowWindowMenuError(#[from] ShowWindowMenuError),
|
||||
#[error("Could not process `move` request")]
|
||||
MoveError(#[from] MoveError),
|
||||
#[error("Could not process `resize` request")]
|
||||
ResizeError(#[from] ResizeError),
|
||||
#[error("Could not process `set_max_size` request")]
|
||||
SetMaxSizeError(#[from] SetMaxSizeError),
|
||||
#[error("Could not process `set_min_size` request")]
|
||||
SetMinSizeError(#[from] SetMinSizeError),
|
||||
#[error("Could not process `set_maximized` request")]
|
||||
SetMaximizedError(#[from] SetMaximizedError),
|
||||
#[error("Could not process `unset_maximized` request")]
|
||||
UnsetMaximizedError(#[from] UnsetMaximizedError),
|
||||
#[error("Could not process `set_fullscreen` request")]
|
||||
SetFullscreenError(#[from] SetFullscreenError),
|
||||
#[error("Could not process `unset_fullscreen` request")]
|
||||
UnsetFullscreenError(#[from] UnsetFullscreenError),
|
||||
#[error("Could not process `set_minimized` request")]
|
||||
SetMinimizedError(#[from] SetMinimizedError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetParentError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetParentError, ParseFailed, MsgParserError);
|
||||
efrom!(SetParentError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetTitleError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetTitleError, ParseFailed, MsgParserError);
|
||||
efrom!(SetTitleError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetAppIdError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetAppIdError, ParseFailed, MsgParserError);
|
||||
efrom!(SetAppIdError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ShowWindowMenuError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ShowWindowMenuError, ParseFailed, MsgParserError);
|
||||
efrom!(ShowWindowMenuError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum MoveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(MoveError, ParseFailed, MsgParserError);
|
||||
efrom!(MoveError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ResizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ResizeError, ParseFailed, MsgParserError);
|
||||
efrom!(ResizeError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMaxSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("width/height must be non-negative")]
|
||||
NonNegative,
|
||||
}
|
||||
efrom!(SetMaxSizeError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMaxSizeError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMinSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("width/height must be non-negative")]
|
||||
NonNegative,
|
||||
}
|
||||
efrom!(SetMinSizeError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMinSizeError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMaximizedError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetMaximizedError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMaximizedError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UnsetMaximizedError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(UnsetMaximizedError, ParseFailed, MsgParserError);
|
||||
efrom!(UnsetMaximizedError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetFullscreenError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetFullscreenError, ParseFailed, MsgParserError);
|
||||
efrom!(SetFullscreenError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UnsetFullscreenError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(UnsetFullscreenError, ParseFailed, MsgParserError);
|
||||
efrom!(UnsetFullscreenError, ClientError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMinimizedError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetMinimizedError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMinimizedError, ClientError, ClientError);
|
||||
|
|
@ -1,472 +0,0 @@
|
|||
use super::CONFIGURE;
|
||||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_seat::WlSeatId;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::{XdgToplevel, XdgToplevelId, CLOSE};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use bstr::BStr;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgToplevelError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `set_parent` request")]
|
||||
SetParentError(#[from] SetParentError),
|
||||
#[error("Could not process `set_title` request")]
|
||||
SetTitleError(#[from] SetTitleError),
|
||||
#[error("Could not process `set_app_id` request")]
|
||||
SetAppIdError(#[from] SetAppIdError),
|
||||
#[error("Could not process `show_window_menu` request")]
|
||||
ShowWindowMenuError(#[from] ShowWindowMenuError),
|
||||
#[error("Could not process `move` request")]
|
||||
MoveError(#[from] MoveError),
|
||||
#[error("Could not process `resize` request")]
|
||||
ResizeError(#[from] ResizeError),
|
||||
#[error("Could not process `set_max_size` request")]
|
||||
SetMaxSizeError(#[from] SetMaxSizeError),
|
||||
#[error("Could not process `set_min_size` request")]
|
||||
SetMinSizeError(#[from] SetMinSizeError),
|
||||
#[error("Could not process `set_maximized` request")]
|
||||
SetMaximizedError(#[from] SetMaximizedError),
|
||||
#[error("Could not process `unset_maximized` request")]
|
||||
UnsetMaximizedError(#[from] UnsetMaximizedError),
|
||||
#[error("Could not process `set_fullscreen` request")]
|
||||
SetFullscreenError(#[from] SetFullscreenError),
|
||||
#[error("Could not process `unset_fullscreen` request")]
|
||||
UnsetFullscreenError(#[from] UnsetFullscreenError),
|
||||
#[error("Could not process `set_minimized` request")]
|
||||
SetMinimizedError(#[from] SetMinimizedError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetParentError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetParentError, ParseFailed, MsgParserError);
|
||||
efrom!(SetParentError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetTitleError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetTitleError, ParseFailed, MsgParserError);
|
||||
efrom!(SetTitleError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetAppIdError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetAppIdError, ParseFailed, MsgParserError);
|
||||
efrom!(SetAppIdError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ShowWindowMenuError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ShowWindowMenuError, ParseFailed, MsgParserError);
|
||||
efrom!(ShowWindowMenuError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum MoveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(MoveError, ParseFailed, MsgParserError);
|
||||
efrom!(MoveError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ResizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ResizeError, ParseFailed, MsgParserError);
|
||||
efrom!(ResizeError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMaxSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("width/height must be non-negative")]
|
||||
NonNegative,
|
||||
}
|
||||
efrom!(SetMaxSizeError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMaxSizeError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMinSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("width/height must be non-negative")]
|
||||
NonNegative,
|
||||
}
|
||||
efrom!(SetMinSizeError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMinSizeError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMaximizedError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetMaximizedError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMaximizedError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UnsetMaximizedError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(UnsetMaximizedError, ParseFailed, MsgParserError);
|
||||
efrom!(UnsetMaximizedError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetFullscreenError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetFullscreenError, ParseFailed, MsgParserError);
|
||||
efrom!(SetFullscreenError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UnsetFullscreenError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(UnsetFullscreenError, ParseFailed, MsgParserError);
|
||||
efrom!(UnsetFullscreenError, ClientError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetMinimizedError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(SetMinimizedError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMinimizedError, ClientError, ClientError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetParent {
|
||||
pub parent: XdgToplevelId,
|
||||
}
|
||||
impl RequestParser<'_> for SetParent {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
parent: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetParent {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_parent(parent: {})", self.parent)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetTitle<'a> {
|
||||
pub title: &'a BStr,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for SetTitle<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
title: parser.bstr()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<'a> Debug for SetTitle<'a> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_title(title: {:?})", self.title)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetAppId<'a> {
|
||||
pub app_id: &'a BStr,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for SetAppId<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
app_id: parser.bstr()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<'a> Debug for SetAppId<'a> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_app_id(app_id: {:?})", self.app_id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct ShowWindowMenu {
|
||||
pub seat: WlSeatId,
|
||||
pub serial: u32,
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
}
|
||||
impl RequestParser<'_> for ShowWindowMenu {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
seat: parser.object()?,
|
||||
serial: parser.uint()?,
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for ShowWindowMenu {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"show_window_menu(seat: {}, serial: {}, x: {}, y: {})",
|
||||
self.seat, self.serial, self.x, self.y
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Move {
|
||||
pub seat: WlSeatId,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Move {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
seat: parser.object()?,
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Move {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "move(seat: {}, serial: {})", self.seat, self.serial)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Resize {
|
||||
pub seat: WlSeatId,
|
||||
pub serial: u32,
|
||||
pub edges: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Resize {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
seat: parser.object()?,
|
||||
serial: parser.uint()?,
|
||||
edges: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Resize {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"resize(seat: {}, serial: {}, edges: {})",
|
||||
self.seat, self.serial, self.edges
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetMaxSize {
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetMaxSize {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetMaxSize {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_max_size(width: {}, height: {})",
|
||||
self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetMinSize {
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetMinSize {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetMinSize {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_min_size(width: {}, height: {})",
|
||||
self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetMaximized;
|
||||
impl RequestParser<'_> for SetMaximized {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for SetMaximized {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_maximized()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct UnsetMaximized;
|
||||
impl RequestParser<'_> for UnsetMaximized {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for UnsetMaximized {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "unset_maximized()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetFullscreen {
|
||||
pub output: crate::ifs::wl_output::WlOutputId,
|
||||
}
|
||||
impl RequestParser<'_> for SetFullscreen {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
output: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetFullscreen {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_fullscreen(output: {})", self.output)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct UnsetFullscreen;
|
||||
impl RequestParser<'_> for UnsetFullscreen {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for UnsetFullscreen {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "unset_fullscreen()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetMinimized;
|
||||
impl RequestParser<'_> for SetMinimized {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for SetMinimized {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_minimized()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Configure {
|
||||
pub obj: Rc<XdgToplevel>,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub states: Vec<u32>,
|
||||
}
|
||||
impl EventFormatter for Configure {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CONFIGURE)
|
||||
.int(self.width)
|
||||
.int(self.height)
|
||||
.array(|fmt| {
|
||||
for &state in &self.states {
|
||||
fmt.uint(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Configure {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"configure(width: {}, height: {}, states: {:?})",
|
||||
self.width, self.height, self.states
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Close {
|
||||
pub obj: Rc<XdgToplevel>,
|
||||
}
|
||||
impl EventFormatter for Close {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CLOSE);
|
||||
}
|
||||
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Close {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "close()")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::ifs::xdg_wm_base::XdgWmBase;
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
|
|
@ -8,18 +7,10 @@ use crate::utils::buffd::MsgParser;
|
|||
use bitflags::bitflags;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const SET_SIZE: u32 = 1;
|
||||
const SET_ANCHOR_RECT: u32 = 2;
|
||||
const SET_ANCHOR: u32 = 3;
|
||||
const SET_GRAVITY: u32 = 4;
|
||||
const SET_CONSTRAINT_ADJUSTMENT: u32 = 5;
|
||||
const SET_OFFSET: u32 = 6;
|
||||
const SET_REACTIVE: u32 = 7;
|
||||
const SET_PARENT_SIZE: u32 = 8;
|
||||
const SET_PARENT_CONFIGURE: u32 = 9;
|
||||
use thiserror::Error;
|
||||
use crate::wire::xdg_positioner::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::XdgPositionerId;
|
||||
|
||||
const INVALID_INPUT: u32 = 0;
|
||||
|
||||
|
|
@ -74,8 +65,6 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
id!(XdgPositionerId);
|
||||
|
||||
pub struct XdgPositioner {
|
||||
id: XdgPositionerId,
|
||||
base: Rc<XdgWmBase>,
|
||||
|
|
@ -305,3 +294,112 @@ impl Object for XdgPositioner {
|
|||
}
|
||||
|
||||
dedicated_add_obj!(XdgPositioner, XdgPositionerId, xdg_positioners);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgPositionerError {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `set_size` request")]
|
||||
SetSizeError(#[from] SetSizeError),
|
||||
#[error("Could not process a `set_anchor_rect` request")]
|
||||
SetAnchorRectError(#[from] SetAnchorRectError),
|
||||
#[error("Could not process a `set_anchor` request")]
|
||||
SetAnchorError(#[from] SetAnchorError),
|
||||
#[error("Could not process a `set_gravity` request")]
|
||||
SetGravityError(#[from] SetGravityError),
|
||||
#[error("Could not process a `set_constraint_adjustment` request")]
|
||||
SetConstraintAdjustmentError(#[from] SetConstraintAdjustmentError),
|
||||
#[error("Could not process a `set_offset` request")]
|
||||
SetOffsetError(#[from] SetOffsetError),
|
||||
#[error("Could not process a `set_reactive` request")]
|
||||
SetReactiveError(#[from] SetReactiveError),
|
||||
#[error("Could not process a `set_parent_size` request")]
|
||||
SetParentSizeError(#[from] SetParentSizeError),
|
||||
#[error("Could not process a `set_parent_configure` request")]
|
||||
SetParentConfigureError(#[from] SetParentConfigureError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Cannot set a non-positive size")]
|
||||
NonPositiveSize,
|
||||
}
|
||||
efrom!(SetSizeError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetAnchorRectError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Cannot set an anchor rect with a negative size")]
|
||||
NegativeAnchorRect,
|
||||
}
|
||||
efrom!(SetAnchorRectError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetAnchorError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Unknown anchor {0}")]
|
||||
UnknownAnchor(u32),
|
||||
}
|
||||
efrom!(SetAnchorError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetGravityError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Unknown gravity {0}")]
|
||||
UnknownGravity(u32),
|
||||
}
|
||||
efrom!(SetGravityError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetConstraintAdjustmentError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Unknown constraint adjustment {0}")]
|
||||
UnknownCa(u32),
|
||||
}
|
||||
efrom!(SetConstraintAdjustmentError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetOffsetError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetOffsetError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetReactiveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetReactiveError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetParentSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Cannot set a negative parent size")]
|
||||
NegativeParentSize,
|
||||
}
|
||||
efrom!(SetParentSizeError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetParentConfigureError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetParentConfigureError, ParseError, MsgParserError);
|
||||
|
|
@ -1,293 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgPositionerError {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `set_size` request")]
|
||||
SetSizeError(#[from] SetSizeError),
|
||||
#[error("Could not process a `set_anchor_rect` request")]
|
||||
SetAnchorRectError(#[from] SetAnchorRectError),
|
||||
#[error("Could not process a `set_anchor` request")]
|
||||
SetAnchorError(#[from] SetAnchorError),
|
||||
#[error("Could not process a `set_gravity` request")]
|
||||
SetGravityError(#[from] SetGravityError),
|
||||
#[error("Could not process a `set_constraint_adjustment` request")]
|
||||
SetConstraintAdjustmentError(#[from] SetConstraintAdjustmentError),
|
||||
#[error("Could not process a `set_offset` request")]
|
||||
SetOffsetError(#[from] SetOffsetError),
|
||||
#[error("Could not process a `set_reactive` request")]
|
||||
SetReactiveError(#[from] SetReactiveError),
|
||||
#[error("Could not process a `set_parent_size` request")]
|
||||
SetParentSizeError(#[from] SetParentSizeError),
|
||||
#[error("Could not process a `set_parent_configure` request")]
|
||||
SetParentConfigureError(#[from] SetParentConfigureError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Cannot set a non-positive size")]
|
||||
NonPositiveSize,
|
||||
}
|
||||
efrom!(SetSizeError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetAnchorRectError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Cannot set an anchor rect with a negative size")]
|
||||
NegativeAnchorRect,
|
||||
}
|
||||
efrom!(SetAnchorRectError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetAnchorError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Unknown anchor {0}")]
|
||||
UnknownAnchor(u32),
|
||||
}
|
||||
efrom!(SetAnchorError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetGravityError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Unknown gravity {0}")]
|
||||
UnknownGravity(u32),
|
||||
}
|
||||
efrom!(SetGravityError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetConstraintAdjustmentError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Unknown constraint adjustment {0}")]
|
||||
UnknownCa(u32),
|
||||
}
|
||||
efrom!(SetConstraintAdjustmentError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetOffsetError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetOffsetError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetReactiveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetReactiveError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetParentSizeError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Cannot set a negative parent size")]
|
||||
NegativeParentSize,
|
||||
}
|
||||
efrom!(SetParentSizeError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetParentConfigureError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetParentConfigureError, ParseError, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetSize {
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetSize {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetSize {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_size(width: {}, height: {})",
|
||||
self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetAnchorRect {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetAnchorRect {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetAnchorRect {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_anchor_rect(x: {}, y: {}, width: {}, height: {})",
|
||||
self.x, self.y, self.width, self.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetAnchor {
|
||||
pub anchor: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetAnchor {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
anchor: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetAnchor {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_anchor(anchor: {})", self.anchor)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetGravity {
|
||||
pub gravity: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetGravity {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
gravity: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetGravity {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_gravity(gravity: {})", self.gravity)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetConstraintAdjustment {
|
||||
pub constraint_adjustment: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetConstraintAdjustment {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
constraint_adjustment: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetConstraintAdjustment {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_constraint_adjustment(constraint_adjustment: {})",
|
||||
self.constraint_adjustment
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetOffset {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetOffset {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
x: parser.int()?,
|
||||
y: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetOffset {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_offset(x: {}, y: {})", self.x, self.y)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetReactive;
|
||||
impl RequestParser<'_> for SetReactive {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for SetReactive {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_reactive()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetParentSize {
|
||||
pub parent_width: i32,
|
||||
pub parent_height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetParentSize {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
parent_width: parser.int()?,
|
||||
parent_height: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetParentSize {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_parent_size(parent_width: {}, parent_height: {})",
|
||||
self.parent_width, self.parent_height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetParentConfigure {
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetParentConfigure {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetParentConfigure {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_parent_configure(serial: {})", self.serial)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,16 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceId};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError};
|
||||
use crate::ifs::xdg_positioner::XdgPositioner;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::copyhashmap::CopyHashMap;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const CREATE_POSITIONER: u32 = 1;
|
||||
const GET_XDG_SURFACE: u32 = 2;
|
||||
const PONG: u32 = 3;
|
||||
|
||||
const PING: u32 = 0;
|
||||
use thiserror::Error;
|
||||
use crate::wire::xdg_wm_base::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::{XdgSurfaceId, XdgWmBaseId};
|
||||
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
|
@ -29,8 +24,6 @@ const INVALID_SURFACE_STATE: u32 = 4;
|
|||
#[allow(dead_code)]
|
||||
const INVALID_POSITIONER: u32 = 5;
|
||||
|
||||
id!(XdgWmBaseId);
|
||||
|
||||
pub struct XdgWmBaseGlobal {
|
||||
name: GlobalName,
|
||||
}
|
||||
|
|
@ -145,3 +138,60 @@ impl Object for XdgWmBase {
|
|||
self.surfaces.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgWmBaseError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `create_positioner` request")]
|
||||
CreatePositionerError(#[from] CreatePositionerError),
|
||||
#[error("Could not process a `get_xdg_surface` request")]
|
||||
GetXdgSurfaceError(#[from] GetXdgSurfaceError),
|
||||
#[error("Could not process a `pong` request")]
|
||||
PongError(#[from] PongError),
|
||||
}
|
||||
efrom!(XdgWmBaseError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Tried to destroy xdg_wm_base object before destroying its surfaces")]
|
||||
DefunctSurfaces,
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreatePositionerError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreatePositionerError, ParseError, MsgParserError);
|
||||
efrom!(CreatePositionerError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetXdgSurfaceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
XdgSurfaceError(Box<XdgSurfaceError>),
|
||||
}
|
||||
efrom!(GetXdgSurfaceError, ParseError, MsgParserError);
|
||||
efrom!(GetXdgSurfaceError, ClientError);
|
||||
efrom!(GetXdgSurfaceError, XdgSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PongError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(PongError, ParseError, MsgParserError);
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurfaceError, XdgSurfaceId};
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::ifs::xdg_positioner::XdgPositionerId;
|
||||
use crate::ifs::xdg_wm_base::{XdgWmBase, PING};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgWmBaseError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `create_positioner` request")]
|
||||
CreatePositionerError(#[from] CreatePositionerError),
|
||||
#[error("Could not process a `get_xdg_surface` request")]
|
||||
GetXdgSurfaceError(#[from] GetXdgSurfaceError),
|
||||
#[error("Could not process a `pong` request")]
|
||||
PongError(#[from] PongError),
|
||||
}
|
||||
efrom!(XdgWmBaseError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("Tried to destroy xdg_wm_base object before destroying its surfaces")]
|
||||
DefunctSurfaces,
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreatePositionerError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreatePositionerError, ParseError, MsgParserError);
|
||||
efrom!(CreatePositionerError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetXdgSurfaceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
XdgSurfaceError(Box<XdgSurfaceError>),
|
||||
}
|
||||
efrom!(GetXdgSurfaceError, ParseError, MsgParserError);
|
||||
efrom!(GetXdgSurfaceError, ClientError);
|
||||
efrom!(GetXdgSurfaceError, XdgSurfaceError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PongError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(PongError, ParseError, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()",)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct CreatePositioner {
|
||||
pub id: XdgPositionerId,
|
||||
}
|
||||
impl RequestParser<'_> for CreatePositioner {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreatePositioner {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_positioner(id: {})", self.id,)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetXdgSurface {
|
||||
pub id: XdgSurfaceId,
|
||||
pub surface: WlSurfaceId,
|
||||
}
|
||||
impl RequestParser<'_> for GetXdgSurface {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
surface: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetXdgSurface {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"get_xdg_surface(id: {}, surface: {})",
|
||||
self.id, self.surface,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Pong {
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Pong {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Pong {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "pong(serial: {})", self.serial,)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Ping {
|
||||
pub obj: Rc<XdgWmBase>,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl EventFormatter for Ping {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, PING).uint(self.serial);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Ping {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "ping(serial: {})", self.serial)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +1,19 @@
|
|||
use crate::client::DynEventFormatter;
|
||||
use crate::client::{ClientError, DynEventFormatter};
|
||||
use crate::drm::dma::{DmaBuf, DmaBufPlane};
|
||||
use crate::drm::INVALID_MODIFIER;
|
||||
use crate::ifs::wl_buffer::{WlBuffer, WlBufferId};
|
||||
use crate::ifs::wl_buffer::{WlBuffer};
|
||||
use crate::ifs::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::ErrorFmt;
|
||||
use crate::{ErrorFmt, RenderError};
|
||||
use ahash::AHashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::zwp_linux_buffer_params_v1::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::{WlBufferId, ZwpLinuxBufferParamsV1Id};
|
||||
|
||||
mod types;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const ADD: u32 = 1;
|
||||
const CREATE: u32 = 2;
|
||||
const CREATE_IMMED: u32 = 3;
|
||||
|
||||
const CREATED: u32 = 0;
|
||||
const FAILED: u32 = 1;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const Y_INVERT: u32 = 1;
|
||||
|
|
@ -28,8 +22,6 @@ const INTERLACED: u32 = 2;
|
|||
#[allow(dead_code)]
|
||||
const BOTTOM_FIRST: u32 = 4;
|
||||
|
||||
id!(ZwpLinuxBufferParamsV1Id);
|
||||
|
||||
const MAX_PLANE: u32 = 3;
|
||||
|
||||
pub struct ZwpLinuxBufferParamsV1 {
|
||||
|
|
@ -51,13 +43,13 @@ impl ZwpLinuxBufferParamsV1 {
|
|||
|
||||
fn created(self: &Rc<Self>, buffer_id: WlBufferId) -> DynEventFormatter {
|
||||
Box::new(Created {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
buffer: buffer_id,
|
||||
})
|
||||
}
|
||||
|
||||
fn failed(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Failed { obj: self.clone() })
|
||||
Box::new(Failed { self_id: self.id })
|
||||
}
|
||||
|
||||
fn destroy(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
|
|
@ -186,3 +178,85 @@ impl Object for ZwpLinuxBufferParamsV1 {
|
|||
}
|
||||
|
||||
simple_add_obj!(ZwpLinuxBufferParamsV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpLinuxBufferParamsV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `add` request")]
|
||||
AddError(#[from] AddError),
|
||||
#[error("Could not process a `create` request")]
|
||||
Create(#[from] CreateError),
|
||||
#[error("Could not process a `create_immed` request")]
|
||||
CreateImmed(#[from] CreateImmedError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpLinuxBufferParamsV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AddError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("A buffer can contain at most 4 planes")]
|
||||
MaxPlane,
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The modifier {0} is not supported")]
|
||||
InvalidModifier(u64),
|
||||
#[error("The plane {0} was already set")]
|
||||
AlreadySet(u32),
|
||||
}
|
||||
efrom!(AddError, ClientError);
|
||||
efrom!(AddError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DoCreateError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The compositor has no render context attached")]
|
||||
NoRenderContext,
|
||||
#[error("The format {0} is not supported")]
|
||||
InvalidFormat(u32),
|
||||
#[error("Plane {0} was not set")]
|
||||
MissingPlane(usize),
|
||||
#[error("Could not import the buffer")]
|
||||
ImportError(#[from] RenderError),
|
||||
}
|
||||
efrom!(DoCreateError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateError {
|
||||
#[error("The params object has already been used")]
|
||||
AlreadyUsed,
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateError, ClientError, ClientError);
|
||||
efrom!(CreateError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateImmedError {
|
||||
#[error("The params object has already been used")]
|
||||
AlreadyUsed,
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
DoCreateError(#[from] DoCreateError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateImmedError, ClientError, ClientError);
|
||||
efrom!(CreateImmedError, ParseError, MsgParserError);
|
||||
|
|
@ -1,227 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_buffer::WlBufferId;
|
||||
use crate::ifs::zwp_linux_buffer_params_v1::{ZwpLinuxBufferParamsV1, CREATED, FAILED};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use crate::RenderError;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpLinuxBufferParamsV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `add` request")]
|
||||
AddError(#[from] AddError),
|
||||
#[error("Could not process a `create` request")]
|
||||
Create(#[from] CreateError),
|
||||
#[error("Could not process a `create_immed` request")]
|
||||
CreateImmed(#[from] CreateImmedError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpLinuxBufferParamsV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AddError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error("A buffer can contain at most 4 planes")]
|
||||
MaxPlane,
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The modifier {0} is not supported")]
|
||||
InvalidModifier(u64),
|
||||
#[error("The plane {0} was already set")]
|
||||
AlreadySet(u32),
|
||||
}
|
||||
efrom!(AddError, ClientError);
|
||||
efrom!(AddError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DoCreateError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The compositor has no render context attached")]
|
||||
NoRenderContext,
|
||||
#[error("The format {0} is not supported")]
|
||||
InvalidFormat(u32),
|
||||
#[error("Plane {0} was not set")]
|
||||
MissingPlane(usize),
|
||||
#[error("Could not import the buffer")]
|
||||
ImportError(#[from] RenderError),
|
||||
}
|
||||
efrom!(DoCreateError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateError {
|
||||
#[error("The params object has already been used")]
|
||||
AlreadyUsed,
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateError, ClientError, ClientError);
|
||||
efrom!(CreateError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateImmedError {
|
||||
#[error("The params object has already been used")]
|
||||
AlreadyUsed,
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
DoCreateError(#[from] DoCreateError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateImmedError, ClientError, ClientError);
|
||||
efrom!(CreateImmedError, ParseError, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Add {
|
||||
pub fd: OwnedFd,
|
||||
pub plane_idx: u32,
|
||||
pub offset: u32,
|
||||
pub stride: u32,
|
||||
pub modifier_hi: u32,
|
||||
pub modifier_lo: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Add {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
fd: parser.fd()?,
|
||||
plane_idx: parser.uint()?,
|
||||
offset: parser.uint()?,
|
||||
stride: parser.uint()?,
|
||||
modifier_hi: parser.uint()?,
|
||||
modifier_lo: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Add {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"add(fd: {}, plane_idx: {}, offset: {}, stride: {}, modifier: {})",
|
||||
self.fd.raw(),
|
||||
self.plane_idx,
|
||||
self.offset,
|
||||
self.stride,
|
||||
(self.modifier_hi as u64) << 32 | self.modifier_lo as u64,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Create {
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub format: u32,
|
||||
pub flags: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Create {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
format: parser.uint()?,
|
||||
flags: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Create {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"create(width: {}, height: {}, format: {}, flags: {})",
|
||||
self.width, self.height, self.format, self.flags,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct CreateImmed {
|
||||
pub buffer_id: WlBufferId,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub format: u32,
|
||||
pub flags: u32,
|
||||
}
|
||||
impl RequestParser<'_> for CreateImmed {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
buffer_id: parser.object()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
format: parser.uint()?,
|
||||
flags: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateImmed {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"create_immed(buffer_id: {}, width: {}, height: {}, format: {}, flags: {})",
|
||||
self.buffer_id, self.width, self.height, self.format, self.flags,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Created {
|
||||
pub obj: Rc<ZwpLinuxBufferParamsV1>,
|
||||
pub buffer: WlBufferId,
|
||||
}
|
||||
impl EventFormatter for Created {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CREATED).object(self.buffer);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Created {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "created(buffer: {})", self.buffer)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Failed {
|
||||
pub obj: Rc<ZwpLinuxBufferParamsV1>,
|
||||
}
|
||||
impl EventFormatter for Failed {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, FAILED);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Failed {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "failed()")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,15 @@
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::drm::INVALID_MODIFIER;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::zwp_linux_dmabuf_v1::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::ZwpLinuxDmabufV1Id;
|
||||
|
||||
mod types;
|
||||
|
||||
id!(ZwpLinuxDmabufV1Id);
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const CREATE_PARAMS: u32 = 1;
|
||||
|
||||
const FORMAT: u32 = 0;
|
||||
const MODIFIER: u32 = 1;
|
||||
|
||||
pub struct ZwpLinuxDmabufV1Global {
|
||||
name: GlobalName,
|
||||
|
|
@ -80,16 +74,17 @@ pub struct ZwpLinuxDmabufV1 {
|
|||
impl ZwpLinuxDmabufV1 {
|
||||
fn format(self: &Rc<Self>, format: u32) -> DynEventFormatter {
|
||||
Box::new(Format {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
format,
|
||||
})
|
||||
}
|
||||
|
||||
fn modifier(self: &Rc<Self>, format: u32, modifier: u64) -> DynEventFormatter {
|
||||
Box::new(Modifier {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
format,
|
||||
modifier,
|
||||
modifier_hi: (modifier >> 32) as _,
|
||||
modifier_lo: modifier as _,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -121,3 +116,34 @@ impl Object for ZwpLinuxDmabufV1 {
|
|||
}
|
||||
|
||||
simple_add_obj!(ZwpLinuxDmabufV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpLinuxDmabufV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `create_params` request")]
|
||||
CreateParamsError(#[from] CreateParamsError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpLinuxDmabufV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateParamsError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateParamsError, ClientError);
|
||||
efrom!(CreateParamsError, ParseError, MsgParserError);
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1Id;
|
||||
use crate::ifs::zwp_linux_dmabuf_v1::{ZwpLinuxDmabufV1, FORMAT, MODIFIER};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpLinuxDmabufV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `create_params` request")]
|
||||
CreateParamsError(#[from] CreateParamsError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpLinuxDmabufV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, ParseError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateParamsError {
|
||||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateParamsError, ClientError);
|
||||
efrom!(CreateParamsError, ParseError, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct CreateParams {
|
||||
pub params_id: ZwpLinuxBufferParamsV1Id,
|
||||
}
|
||||
impl RequestParser<'_> for CreateParams {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
params_id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateParams {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_params(params_id: {})", self.params_id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Format {
|
||||
pub obj: Rc<ZwpLinuxDmabufV1>,
|
||||
pub format: u32,
|
||||
}
|
||||
impl EventFormatter for Format {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, FORMAT).uint(self.format);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Format {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "format(format: {})", self.format)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Modifier {
|
||||
pub obj: Rc<ZwpLinuxDmabufV1>,
|
||||
pub format: u32,
|
||||
pub modifier: u64,
|
||||
}
|
||||
impl EventFormatter for Modifier {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, MODIFIER)
|
||||
.uint(self.format)
|
||||
.uint((self.modifier >> 32) as u32)
|
||||
.uint(self.modifier as u32);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Modifier {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"modifiers(format: {}, modifier: {})",
|
||||
self.format, self.modifier
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,15 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const CREATE_SOURCE: u32 = 0;
|
||||
const GET_DEVICE: u32 = 1;
|
||||
const DESTROY: u32 = 2;
|
||||
|
||||
id!(ZwpPrimarySelectionDeviceManagerV1Id);
|
||||
use thiserror::Error;
|
||||
use crate::wire::zwp_primary_selection_device_manager_v1::*;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::ZwpPrimarySelectionDeviceManagerV1Id;
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceManagerV1Global {
|
||||
name: GlobalName,
|
||||
|
|
@ -103,3 +99,46 @@ impl Object for ZwpPrimarySelectionDeviceManagerV1 {
|
|||
}
|
||||
|
||||
simple_add_obj!(ZwpPrimarySelectionDeviceManagerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionDeviceManagerV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `create_source` request")]
|
||||
CreateSourceError(#[from] CreateSourceError),
|
||||
#[error("Could not process `get_device` request")]
|
||||
GetDeviceError(#[from] GetDeviceError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceManagerV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateSourceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateSourceError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateSourceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetDeviceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetDeviceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetDeviceError, ClientError);
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::ifs::wl_seat::WlSeatId;
|
||||
use crate::ifs::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1Id;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1Id;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionDeviceManagerV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `create_source` request")]
|
||||
CreateSourceError(#[from] CreateSourceError),
|
||||
#[error("Could not process `get_device` request")]
|
||||
GetDeviceError(#[from] GetDeviceError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceManagerV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateSourceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateSourceError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateSourceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetDeviceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetDeviceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetDeviceError, ClientError);
|
||||
|
||||
pub(super) struct CreateSource {
|
||||
pub id: ZwpPrimarySelectionSourceV1Id,
|
||||
}
|
||||
impl RequestParser<'_> for CreateSource {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateSource {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_source(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetDevice {
|
||||
pub id: ZwpPrimarySelectionDeviceV1Id,
|
||||
pub seat: WlSeatId,
|
||||
}
|
||||
impl RequestParser<'_> for GetDevice {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
seat: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetDevice {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_device(id: {}, seat: {})", self.id, self.seat,)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,14 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::client::{ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::ifs::zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1;
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const SET_SELECTION: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
|
||||
const DATA_OFFER: u32 = 0;
|
||||
const SELECTION: u32 = 1;
|
||||
|
||||
id!(ZwpPrimarySelectionDeviceV1Id);
|
||||
use thiserror::Error;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1Error;
|
||||
use crate::wire::zwp_primary_selection_device_v1::*;
|
||||
use crate::wire::{ZwpPrimarySelectionDeviceV1Id, ZwpPrimarySelectionOfferV1Id};
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceV1 {
|
||||
pub id: ZwpPrimarySelectionDeviceV1Id,
|
||||
|
|
@ -36,16 +29,16 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn data_offer(self: &Rc<Self>, id: ZwpPrimarySelectionOfferV1Id) -> DynEventFormatter {
|
||||
pub fn data_offer(self: &Rc<Self>, offer: ZwpPrimarySelectionOfferV1Id) -> DynEventFormatter {
|
||||
Box::new(DataOffer {
|
||||
obj: self.clone(),
|
||||
id,
|
||||
self_id: self.id,
|
||||
offer,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn selection(self: &Rc<Self>, id: ZwpPrimarySelectionOfferV1Id) -> DynEventFormatter {
|
||||
Box::new(Selection {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
|
@ -87,3 +80,37 @@ impl Object for ZwpPrimarySelectionDeviceV1 {
|
|||
}
|
||||
|
||||
simple_add_obj!(ZwpPrimarySelectionDeviceV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionDeviceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `set_selection` request")]
|
||||
SetSelectionError(#[from] SetSelectionError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSelectionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
ZwpPrimarySelectionSourceV1Error(Box<ZwpPrimarySelectionSourceV1Error>),
|
||||
}
|
||||
efrom!(SetSelectionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetSelectionError, ClientError);
|
||||
efrom!(SetSelectionError, ZwpPrimarySelectionSourceV1Error);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_primary_selection_device_v1::{
|
||||
ZwpPrimarySelectionDeviceV1, DATA_OFFER, SELECTION,
|
||||
};
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{
|
||||
ZwpPrimarySelectionSourceV1Error, ZwpPrimarySelectionSourceV1Id,
|
||||
};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionDeviceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `set_selection` request")]
|
||||
SetSelectionError(#[from] SetSelectionError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSelectionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
ZwpPrimarySelectionSourceV1Error(Box<ZwpPrimarySelectionSourceV1Error>),
|
||||
}
|
||||
efrom!(SetSelectionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetSelectionError, ClientError);
|
||||
efrom!(SetSelectionError, ZwpPrimarySelectionSourceV1Error);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
pub(super) struct SetSelection {
|
||||
pub source: ZwpPrimarySelectionSourceV1Id,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetSelection {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
source: parser.object()?,
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetSelection {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_selection(source: {}, serial: {})",
|
||||
self.source, self.serial,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DataOffer {
|
||||
pub obj: Rc<ZwpPrimarySelectionDeviceV1>,
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
}
|
||||
impl EventFormatter for DataOffer {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DATA_OFFER).object(self.id);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for DataOffer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "data_offer(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Selection {
|
||||
pub obj: Rc<ZwpPrimarySelectionDeviceV1>,
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
}
|
||||
impl EventFormatter for Selection {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, SELECTION).object(self.id);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Selection {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "selection(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,15 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const RECEIVE: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
|
||||
const OFFER: u32 = 0;
|
||||
|
||||
id!(ZwpPrimarySelectionOfferV1Id);
|
||||
use thiserror::Error;
|
||||
use crate::wire::zwp_primary_selection_offer_v1::*;
|
||||
use crate::wire::ZwpPrimarySelectionOfferV1Id;
|
||||
|
||||
pub struct ZwpPrimarySelectionOfferV1 {
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
|
|
@ -54,14 +48,14 @@ impl ZwpPrimarySelectionOfferV1 {
|
|||
}
|
||||
|
||||
pub fn offer(self: &Rc<Self>, mime_type: &str) -> DynEventFormatter {
|
||||
Box::new(Offer {
|
||||
obj: self.clone(),
|
||||
Box::new(OfferOut {
|
||||
self_id: self.id,
|
||||
mime_type: mime_type.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ReceiveError> {
|
||||
let req: Receive = self.client.parse(self, parser)?;
|
||||
let req: ReceiveIn = self.client.parse(self, parser)?;
|
||||
if let Some(src) = self.source.get() {
|
||||
src.client.event(src.send(req.mime_type, req.fd));
|
||||
src.client.flush();
|
||||
|
|
@ -101,3 +95,34 @@ impl Object for ZwpPrimarySelectionOfferV1 {
|
|||
}
|
||||
|
||||
simple_add_obj!(ZwpPrimarySelectionOfferV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionOfferV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `receive` request")]
|
||||
ReceiveError(#[from] ReceiveError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionOfferV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReceiveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReceiveError, ParseFailed, MsgParserError);
|
||||
efrom!(ReceiveError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::{ZwpPrimarySelectionOfferV1, OFFER};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionOfferV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `receive` request")]
|
||||
ReceiveError(#[from] ReceiveError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionOfferV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReceiveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReceiveError, ParseFailed, MsgParserError);
|
||||
efrom!(ReceiveError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
pub(super) struct Receive<'a> {
|
||||
pub mime_type: &'a str,
|
||||
pub fd: OwnedFd,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for Receive<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
mime_type: parser.str()?,
|
||||
fd: parser.fd()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Offer {
|
||||
pub obj: Rc<ZwpPrimarySelectionOfferV1>,
|
||||
pub mime_type: String,
|
||||
}
|
||||
impl EventFormatter for Offer {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, OFFER).string(&self.mime_type);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Offer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "offer(mime_type: {:?})", self.mime_type)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,17 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use ahash::AHashSet;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
const OFFER: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
|
||||
const SEND: u32 = 0;
|
||||
const CANCELLED: u32 = 1;
|
||||
|
||||
id!(ZwpPrimarySelectionSourceV1Id);
|
||||
use crate::wire::zwp_primary_selection_source_v1::*;
|
||||
use crate::wire::ZwpPrimarySelectionSourceV1Id;
|
||||
|
||||
pub struct ZwpPrimarySelectionSourceV1 {
|
||||
pub id: ZwpPrimarySelectionSourceV1Id,
|
||||
|
|
@ -76,19 +69,19 @@ impl ZwpPrimarySelectionSourceV1 {
|
|||
}
|
||||
|
||||
pub fn cancelled(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Cancelled { obj: self.clone() })
|
||||
Box::new(Cancelled { self_id: self.id })
|
||||
}
|
||||
|
||||
pub fn send(self: &Rc<Self>, mime_type: &str, fd: OwnedFd) -> DynEventFormatter {
|
||||
Box::new(Send {
|
||||
obj: self.clone(),
|
||||
pub fn send(self: &Rc<Self>, mime_type: &str, fd: Rc<OwnedFd>) -> DynEventFormatter {
|
||||
Box::new(SendOut {
|
||||
self_id: self.id,
|
||||
mime_type: mime_type.to_string(),
|
||||
fd: Rc::new(fd),
|
||||
fd,
|
||||
})
|
||||
}
|
||||
|
||||
fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), OfferError> {
|
||||
let req: Offer = self.client.parse(self, parser)?;
|
||||
let req: OfferIn = self.client.parse(self, parser)?;
|
||||
if self
|
||||
.mime_types
|
||||
.borrow_mut()
|
||||
|
|
@ -140,3 +133,36 @@ dedicated_add_obj!(
|
|||
ZwpPrimarySelectionSourceV1Id,
|
||||
zwp_primary_selection_source
|
||||
);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionSourceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `offer` request")]
|
||||
OfferError(#[from] OfferError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("The data source is already attached")]
|
||||
AlreadyAttached,
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionSourceV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OfferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(OfferError, ParseFailed, MsgParserError);
|
||||
efrom!(OfferError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{ZwpPrimarySelectionSourceV1, CANCELLED, SEND};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionSourceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `offer` request")]
|
||||
OfferError(#[from] OfferError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("The data source is already attached")]
|
||||
AlreadyAttached,
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionSourceV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OfferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(OfferError, ParseFailed, MsgParserError);
|
||||
efrom!(OfferError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
pub(super) struct Offer<'a> {
|
||||
pub mime_type: &'a str,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for Offer<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
mime_type: parser.str()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Offer<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "offer(mime_type: {:?})", self.mime_type)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()",)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Send {
|
||||
pub obj: Rc<ZwpPrimarySelectionSourceV1>,
|
||||
pub mime_type: String,
|
||||
pub fd: Rc<OwnedFd>,
|
||||
}
|
||||
impl EventFormatter for Send {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, SEND)
|
||||
.string(&self.mime_type)
|
||||
.fd(self.fd);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Send {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"send(mime_type: {:?}, fd: {})",
|
||||
self.mime_type,
|
||||
self.fd.raw()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Cancelled {
|
||||
pub obj: Rc<ZwpPrimarySelectionSourceV1>,
|
||||
}
|
||||
impl EventFormatter for Cancelled {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CANCELLED);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Cancelled {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "cancelled()")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,13 @@
|
|||
use crate::client::Client;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use thiserror::Error;
|
||||
use crate::wire::zxdg_decoration_manager_v1::*;
|
||||
use crate::wire::ZxdgDecorationManagerV1Id;
|
||||
|
||||
mod types;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const GET_TOPLEVEL_DECORATION: u32 = 1;
|
||||
|
||||
id!(ZxdgDecorationManagerV1Id);
|
||||
|
||||
pub struct ZxdgDecorationManagerV1Global {
|
||||
name: GlobalName,
|
||||
|
|
@ -95,3 +91,34 @@ impl Object for ZxdgDecorationManagerV1 {
|
|||
}
|
||||
|
||||
simple_add_obj!(ZxdgDecorationManagerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZxdgDecorationManagerV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `get_toplevel_decoration` request")]
|
||||
GetToplevelDecorationError(#[from] GetToplevelDecorationError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZxdgDecorationManagerV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetToplevelDecorationError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetToplevelDecorationError, ClientError);
|
||||
efrom!(GetToplevelDecorationError, MsgParserError);
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevelId;
|
||||
use crate::ifs::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1Id;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZxdgDecorationManagerV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process a `get_toplevel_decoration` request")]
|
||||
GetToplevelDecorationError(#[from] GetToplevelDecorationError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZxdgDecorationManagerV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetToplevelDecorationError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetToplevelDecorationError, ClientError);
|
||||
efrom!(GetToplevelDecorationError, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetToplevelDecoration {
|
||||
pub id: ZxdgToplevelDecorationV1Id,
|
||||
pub toplevel: XdgToplevelId,
|
||||
}
|
||||
impl RequestParser<'_> for GetToplevelDecoration {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
toplevel: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetToplevelDecoration {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"get_toplevel_decoration(id: {}, toplevel: {})",
|
||||
self.id, self.toplevel
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,16 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::client::{Client, ClientError, DynEventFormatter};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::{Decoration, XdgToplevel};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const SET_MODE: u32 = 1;
|
||||
const UNSET_MODE: u32 = 2;
|
||||
|
||||
const CONFIGURE: u32 = 0;
|
||||
use thiserror::Error;
|
||||
use crate::wire::zxdg_toplevel_decoration_v1::*;
|
||||
use crate::wire::ZxdgToplevelDecorationV1Id;
|
||||
|
||||
const CLIENT_SIDE: u32 = 1;
|
||||
const SERVER_SIDE: u32 = 2;
|
||||
|
||||
id!(ZxdgToplevelDecorationV1Id);
|
||||
|
||||
pub struct ZxdgToplevelDecorationV1 {
|
||||
pub id: ZxdgToplevelDecorationV1Id,
|
||||
pub client: Rc<Client>,
|
||||
|
|
@ -39,7 +32,7 @@ impl ZxdgToplevelDecorationV1 {
|
|||
|
||||
fn configure(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
||||
Box::new(Configure {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
mode,
|
||||
})
|
||||
}
|
||||
|
|
@ -87,3 +80,37 @@ impl Object for ZxdgToplevelDecorationV1 {
|
|||
}
|
||||
|
||||
simple_add_obj!(ZxdgToplevelDecorationV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZxdgToplevelDecorationV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestoryError(#[from] DestroyError),
|
||||
#[error("Could not process a `set_mode` request")]
|
||||
SetModeError(#[from] SetModeError),
|
||||
#[error("Could not process a `unset_mode` request")]
|
||||
UnsetModeError(#[from] UnsetModeError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetModeError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetModeError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UnsetModeError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(UnsetModeError, MsgParserError);
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zxdg_toplevel_decoration_v1::{ZxdgToplevelDecorationV1, CONFIGURE};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZxdgToplevelDecorationV1Error {
|
||||
#[error("Could not process a `destroy` request")]
|
||||
DestoryError(#[from] DestroyError),
|
||||
#[error("Could not process a `set_mode` request")]
|
||||
SetModeError(#[from] SetModeError),
|
||||
#[error("Could not process a `unset_mode` request")]
|
||||
UnsetModeError(#[from] UnsetModeError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ClientError);
|
||||
efrom!(DestroyError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetModeError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(SetModeError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UnsetModeError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(UnsetModeError, MsgParserError);
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetMode {
|
||||
pub mode: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetMode {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
mode: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetMode {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_mode(mode: {})", self.mode)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct UnsetMode;
|
||||
impl RequestParser<'_> for UnsetMode {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for UnsetMode {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "unset_mode()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Configure {
|
||||
pub obj: Rc<ZxdgToplevelDecorationV1>,
|
||||
pub mode: u32,
|
||||
}
|
||||
impl EventFormatter for Configure {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CONFIGURE).uint(self.mode);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Configure {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "configure(mode: {})", self.mode)
|
||||
}
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ macro_rules! id {
|
|||
impl $name {
|
||||
pub const NONE: Self = $name(0);
|
||||
|
||||
pub fn from_raw(raw: u32) -> Self {
|
||||
pub const fn from_raw(raw: u32) -> Self {
|
||||
Self(raw)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::fmt::{Display, Formatter};
|
|||
use std::rc::Rc;
|
||||
use crate::wire::WlDisplayId;
|
||||
|
||||
pub const WL_DISPLAY_ID: WlDisplayId = WlDisplayId(1);
|
||||
pub const WL_DISPLAY_ID: WlDisplayId = WlDisplayId::from_raw(1);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub struct ObjectId(u32);
|
||||
|
|
@ -69,6 +69,7 @@ pub enum Interface {
|
|||
WlSeat,
|
||||
WlDrm,
|
||||
ZwpLinuxDmabufV1,
|
||||
ZwpLinuxDmabufFeedbackV1,
|
||||
ZwpLinuxBufferParamsV1,
|
||||
ZxdgDecorationManagerV1,
|
||||
ZxdgToplevelDecorationV1,
|
||||
|
|
@ -109,6 +110,7 @@ impl Interface {
|
|||
Interface::WlDataSource => "wl_data_source",
|
||||
Interface::WlDataOffer => "wl_data_offer",
|
||||
Interface::ZwpLinuxDmabufV1 => "zwp_linux_dmabuf_v1",
|
||||
Interface::ZwpLinuxDmabufFeedbackV1 => "zwp_linux_dmabuf_feedback_v1",
|
||||
Interface::ZwpLinuxBufferParamsV1 => "zwp_linux_buffer_params_v1",
|
||||
Interface::WlDrm => "wl_drm",
|
||||
Interface::ZxdgDecorationManagerV1 => "zxdg_decoration_manager_v1",
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ impl<'a> MsgFormatter<'a> {
|
|||
self.object(obj).uint(event)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn array<F: FnOnce(&mut MsgFormatter<'_>)>(&mut self, f: F) -> &mut Self {
|
||||
let pos = self.buf.out_pos;
|
||||
self.uint(0);
|
||||
|
|
@ -81,6 +82,14 @@ impl<'a> MsgFormatter<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn binary<T: ?Sized>(&mut self, t: &T) -> &mut Self {
|
||||
self.uint(mem::size_of_val(t) as u32);
|
||||
self.buf.write(uapi::as_maybe_uninit_bytes(t));
|
||||
let none = [MaybeUninit::new(0); 4];
|
||||
self.buf.write(&none[..self.buf.out_pos.wrapping_neg() & 3]);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn write_len(self) {
|
||||
assert!(self.buf.out_pos - self.pos >= 8);
|
||||
assert_eq!(self.pos % 4, 0);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::{mem, ptr};
|
||||
use std::rc::Rc;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::globals::GlobalName;
|
||||
|
|
@ -5,12 +6,16 @@ use crate::object::ObjectId;
|
|||
use crate::utils::buffd::BufFdIn;
|
||||
use bstr::{BStr, ByteSlice};
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use uapi::{OwnedFd, Pod};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum MsgParserError {
|
||||
#[error("The message ended unexpectedly")]
|
||||
UnexpectedEof,
|
||||
#[error("The binary array contains more than the required number of bytes")]
|
||||
BinaryArrayTooLarge,
|
||||
#[error("The size of the binary array is not a multiple of the element size")]
|
||||
BinaryArraySize,
|
||||
#[error("The message contained a string of size 0")]
|
||||
EmptyString,
|
||||
#[error("Message is missing a required file descriptor")]
|
||||
|
|
@ -56,6 +61,7 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
|||
self.int().map(|i| ObjectId::from_raw(i as u32).into())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn global(&mut self) -> Result<GlobalName, MsgParserError> {
|
||||
self.int().map(|i| GlobalName::from_raw(i as u32))
|
||||
}
|
||||
|
|
@ -105,4 +111,33 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
|||
self.pos += cap;
|
||||
Ok(&self.data[pos..pos + len])
|
||||
}
|
||||
|
||||
pub fn binary<T: Pod>(&mut self) -> Result<T, MsgParserError> {
|
||||
let array = self.array()?;
|
||||
if array.len() < mem::size_of::<T>() {
|
||||
return Err(MsgParserError::UnexpectedEof);
|
||||
}
|
||||
if array.len() > mem::size_of::<T>() {
|
||||
return Err(MsgParserError::BinaryArrayTooLarge);
|
||||
}
|
||||
unsafe {
|
||||
Ok(ptr::read_unaligned(array.as_ptr() as _))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn binary_array<T: Pod>(&mut self) -> Result<&'b [T], MsgParserError> {
|
||||
if std::mem::align_of::<T>() > 4 {
|
||||
panic!("Alignment of binary array element is too large");
|
||||
};
|
||||
if std::mem::size_of::<T>() == 0 {
|
||||
panic!("Size of binary array element is 0");
|
||||
};
|
||||
let array = self.array()?;
|
||||
if array.len() % mem::size_of::<T>() != 0 {
|
||||
return Err(MsgParserError::BinaryArraySize);
|
||||
}
|
||||
unsafe {
|
||||
Ok(std::slice::from_raw_parts(array.as_ptr() as _, array.len() / mem::size_of::<T>()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue