autocommit 2022-02-06 03:46:03 CET
This commit is contained in:
parent
59ce74681a
commit
c92346324b
60 changed files with 1292 additions and 1958 deletions
|
|
@ -164,10 +164,8 @@ impl Drop for ClientHolder {
|
|||
|
||||
pub trait EventFormatter: Debug {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>);
|
||||
fn obj(&self) -> &dyn Object;
|
||||
fn should_log(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn id(&self) -> ObjectId;
|
||||
fn interface(&self) -> Interface;
|
||||
}
|
||||
|
||||
pub type DynEventFormatter = Box<dyn EventFormatter>;
|
||||
|
|
|
|||
|
|
@ -4,22 +4,16 @@ use crate::utils::buffd::MsgParser;
|
|||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::wire::org_kde_kwin_server_decoration::*;
|
||||
|
||||
mod types;
|
||||
|
||||
const RELEASE: u32 = 0;
|
||||
const REQUEST_MODE: u32 = 1;
|
||||
|
||||
const MODE: u32 = 0;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const NONE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const CLIENT: u32 = 1;
|
||||
const SERVER: u32 = 2;
|
||||
|
||||
id!(OrgKdeKwinServerDecorationId);
|
||||
|
||||
pub struct OrgKdeKwinServerDecoration {
|
||||
id: OrgKdeKwinServerDecorationId,
|
||||
client: Rc<Client>,
|
||||
|
|
@ -37,7 +31,7 @@ impl OrgKdeKwinServerDecoration {
|
|||
|
||||
pub fn mode(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
||||
Box::new(Mode {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
mode,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,49 +38,3 @@ pub enum RequestModeError {
|
|||
}
|
||||
efrom!(RequestModeError, ClientError);
|
||||
efrom!(RequestModeError, ParseError, MsgParserError);
|
||||
|
||||
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, "release()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct RequestMode {
|
||||
pub mode: u32,
|
||||
}
|
||||
impl RequestParser<'_> for RequestMode {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
mode: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for RequestMode {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "request_mode(mode: {})", self.mode)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Mode {
|
||||
pub obj: Rc<OrgKdeKwinServerDecoration>,
|
||||
pub mode: u32,
|
||||
}
|
||||
impl EventFormatter for Mode {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, MODE).uint(self.mode);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Mode {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "mode(mode: {})", self.mode)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,21 +5,16 @@ use crate::object::Object;
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::wire::org_kde_kwin_server_decoration_manager::*;
|
||||
|
||||
mod types;
|
||||
|
||||
const CREATE: u32 = 0;
|
||||
|
||||
const DEFAULT_MODE: u32 = 0;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const NONE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const CLIENT: u32 = 1;
|
||||
const SERVER: u32 = 2;
|
||||
|
||||
id!(OrgKdeKwinServerDecorationManagerGlobalId);
|
||||
|
||||
pub struct OrgKdeKwinServerDecorationManagerGlobal {
|
||||
name: GlobalName,
|
||||
}
|
||||
|
|
@ -72,7 +67,7 @@ pub struct OrgKdeKwinServerDecorationManager {
|
|||
impl OrgKdeKwinServerDecorationManager {
|
||||
fn default_mode(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
||||
Box::new(DefaultMode {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
mode,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,39 +32,3 @@ pub enum CreateError {
|
|||
}
|
||||
efrom!(CreateError, ClientError);
|
||||
efrom!(CreateError, ParseError, MsgParserError);
|
||||
|
||||
pub(super) struct Create {
|
||||
pub id: OrgKdeKwinServerDecorationId,
|
||||
pub surface: WlSurfaceId,
|
||||
}
|
||||
impl RequestParser<'_> for Create {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
surface: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Create {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create(id: {}, surface: {})", self.id, self.surface)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DefaultMode {
|
||||
pub obj: Rc<OrgKdeKwinServerDecorationManager>,
|
||||
pub mode: u32,
|
||||
}
|
||||
impl EventFormatter for DefaultMode {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DEFAULT_MODE).uint(self.mode);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for DefaultMode {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "default_mode(mode: {})", self.mode)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,9 @@ use crate::utils::buffd::MsgParser;
|
|||
use crate::utils::clonecell::CloneCell;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use crate::wire::wl_buffer::*;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
|
||||
const RELEASE: u32 = 0;
|
||||
|
||||
id!(WlBufferId);
|
||||
|
||||
pub enum WlBufferStorage {
|
||||
Shm { mem: ClientMemOffset, stride: i32 },
|
||||
Dmabuf(Rc<Image>),
|
||||
|
|
@ -122,8 +117,8 @@ impl WlBuffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn release(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Release { obj: self.clone() })
|
||||
pub fn release(&self) -> DynEventFormatter {
|
||||
Box::new(Release { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,32 +33,3 @@ pub enum DestroyError {
|
|||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, 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 Release {
|
||||
pub obj: Rc<WlBuffer>,
|
||||
}
|
||||
impl EventFormatter for Release {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, RELEASE);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Release {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "release()")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@ use crate::client::DynEventFormatter;
|
|||
use crate::object::Object;
|
||||
use std::rc::Rc;
|
||||
use types::*;
|
||||
|
||||
const DONE: u32 = 0;
|
||||
|
||||
id!(WlCallbackId);
|
||||
use crate::wire::wl_callback::*;
|
||||
|
||||
pub struct WlCallback {
|
||||
id: WlCallbackId,
|
||||
|
|
@ -19,7 +16,7 @@ impl WlCallback {
|
|||
}
|
||||
|
||||
pub fn done(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Done { obj: self.clone() })
|
||||
Box::new(Done { self_id: self.id, callback_data: 0 })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,20 +8,3 @@ use thiserror::Error;
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlCallbackError {}
|
||||
|
||||
pub(super) struct Done {
|
||||
pub obj: Rc<WlCallback>,
|
||||
}
|
||||
impl EventFormatter for Done {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DONE).uint(0);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Done {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "done(callback_data: 0)")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,35 +40,3 @@ pub enum CreateRegionError {
|
|||
|
||||
efrom!(CreateRegionError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateRegionError, ClientError, ClientError);
|
||||
|
||||
pub(super) struct CreateSurface {
|
||||
pub id: WlSurfaceId,
|
||||
}
|
||||
impl RequestParser<'_> for CreateSurface {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateSurface {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_surface(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct CreateRegion {
|
||||
pub id: WlRegionId,
|
||||
}
|
||||
impl RequestParser<'_> for CreateRegion {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateRegion {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_region(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,23 +8,11 @@ use crate::object::Object;
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const START_DRAG: u32 = 0;
|
||||
const SET_SELECTION: u32 = 1;
|
||||
const RELEASE: u32 = 2;
|
||||
|
||||
const DATA_OFFER: u32 = 0;
|
||||
const ENTER: u32 = 1;
|
||||
const LEAVE: u32 = 2;
|
||||
const MOTION: u32 = 4;
|
||||
const DROP: u32 = 5;
|
||||
const SELECTION: u32 = 5;
|
||||
use crate::wire::wl_data_device::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
||||
id!(WlDataDeviceId);
|
||||
|
||||
pub struct WlDataDevice {
|
||||
pub id: WlDataDeviceId,
|
||||
pub manager: Rc<WlDataDeviceManager>,
|
||||
|
|
@ -42,14 +30,14 @@ impl WlDataDevice {
|
|||
|
||||
pub fn data_offer(self: &Rc<Self>, id: WlDataOfferId) -> DynEventFormatter {
|
||||
Box::new(DataOffer {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn selection(self: &Rc<Self>, id: WlDataOfferId) -> DynEventFormatter {
|
||||
Box::new(Selection {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,197 +55,3 @@ pub enum ReleaseError {
|
|||
}
|
||||
efrom!(ReleaseError, ParseFailed, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError);
|
||||
|
||||
pub(super) struct StartDrag {
|
||||
pub source: WlDataSourceId,
|
||||
pub origin: WlSurfaceId,
|
||||
pub icon: WlSurfaceId,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for StartDrag {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
source: parser.object()?,
|
||||
origin: parser.object()?,
|
||||
icon: parser.object()?,
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for StartDrag {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"start_drag(source: {}, origin: {}, icon: {}, serial: {})",
|
||||
self.source, self.origin, self.icon, self.serial
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetSelection {
|
||||
pub source: WlDataSourceId,
|
||||
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 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, "release()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DataOffer {
|
||||
pub obj: Rc<WlDataDevice>,
|
||||
pub id: WlDataOfferId,
|
||||
}
|
||||
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 Enter {
|
||||
pub obj: Rc<WlDataDevice>,
|
||||
pub serial: u32,
|
||||
pub surface: WlSurfaceId,
|
||||
pub x: Fixed,
|
||||
pub y: Fixed,
|
||||
pub id: WlDataOfferId,
|
||||
}
|
||||
impl EventFormatter for Enter {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, ENTER)
|
||||
.uint(self.serial)
|
||||
.object(self.surface)
|
||||
.fixed(self.x)
|
||||
.fixed(self.y)
|
||||
.object(self.id);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Enter {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"enter(serial: {}, surface: {}, x: {}, y: {}, id: {})",
|
||||
self.serial, self.surface, self.x, self.y, self.id
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Leave {
|
||||
pub obj: Rc<WlDataDevice>,
|
||||
}
|
||||
impl EventFormatter for Leave {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, LEAVE);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Leave {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "leave()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Motion {
|
||||
pub obj: Rc<WlDataDevice>,
|
||||
pub time: u32,
|
||||
pub x: Fixed,
|
||||
pub y: Fixed,
|
||||
}
|
||||
impl EventFormatter for Motion {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, MOTION)
|
||||
.uint(self.time)
|
||||
.fixed(self.x)
|
||||
.fixed(self.y);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Motion {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"motion(time: {}, x: {}, y: {})",
|
||||
self.time, self.x, self.y
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Drop {
|
||||
pub obj: Rc<WlDataDevice>,
|
||||
}
|
||||
impl EventFormatter for Drop {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DROP);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Drop {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "drop()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Selection {
|
||||
pub obj: Rc<WlDataDevice>,
|
||||
pub id: WlDataOfferId,
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
//
|
||||
// msgs! {
|
||||
// WlDataDevice::Selection = 5 {
|
||||
// id: id(WlDataOffer),
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ use crate::object::Object;
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const CREATE_DATA_SOURCE: u32 = 0;
|
||||
const GET_DATA_DEVICE: u32 = 1;
|
||||
use crate::wire::wl_data_device_manager::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const DND_NONE: u32 = 0;
|
||||
|
|
@ -21,8 +19,6 @@ const DND_MOVE: u32 = 2;
|
|||
#[allow(dead_code)]
|
||||
const DND_ASK: u32 = 4;
|
||||
|
||||
id!(WlDataDeviceManagerId);
|
||||
|
||||
pub struct WlDataDeviceManagerGlobal {
|
||||
name: GlobalName,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,37 +36,3 @@ pub enum GetDataDeviceError {
|
|||
}
|
||||
efrom!(GetDataDeviceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetDataDeviceError, ClientError);
|
||||
|
||||
pub(super) struct CreateDataSource {
|
||||
pub id: WlDataSourceId,
|
||||
}
|
||||
impl RequestParser<'_> for CreateDataSource {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateDataSource {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_data_source(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetDataDevice {
|
||||
pub id: WlDataDeviceId,
|
||||
pub seat: WlSeatId,
|
||||
}
|
||||
impl RequestParser<'_> for GetDataDevice {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
seat: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetDataDevice {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_data_device(id: {}, seat: {})", self.id, self.seat,)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,16 +9,7 @@ use crate::utils::clonecell::CloneCell;
|
|||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const ACCEPT: u32 = 0;
|
||||
const RECEIVE: u32 = 1;
|
||||
const DESTROY: u32 = 2;
|
||||
const FINISH: u32 = 3;
|
||||
const SET_ACTIONS: u32 = 4;
|
||||
|
||||
const OFFER: u32 = 0;
|
||||
const SOURCE_ACTIONS: u32 = 1;
|
||||
const ACTION: u32 = 2;
|
||||
use crate::wire::wl_data_offer::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_FINISH: u32 = 0;
|
||||
|
|
@ -29,8 +20,6 @@ const INVALID_ACTION: u32 = 2;
|
|||
#[allow(dead_code)]
|
||||
const INVALID_OFFER: u32 = 3;
|
||||
|
||||
id!(WlDataOfferId);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub enum DataOfferRole {
|
||||
Selection,
|
||||
|
|
@ -79,19 +68,19 @@ impl WlDataOffer {
|
|||
}
|
||||
|
||||
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 accept(&self, parser: MsgParser<'_, '_>) -> Result<(), AcceptError> {
|
||||
let _req: Accept = self.client.parse(self, parser)?;
|
||||
let _req: AcceptIn = self.client.parse(self, parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -74,149 +74,3 @@ pub enum SetActionsError {
|
|||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, ClientError);
|
||||
|
||||
pub(super) struct Accept<'a> {
|
||||
pub serial: u32,
|
||||
pub mime_type: &'a BStr,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for Accept<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
serial: parser.uint()?,
|
||||
mime_type: parser.bstr()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Accept<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"accept(serial: {}, mime_type: {:?})",
|
||||
self.serial, self.mime_type
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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 Finish;
|
||||
impl RequestParser<'_> for Finish {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Finish {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "finish()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SetActions {
|
||||
pub dnd_actions: u32,
|
||||
pub preferred_action: u32,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for SetActions {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
dnd_actions: parser.uint()?,
|
||||
preferred_action: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetActions {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_actions(dnd_actions: {}, preferred_action: {})",
|
||||
self.dnd_actions, self.preferred_action
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Offer {
|
||||
pub obj: Rc<WlDataOffer>,
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct SourceActions {
|
||||
pub obj: Rc<WlDataOffer>,
|
||||
pub source_actions: u32,
|
||||
}
|
||||
impl EventFormatter for SourceActions {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, SOURCE_ACTIONS)
|
||||
.uint(self.source_actions);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for SourceActions {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "source_actions(source_actions: {})", self.source_actions,)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Action {
|
||||
pub obj: Rc<WlDataOffer>,
|
||||
pub dnd_action: u32,
|
||||
}
|
||||
impl EventFormatter for Action {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, ACTION).uint(self.dnd_action);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Action {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "action(dnd_action: {})", self.dnd_action,)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,25 +11,13 @@ use std::cell::RefCell;
|
|||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
const OFFER: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
const SET_ACTIONS: u32 = 2;
|
||||
|
||||
const TARGET: u32 = 0;
|
||||
const SEND: u32 = 1;
|
||||
const CANCELLED: u32 = 2;
|
||||
const DND_DROP_PERFORMED: u32 = 4;
|
||||
const DND_FINISHED: u32 = 5;
|
||||
const ACTION: u32 = 5;
|
||||
use crate::wire::wl_data_source::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_ACTION_MASK: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const INVALID_SOURCE: u32 = 1;
|
||||
|
||||
id!(WlDataSourceId);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Attachment {
|
||||
seat: Rc<WlSeatGlobal>,
|
||||
|
|
@ -101,19 +89,19 @@ impl WlDataSource {
|
|||
}
|
||||
|
||||
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, 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()
|
||||
|
|
|
|||
|
|
@ -54,160 +54,3 @@ pub enum SetActionsError {
|
|||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, 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 SetActions {
|
||||
pub actions: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetActions {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
actions: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetActions {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "set_actions(actions: {})", self.actions)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Target {
|
||||
pub obj: Rc<WlDataSource>,
|
||||
pub mime_type: BString,
|
||||
}
|
||||
impl EventFormatter for Target {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, TARGET).string(&self.mime_type);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Target {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "target(mime_type: {:?})", self.mime_type)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Send {
|
||||
pub obj: Rc<WlDataSource>,
|
||||
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<WlDataSource>,
|
||||
}
|
||||
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()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DndDropPerformed {
|
||||
pub obj: Rc<WlDataSource>,
|
||||
}
|
||||
impl EventFormatter for DndDropPerformed {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DND_DROP_PERFORMED);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for DndDropPerformed {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "dnd_drop_performed()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DndFinished {
|
||||
pub obj: Rc<WlDataSource>,
|
||||
}
|
||||
impl EventFormatter for DndFinished {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DND_FINISHED);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for DndFinished {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "dnd_finished()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Action {
|
||||
pub obj: Rc<WlDataSource>,
|
||||
pub dnd_action: u32,
|
||||
}
|
||||
impl EventFormatter for Action {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, ACTION).uint(self.dnd_action);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Action {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "action(dnd_action: {})", self.dnd_action)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,7 @@ use crate::object::{Object, ObjectId, WL_DISPLAY_ID};
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const SYNC: u32 = 0;
|
||||
const GET_REGISTRY: u32 = 1;
|
||||
|
||||
const ERROR: u32 = 0;
|
||||
const DELETE_ID: u32 = 1;
|
||||
use crate::wire::wl_display::*;
|
||||
|
||||
const INVALID_OBJECT: u32 = 0;
|
||||
const INVALID_METHOD: u32 = 1;
|
||||
|
|
@ -21,7 +16,7 @@ const NO_MEMORY: u32 = 2;
|
|||
const IMPLEMENTATION: u32 = 3;
|
||||
|
||||
pub struct WlDisplay {
|
||||
id: ObjectId,
|
||||
id: WlDisplayId,
|
||||
client: Rc<Client>,
|
||||
}
|
||||
|
||||
|
|
@ -53,15 +48,15 @@ impl WlDisplay {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn error(
|
||||
pub fn error<O: Into<ObjectId>>(
|
||||
self: &Rc<Self>,
|
||||
object_id: ObjectId,
|
||||
object_id: O,
|
||||
code: u32,
|
||||
message: String,
|
||||
) -> DynEventFormatter {
|
||||
Box::new(Error {
|
||||
obj: self.clone(),
|
||||
object_id,
|
||||
Box::new(ErrorOut {
|
||||
self_id: self.id,
|
||||
object_id: object_id.into(),
|
||||
code,
|
||||
message,
|
||||
})
|
||||
|
|
@ -89,8 +84,8 @@ impl WlDisplay {
|
|||
|
||||
pub fn delete_id(self: &Rc<Self>, id: ObjectId) -> DynEventFormatter {
|
||||
Box::new(DeleteId {
|
||||
obj: self.clone(),
|
||||
id,
|
||||
self_id: self.id,
|
||||
id: id.raw(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,80 +44,3 @@ pub enum SyncError {
|
|||
|
||||
efrom!(SyncError, ParseFailed, MsgParserError);
|
||||
efrom!(SyncError, ClientError);
|
||||
|
||||
pub(super) struct GetRegistry {
|
||||
pub registry: WlRegistryId,
|
||||
}
|
||||
impl RequestParser<'_> for GetRegistry {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
registry: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetRegistry {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_registry(registry: {})", self.registry)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Sync {
|
||||
pub callback: WlCallbackId,
|
||||
}
|
||||
impl RequestParser<'_> for Sync {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
callback: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Sync {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "sync(callback: {})", self.callback)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DeleteId {
|
||||
pub obj: Rc<WlDisplay>,
|
||||
pub id: ObjectId,
|
||||
}
|
||||
impl EventFormatter for DeleteId {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(WL_DISPLAY_ID, DELETE_ID).object(self.id);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for DeleteId {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "delete_id(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Error {
|
||||
pub obj: Rc<WlDisplay>,
|
||||
pub object_id: ObjectId,
|
||||
pub code: u32,
|
||||
pub message: String,
|
||||
}
|
||||
impl EventFormatter for Error {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(WL_DISPLAY_ID, ERROR)
|
||||
.object(self.object_id)
|
||||
.uint(self.code)
|
||||
.string(&self.message);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Error {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"error(object_id: {}, code: {}, message: {:?})",
|
||||
self.object_id, self.code, self.message
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,21 +4,12 @@ use crate::object::Object;
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::ffi::CString;
|
||||
use std::rc::Rc;
|
||||
use bstr::ByteSlice;
|
||||
pub use types::*;
|
||||
use crate::wire::wl_drm::*;
|
||||
|
||||
mod types;
|
||||
|
||||
id!(WlDrmId);
|
||||
|
||||
const AUTHENTICATE: u32 = 0;
|
||||
const CREATE_BUFFER: u32 = 1;
|
||||
const CREATE_PLANAR_BUFFER: u32 = 2;
|
||||
|
||||
const DEVICE: u32 = 0;
|
||||
const FORMAT: u32 = 1;
|
||||
const AUTHENTICATED: u32 = 2;
|
||||
const CAPABILITIES: u32 = 3;
|
||||
|
||||
const PRIME: u32 = 1;
|
||||
|
||||
pub struct WlDrmGlobal {
|
||||
|
|
@ -72,19 +63,19 @@ pub struct WlDrm {
|
|||
|
||||
impl WlDrm {
|
||||
fn device(self: &Rc<Self>, device: &Rc<CString>) -> DynEventFormatter {
|
||||
Box::new(Device {
|
||||
obj: self.clone(),
|
||||
name: device.clone(),
|
||||
Box::new(DeviceOut {
|
||||
self_id: self.id,
|
||||
name: device.as_bytes().as_bstr().to_owned(),
|
||||
})
|
||||
}
|
||||
|
||||
fn authenticated(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Authenticated { obj: self.clone() })
|
||||
Box::new(Authenticated { self_id: self.id })
|
||||
}
|
||||
|
||||
fn capabilities(self: &Rc<Self>, value: u32) -> DynEventFormatter {
|
||||
Box::new(Capabilities {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
value,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,166 +45,3 @@ pub enum CreatePlanarBufferError {
|
|||
Unsupported,
|
||||
}
|
||||
efrom!(CreatePlanarBufferError, ParseError, MsgParserError);
|
||||
|
||||
pub(super) struct Authenticate {
|
||||
id: u32,
|
||||
}
|
||||
impl RequestParser<'_> for Authenticate {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self { id: parser.uint()? })
|
||||
}
|
||||
}
|
||||
impl Debug for Authenticate {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "authenticate(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct CreateBuffer {
|
||||
pub id: WlBufferId,
|
||||
pub name: u32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub stride: u32,
|
||||
pub format: u32,
|
||||
}
|
||||
impl RequestParser<'_> for CreateBuffer {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
name: parser.uint()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
stride: parser.uint()?,
|
||||
format: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateBuffer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"create_buffer(id: {}, name: {}, width: {}, height: {}, stride: {}, format: {})",
|
||||
self.id, self.name, self.width, self.height, self.stride, self.format,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct CreatePlanarBuffer {
|
||||
id: WlBufferId,
|
||||
name: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
format: u32,
|
||||
offset0: i32,
|
||||
stride0: i32,
|
||||
offset1: i32,
|
||||
stride1: i32,
|
||||
offset2: i32,
|
||||
stride2: i32,
|
||||
}
|
||||
impl RequestParser<'_> for CreatePlanarBuffer {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
name: parser.uint()?,
|
||||
width: parser.int()?,
|
||||
height: parser.int()?,
|
||||
format: parser.uint()?,
|
||||
offset0: parser.int()?,
|
||||
stride0: parser.int()?,
|
||||
offset1: parser.int()?,
|
||||
stride1: parser.int()?,
|
||||
offset2: parser.int()?,
|
||||
stride2: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreatePlanarBuffer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_params(id: {}, name: {}, width: {}, height: {}, format: {}, offset0: {}, stride0: {}, offset1: {}, stride1: {}, offset2: {}, stride2: {})",
|
||||
self.id,
|
||||
self.name,
|
||||
self.width,
|
||||
self.height,
|
||||
self.format,
|
||||
self.offset0,
|
||||
self.stride0,
|
||||
self.offset1,
|
||||
self.stride1,
|
||||
self.offset2,
|
||||
self.stride2,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Device {
|
||||
pub obj: Rc<WlDrm>,
|
||||
pub name: Rc<CString>,
|
||||
}
|
||||
impl EventFormatter for Device {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DEVICE).string(self.name.as_bytes());
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Device {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "device(name: {:?})", self.name)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Format {
|
||||
pub obj: Rc<WlDrm>,
|
||||
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 Authenticated {
|
||||
pub obj: Rc<WlDrm>,
|
||||
}
|
||||
impl EventFormatter for Authenticated {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, AUTHENTICATED);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Authenticated {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "authenticated()",)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Capabilities {
|
||||
pub obj: Rc<WlDrm>,
|
||||
pub value: u32,
|
||||
}
|
||||
impl EventFormatter for Capabilities {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CAPABILITIES).uint(self.value);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Capabilities {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "capabilities(value: {})", self.value,)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,7 @@ use std::collections::hash_map::Entry;
|
|||
use std::iter;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
id!(WlOutputId);
|
||||
|
||||
const RELEASE: u32 = 0;
|
||||
|
||||
const GEOMETRY: u32 = 0;
|
||||
const MODE: u32 = 1;
|
||||
const DONE: u32 = 2;
|
||||
const SCALE: u32 = 3;
|
||||
use crate::wire::wl_output::*;
|
||||
|
||||
const SP_UNKNOWN: i32 = 0;
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -186,7 +178,7 @@ impl WlOutput {
|
|||
|
||||
fn mode(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Mode {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
flags: MODE_CURRENT,
|
||||
width: self.global.width.get() as _,
|
||||
height: self.global.height.get() as _,
|
||||
|
|
@ -196,13 +188,13 @@ impl WlOutput {
|
|||
|
||||
fn scale(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Scale {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
factor: 1,
|
||||
})
|
||||
}
|
||||
|
||||
fn done(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Done { obj: self.clone() })
|
||||
Box::new(Done { self_id: self.id })
|
||||
}
|
||||
|
||||
fn remove_binding(&self) {
|
||||
|
|
|
|||
|
|
@ -24,113 +24,3 @@ pub enum ReleaseError {
|
|||
}
|
||||
efrom!(ReleaseError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
||||
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, "release()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Geometry {
|
||||
pub obj: Rc<WlOutput>,
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub physical_width: i32,
|
||||
pub physical_height: i32,
|
||||
pub subpixel: i32,
|
||||
pub make: String,
|
||||
pub model: String,
|
||||
pub transform: i32,
|
||||
}
|
||||
impl EventFormatter for Geometry {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, GEOMETRY)
|
||||
.int(self.x)
|
||||
.int(self.y)
|
||||
.int(self.physical_width)
|
||||
.int(self.physical_height)
|
||||
.int(self.subpixel)
|
||||
.string(&self.make)
|
||||
.string(&self.model)
|
||||
.int(self.transform);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Geometry {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "geometry(x: {}, y: {}, physical_width: {}, physical_height: {}, subpixel: {}, make: {}, model: {}, transform: {})",
|
||||
self.x, self.y, self.physical_width, self.physical_height, self.subpixel, self.make, self.model, self.transform)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Mode {
|
||||
pub obj: Rc<WlOutput>,
|
||||
pub flags: u32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub refresh: i32,
|
||||
}
|
||||
impl EventFormatter for Mode {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, MODE)
|
||||
.uint(self.flags)
|
||||
.int(self.width)
|
||||
.int(self.height)
|
||||
.int(self.refresh);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Mode {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"mode(flags: 0x{:x}, width: {}, height: {}, refresh: {})",
|
||||
self.flags, self.width, self.height, self.refresh
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Done {
|
||||
pub obj: Rc<WlOutput>,
|
||||
}
|
||||
impl EventFormatter for Done {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DONE);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Done {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "done()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Scale {
|
||||
pub obj: Rc<WlOutput>,
|
||||
pub factor: i32,
|
||||
}
|
||||
impl EventFormatter for Scale {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, SCALE).int(self.factor);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Scale {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "scale(factor: {})", self.factor)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,7 @@ use crate::utils::buffd::MsgParser;
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const ADD: u32 = 1;
|
||||
const SUBTRACT: u32 = 2;
|
||||
|
||||
id!(WlRegionId);
|
||||
use crate::wire::wl_region::*;
|
||||
|
||||
pub struct WlRegion {
|
||||
id: WlRegionId,
|
||||
|
|
|
|||
|
|
@ -40,67 +40,3 @@ pub enum SubtractError {
|
|||
NegativeExtents,
|
||||
}
|
||||
efrom!(SubtractError, 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 Add {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for Add {
|
||||
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 Add {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"add(x: {}, y: {}, width: {}, height: {})",
|
||||
self.x, self.y, self.width, self.height,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Subtract {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
impl RequestParser<'_> for Subtract {
|
||||
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 Subtract {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"subtract(x: {}, y: {}, width: {}, height: {})",
|
||||
self.x, self.y, self.width, self.height,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,7 @@ use crate::object::Object;
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const BIND: u32 = 0;
|
||||
|
||||
const GLOBAL: u32 = 0;
|
||||
const GLOBAL_REMOVE: u32 = 1;
|
||||
|
||||
id!(WlRegistryId);
|
||||
use crate::wire::wl_registry::*;
|
||||
|
||||
pub struct WlRegistry {
|
||||
id: WlRegistryId,
|
||||
|
|
@ -28,16 +22,18 @@ impl WlRegistry {
|
|||
}
|
||||
|
||||
pub fn global(self: &Rc<Self>, global: &Rc<dyn Global>) -> DynEventFormatter {
|
||||
Box::new(GlobalE {
|
||||
obj: self.clone(),
|
||||
global: global.clone(),
|
||||
Box::new(GlobalOut {
|
||||
self_id: self.id,
|
||||
name: global.name().raw(),
|
||||
interface: global.interface().name().to_string(),
|
||||
version: global.version(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn global_remove(self: &Rc<Self>, name: GlobalName) -> DynEventFormatter {
|
||||
Box::new(GlobalRemove {
|
||||
obj: self.clone(),
|
||||
name,
|
||||
self_id: self.id,
|
||||
name: name.raw(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ pub enum BindError {
|
|||
#[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 {
|
||||
|
|
@ -43,76 +45,3 @@ pub struct VersionError {
|
|||
pub actual: u32,
|
||||
}
|
||||
|
||||
efrom!(BindError, ParseError, MsgParserError);
|
||||
efrom!(BindError, GlobalsError);
|
||||
|
||||
pub(super) struct GlobalE {
|
||||
pub obj: Rc<WlRegistry>,
|
||||
pub global: Rc<dyn Global>,
|
||||
}
|
||||
impl EventFormatter for GlobalE {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, GLOBAL)
|
||||
.uint(self.global.name().raw())
|
||||
.string(self.global.interface().name())
|
||||
.uint(self.global.version());
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for GlobalE {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"global(name: {}, interface: {:?}, version: {})",
|
||||
self.global.name(),
|
||||
self.global.interface().name(),
|
||||
self.global.version()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GlobalRemove {
|
||||
pub obj: Rc<WlRegistry>,
|
||||
pub name: GlobalName,
|
||||
}
|
||||
impl EventFormatter for GlobalRemove {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, GLOBAL_REMOVE).uint(self.name.raw());
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for GlobalRemove {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "global_remove(name: {})", self.name)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Bind<'a> {
|
||||
pub name: GlobalName,
|
||||
pub id: ObjectId,
|
||||
pub interface: &'a BStr,
|
||||
pub version: u32,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for Bind<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
name: parser.global()?,
|
||||
interface: parser.bstr()?,
|
||||
version: parser.uint()?,
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Bind<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"bind(name: {}, interface: {:?}, version: {}, id: {})",
|
||||
self.name, self.interface, self.version, self.id
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,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::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeSeatState {
|
||||
|
|
@ -371,8 +371,8 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn surface_primary_selection_device_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
||||
where
|
||||
F: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>) -> DynEventFormatter,
|
||||
where
|
||||
F: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>) -> DynEventFormatter,
|
||||
{
|
||||
let client = &surface.client;
|
||||
self.for_each_primary_selection_device(ver, client.id, |p| {
|
||||
|
|
|
|||
|
|
@ -39,19 +39,11 @@ pub use handling::NodeSeatState;
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::io::Write;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use uapi::{c, OwnedFd};
|
||||
|
||||
id!(WlSeatId);
|
||||
|
||||
const GET_POINTER: u32 = 0;
|
||||
const GET_KEYBOARD: u32 = 1;
|
||||
const GET_TOUCH: u32 = 2;
|
||||
const RELEASE: u32 = 3;
|
||||
|
||||
const CAPABILITIES: u32 = 0;
|
||||
const NAME: u32 = 1;
|
||||
use crate::wire::wl_seat::*;
|
||||
|
||||
const POINTER: u32 = 1;
|
||||
const KEYBOARD: u32 = 2;
|
||||
|
|
@ -317,15 +309,15 @@ pub struct WlSeat {
|
|||
impl WlSeat {
|
||||
fn capabilities(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Capabilities {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
capabilities: POINTER | KEYBOARD,
|
||||
})
|
||||
}
|
||||
|
||||
fn name(self: &Rc<Self>, name: &Rc<String>) -> DynEventFormatter {
|
||||
Box::new(Name {
|
||||
obj: self.clone(),
|
||||
name: name.clone(),
|
||||
Box::new(NameOut {
|
||||
self_id: self.id,
|
||||
name: name.deref().clone(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,100 +66,3 @@ pub enum ReleaseError {
|
|||
}
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
|
||||
pub(super) struct GetPointer {
|
||||
pub id: WlPointerId,
|
||||
}
|
||||
impl RequestParser<'_> for GetPointer {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetPointer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_pointer(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetKeyboard {
|
||||
pub id: WlKeyboardId,
|
||||
}
|
||||
impl RequestParser<'_> for GetKeyboard {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetKeyboard {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_keyboard(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetTouch {
|
||||
pub id: WlTouchId,
|
||||
}
|
||||
impl RequestParser<'_> for GetTouch {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetTouch {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_touch(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
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, "release()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Capabilities {
|
||||
pub obj: Rc<WlSeat>,
|
||||
pub capabilities: u32,
|
||||
}
|
||||
impl EventFormatter for Capabilities {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CAPABILITIES)
|
||||
.uint(self.capabilities);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Capabilities {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "capabilities(capabilities: {})", self.capabilities)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Name {
|
||||
pub obj: Rc<WlSeat>,
|
||||
pub name: Rc<String>,
|
||||
}
|
||||
impl EventFormatter for Name {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, NAME).string(self.name.as_bytes());
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Name {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "name(name: {})", self.name)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,15 +8,7 @@ use crate::utils::buffd::MsgParser;
|
|||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use uapi::{c, Errno, OwnedFd};
|
||||
|
||||
const RELEASE: u32 = 0;
|
||||
|
||||
const KEYMAP: u32 = 0;
|
||||
const ENTER: u32 = 1;
|
||||
const LEAVE: u32 = 2;
|
||||
const KEY: u32 = 3;
|
||||
const MODIFIERS: u32 = 4;
|
||||
const REPEAT_INFO: u32 = 5;
|
||||
use crate::wire::wl_keyboard::*;
|
||||
|
||||
pub const REPEAT_INFO_SINCE: u32 = 4;
|
||||
|
||||
|
|
@ -24,13 +16,9 @@ pub const REPEAT_INFO_SINCE: u32 = 4;
|
|||
const NO_KEYMAP: u32 = 0;
|
||||
pub(super) const XKB_V1: u32 = 1;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(super) const RELEASED: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
pub(super) const PRESSED: u32 = 1;
|
||||
|
||||
id!(WlKeyboardId);
|
||||
|
||||
pub struct WlKeyboard {
|
||||
id: WlKeyboardId,
|
||||
seat: Rc<WlSeat>,
|
||||
|
|
@ -76,41 +64,38 @@ impl WlKeyboard {
|
|||
|
||||
pub fn keymap(self: &Rc<Self>, format: u32, fd: Rc<OwnedFd>, size: u32) -> DynEventFormatter {
|
||||
Box::new(Keymap {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
format,
|
||||
fd,
|
||||
size,
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn enter(
|
||||
self: &Rc<Self>,
|
||||
serial: u32,
|
||||
surface: WlSurfaceId,
|
||||
keys: Vec<u32>,
|
||||
) -> DynEventFormatter {
|
||||
Box::new(Enter {
|
||||
obj: self.clone(),
|
||||
Box::new(EnterOut {
|
||||
self_id: self.id,
|
||||
serial,
|
||||
surface,
|
||||
keys,
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
||||
Box::new(Leave {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
serial,
|
||||
surface,
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn key(self: &Rc<Self>, serial: u32, time: u32, key: u32, state: u32) -> DynEventFormatter {
|
||||
Box::new(Key {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
serial,
|
||||
time,
|
||||
key,
|
||||
|
|
@ -118,7 +103,6 @@ impl WlKeyboard {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn modifiers(
|
||||
self: &Rc<Self>,
|
||||
serial: u32,
|
||||
|
|
@ -128,7 +112,7 @@ impl WlKeyboard {
|
|||
group: u32,
|
||||
) -> DynEventFormatter {
|
||||
Box::new(Modifiers {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
serial,
|
||||
mods_depressed,
|
||||
mods_latched,
|
||||
|
|
@ -137,10 +121,9 @@ impl WlKeyboard {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn repeat_info(self: &Rc<Self>, rate: i32, delay: i32) -> DynEventFormatter {
|
||||
Box::new(RepeatInfo {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
rate,
|
||||
delay,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -33,177 +33,3 @@ pub enum ReleaseError {
|
|||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError, 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()",)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Keymap {
|
||||
pub obj: Rc<WlKeyboard>,
|
||||
pub format: u32,
|
||||
pub fd: Rc<OwnedFd>,
|
||||
pub size: u32,
|
||||
}
|
||||
impl EventFormatter for Keymap {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, KEYMAP)
|
||||
.uint(self.format)
|
||||
.fd(self.fd)
|
||||
.uint(self.size);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Keymap {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"keymap(format: {}, fd: {}, size: {})",
|
||||
self.format,
|
||||
self.fd.raw(),
|
||||
self.size
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Enter {
|
||||
pub obj: Rc<WlKeyboard>,
|
||||
pub serial: u32,
|
||||
pub surface: WlSurfaceId,
|
||||
pub keys: Vec<u32>,
|
||||
}
|
||||
impl EventFormatter for Enter {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, ENTER)
|
||||
.uint(self.serial)
|
||||
.object(self.surface)
|
||||
.array(|f| {
|
||||
for &key in &self.keys {
|
||||
f.uint(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Enter {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"enter(serial: {}, surface: {}, keys: {:?})",
|
||||
self.serial, self.surface, self.keys
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Leave {
|
||||
pub obj: Rc<WlKeyboard>,
|
||||
pub serial: u32,
|
||||
pub surface: WlSurfaceId,
|
||||
}
|
||||
impl EventFormatter for Leave {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, LEAVE)
|
||||
.uint(self.serial)
|
||||
.object(self.surface);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Leave {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"leave(serial: {}, surface: {})",
|
||||
self.serial, self.surface
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Key {
|
||||
pub obj: Rc<WlKeyboard>,
|
||||
pub serial: u32,
|
||||
pub time: u32,
|
||||
pub key: u32,
|
||||
pub state: u32,
|
||||
}
|
||||
impl EventFormatter for Key {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, KEY)
|
||||
.uint(self.serial)
|
||||
.uint(self.time)
|
||||
.uint(self.key)
|
||||
.uint(self.state);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Key {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"key(serial: {}, time: {}, key: {}, state: {})",
|
||||
self.serial, self.time, self.key, self.state
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Modifiers {
|
||||
pub obj: Rc<WlKeyboard>,
|
||||
pub serial: u32,
|
||||
pub mods_depressed: u32,
|
||||
pub mods_latched: u32,
|
||||
pub mods_locked: u32,
|
||||
pub group: u32,
|
||||
}
|
||||
impl EventFormatter for Modifiers {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, MODIFIERS)
|
||||
.uint(self.serial)
|
||||
.uint(self.mods_depressed)
|
||||
.uint(self.mods_latched)
|
||||
.uint(self.mods_locked)
|
||||
.uint(self.group);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Modifiers {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "modifiers(serial: {}, mods_depressed: {}, mods_latched: {}, mods_locked: {}, group: {})", self.serial, self.mods_depressed, self.mods_latched, self.mods_locked, self.group)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct RepeatInfo {
|
||||
pub obj: Rc<WlKeyboard>,
|
||||
pub rate: i32,
|
||||
pub delay: i32,
|
||||
}
|
||||
impl EventFormatter for RepeatInfo {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, REPEAT_INFO)
|
||||
.int(self.rate)
|
||||
.int(self.delay);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for RepeatInfo {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "repeat_info(rate: {}, delay: {})", self.rate, self.delay)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,19 +9,7 @@ use crate::object::Object;
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const SET_CURSOR: u32 = 0;
|
||||
const RELEASE: u32 = 1;
|
||||
|
||||
const ENTER: u32 = 0;
|
||||
const LEAVE: u32 = 1;
|
||||
const MOTION: u32 = 2;
|
||||
const BUTTON: u32 = 3;
|
||||
const AXIS: u32 = 4;
|
||||
const FRAME: u32 = 5;
|
||||
const AXIS_SOURCE: u32 = 6;
|
||||
const AXIS_STOP: u32 = 7;
|
||||
const AXIS_DISCRETE: u32 = 8;
|
||||
use crate::wire::wl_pointer::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
|
@ -43,8 +31,6 @@ const WHEEL_TILT: u32 = 3;
|
|||
|
||||
pub const POINTER_FRAME_SINCE_VERSION: u32 = 5;
|
||||
|
||||
id!(WlPointerId);
|
||||
|
||||
pub struct WlPointer {
|
||||
id: WlPointerId,
|
||||
seat: Rc<WlSeat>,
|
||||
|
|
@ -66,7 +52,7 @@ impl WlPointer {
|
|||
y: Fixed,
|
||||
) -> DynEventFormatter {
|
||||
Box::new(Enter {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
serial,
|
||||
surface,
|
||||
surface_x: x,
|
||||
|
|
@ -76,7 +62,7 @@ impl WlPointer {
|
|||
|
||||
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
||||
Box::new(Leave {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
serial,
|
||||
surface,
|
||||
})
|
||||
|
|
@ -84,7 +70,7 @@ impl WlPointer {
|
|||
|
||||
pub fn motion(self: &Rc<Self>, time: u32, x: Fixed, y: Fixed) -> DynEventFormatter {
|
||||
Box::new(Motion {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
time,
|
||||
surface_x: x,
|
||||
surface_y: y,
|
||||
|
|
@ -99,7 +85,7 @@ impl WlPointer {
|
|||
state: u32,
|
||||
) -> DynEventFormatter {
|
||||
Box::new(Button {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
serial,
|
||||
time,
|
||||
button,
|
||||
|
|
@ -109,7 +95,7 @@ impl WlPointer {
|
|||
|
||||
pub fn axis(self: &Rc<Self>, time: u32, axis: u32, value: Fixed) -> DynEventFormatter {
|
||||
Box::new(Axis {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
time,
|
||||
axis,
|
||||
value,
|
||||
|
|
@ -118,13 +104,13 @@ impl WlPointer {
|
|||
|
||||
#[allow(dead_code)]
|
||||
pub fn frame(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Frame { obj: self.clone() })
|
||||
Box::new(Frame { self_id: self.id })
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn axis_source(self: &Rc<Self>, axis_source: u32) -> DynEventFormatter {
|
||||
Box::new(AxisSource {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
axis_source,
|
||||
})
|
||||
}
|
||||
|
|
@ -132,7 +118,7 @@ impl WlPointer {
|
|||
#[allow(dead_code)]
|
||||
pub fn axis_stop(self: &Rc<Self>, time: u32, axis: u32) -> DynEventFormatter {
|
||||
Box::new(AxisStop {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
time,
|
||||
axis,
|
||||
})
|
||||
|
|
@ -141,7 +127,7 @@ impl WlPointer {
|
|||
#[allow(dead_code)]
|
||||
pub fn axis_discrete(self: &Rc<Self>, axis: u32, discrete: i32) -> DynEventFormatter {
|
||||
Box::new(AxisDiscrete {
|
||||
obj: self.clone(),
|
||||
self_id: self.id,
|
||||
axis,
|
||||
discrete,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -44,265 +44,3 @@ pub enum ReleaseError {
|
|||
}
|
||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||
efrom!(ReleaseError, ClientError, ClientError);
|
||||
|
||||
pub(super) struct SetCursor {
|
||||
pub serial: u32,
|
||||
pub surface: WlSurfaceId,
|
||||
pub hotspot_x: i32,
|
||||
pub hotspot_y: i32,
|
||||
}
|
||||
impl RequestParser<'_> for SetCursor {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
serial: parser.uint()?,
|
||||
surface: parser.object()?,
|
||||
hotspot_x: parser.int()?,
|
||||
hotspot_y: parser.int()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetCursor {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_cursor(serial: {}, surface: {}, hotspot_x: {}, hotspot_y: {})",
|
||||
self.serial, self.surface, self.hotspot_x, self.hotspot_y
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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()",)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Enter {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub serial: u32,
|
||||
pub surface: WlSurfaceId,
|
||||
pub surface_x: Fixed,
|
||||
pub surface_y: Fixed,
|
||||
}
|
||||
impl EventFormatter for Enter {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, ENTER)
|
||||
.uint(self.serial)
|
||||
.object(self.surface)
|
||||
.fixed(self.surface_x)
|
||||
.fixed(self.surface_y);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Enter {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"enter(serial: {}, surface: {}, surface_x: {}, surface_y: {})",
|
||||
self.serial, self.surface, self.surface_x, self.surface_y
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Leave {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub serial: u32,
|
||||
pub surface: WlSurfaceId,
|
||||
}
|
||||
impl EventFormatter for Leave {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, LEAVE)
|
||||
.uint(self.serial)
|
||||
.object(self.surface);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Leave {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"leave(serial: {}, surface: {})",
|
||||
self.serial, self.surface
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Motion {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub time: u32,
|
||||
pub surface_x: Fixed,
|
||||
pub surface_y: Fixed,
|
||||
}
|
||||
impl EventFormatter for Motion {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, MOTION)
|
||||
.uint(self.time)
|
||||
.fixed(self.surface_x)
|
||||
.fixed(self.surface_y);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
fn should_log(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
impl Debug for Motion {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"motion(time: {}, surface_x: {}, surface_y: {})",
|
||||
self.time, self.surface_x, self.surface_y
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Button {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub serial: u32,
|
||||
pub time: u32,
|
||||
pub button: u32,
|
||||
pub state: u32,
|
||||
}
|
||||
impl EventFormatter for Button {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, BUTTON)
|
||||
.uint(self.serial)
|
||||
.uint(self.time)
|
||||
.uint(self.button)
|
||||
.uint(self.state);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Button {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"button(serial: {}, time: {}, button: 0x{:x}, state: {})",
|
||||
self.serial, self.time, self.button, self.state
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Axis {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub time: u32,
|
||||
pub axis: u32,
|
||||
pub value: Fixed,
|
||||
}
|
||||
impl EventFormatter for Axis {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, AXIS)
|
||||
.uint(self.time)
|
||||
.uint(self.axis)
|
||||
.fixed(self.value);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for Axis {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"axis(time: {}, axis: {}, value: {:?})",
|
||||
self.time, self.axis, self.value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Frame {
|
||||
pub obj: Rc<WlPointer>,
|
||||
}
|
||||
impl EventFormatter for Frame {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, FRAME);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
fn should_log(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
impl Debug for Frame {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "frame()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct AxisSource {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub axis_source: u32,
|
||||
}
|
||||
impl EventFormatter for AxisSource {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, AXIS_SOURCE).uint(self.axis_source);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for AxisSource {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "axis_source(axis_source: {})", self.axis_source)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct AxisStop {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub time: u32,
|
||||
pub axis: u32,
|
||||
}
|
||||
impl EventFormatter for AxisStop {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, AXIS_STOP)
|
||||
.uint(self.time)
|
||||
.uint(self.axis);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for AxisStop {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "axis_stop(time: {}, axis: {})", self.time, self.axis)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct AxisDiscrete {
|
||||
pub obj: Rc<WlPointer>,
|
||||
pub axis: u32,
|
||||
pub discrete: i32,
|
||||
}
|
||||
impl EventFormatter for AxisDiscrete {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, AXIS_DISCRETE)
|
||||
.uint(self.axis)
|
||||
.int(self.discrete);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
self.obj.deref()
|
||||
}
|
||||
}
|
||||
impl Debug for AxisDiscrete {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"axis_discrete(axis: {}, discrete: {})",
|
||||
self.axis, self.discrete
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ mod tree;
|
|||
mod utils;
|
||||
mod wheel;
|
||||
mod xkbcommon;
|
||||
mod wire;
|
||||
|
||||
fn main() {
|
||||
env_logger::builder()
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ use crate::client::ClientError;
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::rc::Rc;
|
||||
use crate::wire::WlDisplayId;
|
||||
|
||||
pub const WL_DISPLAY_ID: ObjectId = ObjectId(1);
|
||||
pub const WL_DISPLAY_ID: WlDisplayId = WlDisplayId(1);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub struct ObjectId(u32);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::rc::Rc;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::globals::GlobalName;
|
||||
use crate::object::ObjectId;
|
||||
|
|
@ -65,18 +66,11 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
|||
}
|
||||
|
||||
pub fn bstr(&mut self) -> Result<&'b BStr, MsgParserError> {
|
||||
let len = self.uint()? as usize;
|
||||
if len == 0 {
|
||||
let s = self.array()?;
|
||||
if s.len() == 0 {
|
||||
return Err(MsgParserError::EmptyString);
|
||||
}
|
||||
let cap = (len + 3) & !3;
|
||||
if cap > self.data.len() - self.pos {
|
||||
return Err(MsgParserError::UnexpectedEof);
|
||||
}
|
||||
let s = &self.data[self.pos..self.pos + len - 1];
|
||||
let s = s.as_bstr();
|
||||
self.pos += cap;
|
||||
Ok(s)
|
||||
Ok(s[..s.len()-1].as_bstr())
|
||||
}
|
||||
|
||||
pub fn str(&mut self) -> Result<&'b str, MsgParserError> {
|
||||
|
|
@ -86,9 +80,9 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fd(&mut self) -> Result<OwnedFd, MsgParserError> {
|
||||
pub fn fd(&mut self) -> Result<Rc<OwnedFd>, MsgParserError> {
|
||||
match self.buf.get_fd() {
|
||||
Ok(fd) => Ok(fd),
|
||||
Ok(fd) => Ok(Rc::new(fd)),
|
||||
_ => Err(MsgParserError::MissingFd),
|
||||
}
|
||||
}
|
||||
|
|
@ -100,4 +94,15 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
|||
Err(MsgParserError::TrailingData)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn array(&mut self) -> Result<&'b [u8], MsgParserError> {
|
||||
let len = self.uint()? as usize;
|
||||
let cap = (len + 3) & !3;
|
||||
if cap > self.data.len() - self.pos {
|
||||
return Err(MsgParserError::UnexpectedEof);
|
||||
}
|
||||
let pos = self.pos;
|
||||
self.pos += cap;
|
||||
Ok(&self.data[pos..pos + len])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
src/wire.rs
Normal file
1
src/wire.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
include!(concat!(env!("OUT_DIR"), "/wire.rs"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue