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
|
|
@ -2,6 +2,7 @@
|
||||||
name = "i4"
|
name = "i4"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
build = "build/build.rs"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
@ -34,3 +35,7 @@ byteorder = "1.4.3"
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
repc = "0.1.1"
|
repc = "0.1.1"
|
||||||
anyhow = "1.0.52"
|
anyhow = "1.0.52"
|
||||||
|
bstr = "0.2.17"
|
||||||
|
|
||||||
|
[profile.dev.build-override]
|
||||||
|
opt-level = 3
|
||||||
|
|
|
||||||
29
build/build.rs
Normal file
29
build/build.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
use std::fs::{File, OpenOptions};
|
||||||
|
use std::{env, io};
|
||||||
|
use std::io::BufWriter;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
mod enums;
|
||||||
|
mod wire;
|
||||||
|
|
||||||
|
fn open(s: &str) -> io::Result<BufWriter<File>> {
|
||||||
|
let mut path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
|
path.push(s);
|
||||||
|
Ok(BufWriter::new(
|
||||||
|
OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.write(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(path)?,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn main() -> anyhow::Result<()> {
|
||||||
|
wire::main()?;
|
||||||
|
|
||||||
|
enums::main()?;
|
||||||
|
|
||||||
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -1,34 +1,20 @@
|
||||||
|
use std::env;
|
||||||
use repc::layout::{Type, TypeVariant};
|
use repc::layout::{Type, TypeVariant};
|
||||||
use std::fmt::Write as FmtWrite;
|
use std::fmt::Write as FmtWrite;
|
||||||
use std::fs::{File, OpenOptions};
|
|
||||||
use std::io::BufWriter;
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use crate::open;
|
||||||
use std::{env, io};
|
|
||||||
|
|
||||||
#[allow(unused_macros)]
|
#[allow(unused_macros)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
#[path = "src/macros.rs"]
|
#[path = "../src/macros.rs"]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
#[path = "src/pixman/consts.rs"]
|
#[path = "../src/pixman/consts.rs"]
|
||||||
mod pixman;
|
mod pixman;
|
||||||
|
|
||||||
#[path = "src/xkbcommon/consts.rs"]
|
#[path = "../src/xkbcommon/consts.rs"]
|
||||||
mod xkbcommon;
|
mod xkbcommon;
|
||||||
|
|
||||||
fn open(s: &str) -> io::Result<BufWriter<File>> {
|
|
||||||
let mut path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
||||||
path.push(s);
|
|
||||||
Ok(BufWriter::new(
|
|
||||||
OpenOptions::new()
|
|
||||||
.create(true)
|
|
||||||
.write(true)
|
|
||||||
.truncate(true)
|
|
||||||
.open(path)?,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_target() -> repc::Target {
|
fn get_target() -> repc::Target {
|
||||||
let rustc_target = env::var("TARGET").unwrap();
|
let rustc_target = env::var("TARGET").unwrap();
|
||||||
repc::TARGET_MAP
|
repc::TARGET_MAP
|
||||||
|
|
@ -206,7 +192,7 @@ fn write_egl_procs<W: Write>(f: &mut W) -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
pub fn main() -> anyhow::Result<()> {
|
||||||
let mut f = open("pixman_tys.rs")?;
|
let mut f = open("pixman_tys.rs")?;
|
||||||
write_ty(&mut f, pixman::FORMATS, "PixmanFormat")?;
|
write_ty(&mut f, pixman::FORMATS, "PixmanFormat")?;
|
||||||
write_ty(&mut f, pixman::OPS, "PixmanOp")?;
|
write_ty(&mut f, pixman::OPS, "PixmanOp")?;
|
||||||
|
|
@ -230,6 +216,5 @@ fn main() -> anyhow::Result<()> {
|
||||||
let mut f = open("egl_procs.rs")?;
|
let mut f = open("egl_procs.rs")?;
|
||||||
write_egl_procs(&mut f)?;
|
write_egl_procs(&mut f)?;
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
665
build/wire.rs
Normal file
665
build/wire.rs
Normal file
|
|
@ -0,0 +1,665 @@
|
||||||
|
use std::fs::DirEntry;
|
||||||
|
use std::os::unix::ffi::OsStrExt;
|
||||||
|
use anyhow::{bail, Context, Result};
|
||||||
|
use bstr::{BStr, BString, ByteSlice};
|
||||||
|
use crate::open;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
|
enum TreeDelim {
|
||||||
|
Paren,
|
||||||
|
Brace,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TreeDelim {
|
||||||
|
fn opening(self) -> u8 {
|
||||||
|
match self {
|
||||||
|
TreeDelim::Paren => b'(',
|
||||||
|
TreeDelim::Brace => b'{',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn closing(self) -> u8 {
|
||||||
|
match self {
|
||||||
|
TreeDelim::Paren => b')',
|
||||||
|
TreeDelim::Brace => b'}',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
|
enum Symbol {
|
||||||
|
Comma,
|
||||||
|
Colon,
|
||||||
|
Equals,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Symbol {
|
||||||
|
fn name(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Symbol::Comma => "','",
|
||||||
|
Symbol::Colon => "':'",
|
||||||
|
Symbol::Equals => "'='",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Token<'a> {
|
||||||
|
line: u32,
|
||||||
|
kind: TokenKind<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum TokenKind<'a> {
|
||||||
|
Ident(&'a BStr),
|
||||||
|
Num(u32),
|
||||||
|
Tree {
|
||||||
|
delim: TreeDelim,
|
||||||
|
body: Vec<Token<'a>>,
|
||||||
|
},
|
||||||
|
Symbol(Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TokenKind<'_> {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
TokenKind::Ident(_) => "identifier",
|
||||||
|
TokenKind::Num(_) => "number",
|
||||||
|
TokenKind::Tree { delim, .. } => match delim {
|
||||||
|
TreeDelim::Paren => "'('-tree",
|
||||||
|
TreeDelim::Brace => "'{'-tree",
|
||||||
|
},
|
||||||
|
TokenKind::Symbol(s) => s.name(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
struct Cursor<'a> {
|
||||||
|
pos: usize,
|
||||||
|
s: &'a [u8],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cursor<'_> {
|
||||||
|
fn eof(&self) -> bool {
|
||||||
|
self.pos >= self.s.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tokenize<'a>(s: &'a [u8]) -> Result<Vec<Token<'a>>> {
|
||||||
|
let mut tnz = Tokenizer {
|
||||||
|
line: 1,
|
||||||
|
cursor: Cursor { pos: 0, s },
|
||||||
|
delim: None,
|
||||||
|
res: vec![],
|
||||||
|
};
|
||||||
|
tnz.tokenize()?;
|
||||||
|
Ok(tnz.res)
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Tokenizer<'a> {
|
||||||
|
line: u32,
|
||||||
|
cursor: Cursor<'a>,
|
||||||
|
delim: Option<TreeDelim>,
|
||||||
|
res: Vec<Token<'a>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Tokenizer<'a> {
|
||||||
|
fn tokenize_one(&mut self) -> Result<bool> {
|
||||||
|
let c = &mut self.cursor;
|
||||||
|
while !c.eof() {
|
||||||
|
let b = c.s[c.pos];
|
||||||
|
if matches!(b, b' ' | b'\n' | b'#') {
|
||||||
|
c.pos += 1;
|
||||||
|
if b == b'\n' {
|
||||||
|
self.line += 1;
|
||||||
|
} else if b == b'#' {
|
||||||
|
while !c.eof() {
|
||||||
|
c.pos += 1;
|
||||||
|
if c.s[c.pos - 1] == b'\n' {
|
||||||
|
self.line += 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c.eof() {
|
||||||
|
if self.delim.is_some() {
|
||||||
|
bail!("Unexpected eof");
|
||||||
|
}
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
let line = self.line;
|
||||||
|
let b = c.s[c.pos];
|
||||||
|
let b_pos = c.pos;
|
||||||
|
c.pos += 1;
|
||||||
|
let kind = match b {
|
||||||
|
b'a'..=b'z' => {
|
||||||
|
while !c.eof() && matches!(c.s[c.pos], b'a'..=b'z' | b'_' | b'0'..=b'9') {
|
||||||
|
c.pos += 1;
|
||||||
|
}
|
||||||
|
TokenKind::Ident(c.s[b_pos..c.pos].as_bstr())
|
||||||
|
}
|
||||||
|
b'0'..=b'9' => {
|
||||||
|
c.pos -= 1;
|
||||||
|
let mut num = 0;
|
||||||
|
while !c.eof() && matches!(c.s[c.pos], b'0'..=b'9') {
|
||||||
|
num = num * 10 + (c.s[c.pos] - b'0') as u32;
|
||||||
|
c.pos += 1;
|
||||||
|
}
|
||||||
|
TokenKind::Num(num)
|
||||||
|
}
|
||||||
|
b',' => TokenKind::Symbol(Symbol::Comma),
|
||||||
|
b'=' => TokenKind::Symbol(Symbol::Equals),
|
||||||
|
b':' => TokenKind::Symbol(Symbol::Colon),
|
||||||
|
b'(' => self.tokenize_tree(TreeDelim::Paren)?,
|
||||||
|
b'{' => self.tokenize_tree(TreeDelim::Brace)?,
|
||||||
|
c @ (b')' | b'}') => {
|
||||||
|
if self.delim.map(|d| d.closing()) != Some(c) {
|
||||||
|
bail!("Unexpected '{}' in line {}", c, self.line);
|
||||||
|
}
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
_ => bail!("Unexpected byte {:?} in line {}", b as char, self.line),
|
||||||
|
};
|
||||||
|
self.res.push(Token { line, kind });
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tokenize(&mut self) -> Result<()> {
|
||||||
|
while self.tokenize_one()? {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tokenize_tree(&mut self, delim: TreeDelim) -> Result<TokenKind<'a>> {
|
||||||
|
let mut tnz = Tokenizer {
|
||||||
|
line: self.line,
|
||||||
|
cursor: self.cursor,
|
||||||
|
delim: Some(delim),
|
||||||
|
res: vec![],
|
||||||
|
};
|
||||||
|
tnz.tokenize().with_context(|| {
|
||||||
|
format!(
|
||||||
|
"While tokenizing {:?} block starting in line {}",
|
||||||
|
delim.opening() as char,
|
||||||
|
self.line
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
self.cursor.pos = tnz.cursor.pos;
|
||||||
|
self.line = tnz.line;
|
||||||
|
Ok(TokenKind::Tree {
|
||||||
|
delim,
|
||||||
|
body: tnz.res,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Lined<T> {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
line: u32,
|
||||||
|
val: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum Type {
|
||||||
|
Id(BString),
|
||||||
|
U32,
|
||||||
|
I32,
|
||||||
|
Str,
|
||||||
|
BStr,
|
||||||
|
Fixed,
|
||||||
|
Fd,
|
||||||
|
Array(Box<Type>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Field {
|
||||||
|
name: BString,
|
||||||
|
ty: Lined<Type>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Message {
|
||||||
|
name: BString,
|
||||||
|
camel_name: BString,
|
||||||
|
id: Lined<u32>,
|
||||||
|
fields: Vec<Lined<Field>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Parser<'a> {
|
||||||
|
pos: usize,
|
||||||
|
tokens: &'a [Token<'a>],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Parser<'a> {
|
||||||
|
fn parse(&mut self) -> Result<Vec<Lined<Message>>> {
|
||||||
|
let mut res = vec![];
|
||||||
|
while !self.eof() {
|
||||||
|
let (line, ty) = self.expect_ident()?;
|
||||||
|
match ty.as_bytes() {
|
||||||
|
b"msg" => res.push(self.parse_message()?),
|
||||||
|
_ => bail!("In line {}: Unexpected entry {:?}", line, ty),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn eof(&self) -> bool {
|
||||||
|
self.pos == self.tokens.len()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn not_eof(&self) -> Result<()> {
|
||||||
|
if self.eof() {
|
||||||
|
bail!("Unexpected eof");
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn yes_eof(&self) -> Result<()> {
|
||||||
|
if !self.eof() {
|
||||||
|
bail!(
|
||||||
|
"Unexpected trailing tokens in line {}",
|
||||||
|
self.tokens[self.pos].line
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_message(&mut self) -> Result<Lined<Message>> {
|
||||||
|
let (line, name) = self.expect_ident()?;
|
||||||
|
let res: Result<_> = (|| {
|
||||||
|
self.expect_symbol(Symbol::Equals)?;
|
||||||
|
let (num_line, val) = self.expect_number()?;
|
||||||
|
let (_, body) = self.expect_tree(TreeDelim::Brace)?;
|
||||||
|
let mut parser = Parser {
|
||||||
|
pos: 0,
|
||||||
|
tokens: body,
|
||||||
|
};
|
||||||
|
let mut fields = vec!();
|
||||||
|
while !parser.eof() {
|
||||||
|
fields.push(parser.parse_field()?);
|
||||||
|
}
|
||||||
|
Ok(Lined {
|
||||||
|
line,
|
||||||
|
val: Message {
|
||||||
|
name: name.to_owned(),
|
||||||
|
camel_name: to_camel(name),
|
||||||
|
id: Lined { line: num_line, val, },
|
||||||
|
fields,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
res.with_context(|| format!("While parsing message starting at line {}", line))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_field(&mut self) -> Result<Lined<Field>> {
|
||||||
|
let (line, name) = self.expect_ident()?;
|
||||||
|
let res: Result<_> = (|| {
|
||||||
|
self.expect_symbol(Symbol::Colon)?;
|
||||||
|
let ty = self.parse_type()?;
|
||||||
|
if !self.eof() {
|
||||||
|
self.expect_symbol(Symbol::Comma)?;
|
||||||
|
}
|
||||||
|
Ok(Lined {
|
||||||
|
line,
|
||||||
|
val: Field {
|
||||||
|
name: name.to_owned(),
|
||||||
|
ty,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
res.with_context(|| format!("While parsing field starting at line {}", line))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expect_ident(&mut self) -> Result<(u32, &'a BStr)> {
|
||||||
|
self.not_eof()?;
|
||||||
|
let token = &self.tokens[self.pos];
|
||||||
|
self.pos += 1;
|
||||||
|
match &token.kind {
|
||||||
|
TokenKind::Ident(id) => Ok((token.line, *id)),
|
||||||
|
k => bail!("In line {}: Expected identifier, found {}", token.line, k.name()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expect_number(&mut self) -> Result<(u32, u32)> {
|
||||||
|
self.not_eof()?;
|
||||||
|
let token = &self.tokens[self.pos];
|
||||||
|
self.pos += 1;
|
||||||
|
match &token.kind {
|
||||||
|
TokenKind::Num(n) => Ok((token.line, *n)),
|
||||||
|
k => bail!("In line {}: Expected number, found {}", token.line, k.name()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expect_symbol(&mut self, symbol: Symbol) -> Result<()> {
|
||||||
|
self.not_eof()?;
|
||||||
|
let token = &self.tokens[self.pos];
|
||||||
|
self.pos += 1;
|
||||||
|
match &token.kind {
|
||||||
|
TokenKind::Symbol(s) if *s == symbol => Ok(()),
|
||||||
|
k => bail!("In line {}: Expected {}, found {}", token.line, symbol.name(), k.name()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expect_tree_(&mut self) -> Result<(u32, TreeDelim, &'a [Token<'a>])> {
|
||||||
|
self.not_eof()?;
|
||||||
|
let token = &self.tokens[self.pos];
|
||||||
|
self.pos += 1;
|
||||||
|
match &token.kind {
|
||||||
|
TokenKind::Tree { delim, body } => {
|
||||||
|
Ok((token.line, *delim, body))
|
||||||
|
}
|
||||||
|
k => bail!("In line {}: Expected tree, found {}", token.line, k.name()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expect_tree(&mut self, exp_delim: TreeDelim) -> Result<(u32, &'a [Token<'a>])> {
|
||||||
|
let (line, delim, tokens) = self.expect_tree_()?;
|
||||||
|
if delim == exp_delim {
|
||||||
|
Ok((line, tokens))
|
||||||
|
} else {
|
||||||
|
bail!("In line {}: Expected {:?}-delimited tree, found {:?}-delimited tree", line, exp_delim, delim.opening())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_type(&mut self) -> Result<Lined<Type>> {
|
||||||
|
self.not_eof()?;
|
||||||
|
let (line, ty) = self.expect_ident()?;
|
||||||
|
let ty = match ty.as_bytes() {
|
||||||
|
b"u32" => Type::U32,
|
||||||
|
b"i32" => Type::I32,
|
||||||
|
b"str" => Type::Str,
|
||||||
|
b"bstr" => Type::BStr,
|
||||||
|
b"fixed" => Type::Fixed,
|
||||||
|
b"fd" => Type::Fd,
|
||||||
|
b"array" => {
|
||||||
|
let (line, body) = self.expect_tree(TreeDelim::Paren)?;
|
||||||
|
let ty: Result<_> = (|| {
|
||||||
|
let mut parser = Parser {
|
||||||
|
pos: 0,
|
||||||
|
tokens: body,
|
||||||
|
};
|
||||||
|
let ty = parser.parse_type()?;
|
||||||
|
parser.yes_eof()?;
|
||||||
|
match &ty.val {
|
||||||
|
Type::Id(_) => {}
|
||||||
|
Type::U32 => {}
|
||||||
|
Type::I32 => {}
|
||||||
|
Type::Fixed => {}
|
||||||
|
_ => {
|
||||||
|
bail!("Only numerical types can be array elements");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(ty)
|
||||||
|
})();
|
||||||
|
let ty = ty.with_context(|| {
|
||||||
|
format!("While parsing array element type starting in line {}", line)
|
||||||
|
})?;
|
||||||
|
Type::Array(Box::new(ty.val))
|
||||||
|
}
|
||||||
|
b"id" => {
|
||||||
|
let (_, body) = self.expect_tree(TreeDelim::Paren)?;
|
||||||
|
let ident: Result<_> = (|| {
|
||||||
|
let mut parser = Parser {
|
||||||
|
pos: 0,
|
||||||
|
tokens: body,
|
||||||
|
};
|
||||||
|
let id = parser.expect_ident()?;
|
||||||
|
parser.yes_eof()?;
|
||||||
|
Ok(id)
|
||||||
|
})();
|
||||||
|
let (_, ident) = ident.with_context(|| {
|
||||||
|
format!("While parsing identifier starting in line {}", line)
|
||||||
|
})?;
|
||||||
|
Type::Id(to_camel(ident))
|
||||||
|
},
|
||||||
|
_ => bail!("Unknown type {}", ty),
|
||||||
|
};
|
||||||
|
Ok(Lined {
|
||||||
|
line,
|
||||||
|
val: ty,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_messages(s: &[u8]) -> Result<Vec<Lined<Message>>> {
|
||||||
|
let tokens = tokenize(s)?;
|
||||||
|
let mut parser = Parser {
|
||||||
|
pos: 0,
|
||||||
|
tokens: &tokens,
|
||||||
|
};
|
||||||
|
parser.parse()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_camel(s: &BStr) -> BString {
|
||||||
|
let mut last_was_underscore = true;
|
||||||
|
let mut res = vec!();
|
||||||
|
for mut b in s.as_bytes().iter().copied() {
|
||||||
|
if b == b'_' {
|
||||||
|
last_was_underscore = true;
|
||||||
|
} else {
|
||||||
|
if last_was_underscore {
|
||||||
|
b = b.to_ascii_uppercase()
|
||||||
|
}
|
||||||
|
res.push(b);
|
||||||
|
last_was_underscore = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_type<W: Write>(f: &mut W, ty: &Type, role: TypeRole) -> Result<()> {
|
||||||
|
match ty {
|
||||||
|
Type::Id(id) => write!(f, "{}Id", id)?,
|
||||||
|
Type::U32 => write!(f, "u32")?,
|
||||||
|
Type::I32 => write!(f, "i32")?,
|
||||||
|
Type::Str if role == TypeRole::In => write!(f, "&'a str")?,
|
||||||
|
Type::Str => write!(f, "String")?,
|
||||||
|
Type::BStr if role == TypeRole::In => write!(f, "&'a BStr")?,
|
||||||
|
Type::BStr => write!(f, "BString")?,
|
||||||
|
Type::Fixed => write!(f, "Fixed")?,
|
||||||
|
Type::Fd => write!(f, "Rc<OwnedFd>")?,
|
||||||
|
Type::Array(n) if role == TypeRole::In => {
|
||||||
|
write!(f, "&'a [")?;
|
||||||
|
write_type(f, n, role)?;
|
||||||
|
write!(f, "]")?;
|
||||||
|
},
|
||||||
|
Type::Array(n) => {
|
||||||
|
write!(f, "Vec<")?;
|
||||||
|
write_type(f, n, role)?;
|
||||||
|
write!(f, ">")?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_field<W: Write>(f: &mut W, field: &Field, role: TypeRole) -> Result<()> {
|
||||||
|
write!(f, " pub {}: ", field.name)?;
|
||||||
|
write_type(f, &field.ty.val, role)?;
|
||||||
|
writeln!(f, ",")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||||
|
enum TypeRole {
|
||||||
|
Unified,
|
||||||
|
In,
|
||||||
|
Out,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_message_type<W: Write>(f: &mut W, obj: &BStr, message: &Message, role: TypeRole) -> Result<()> {
|
||||||
|
let suffix = match role {
|
||||||
|
TypeRole::Unified => "",
|
||||||
|
TypeRole::In => "In",
|
||||||
|
TypeRole::Out => "Out",
|
||||||
|
};
|
||||||
|
let needs_lifetime = role == TypeRole::In;
|
||||||
|
let lifetime = if needs_lifetime { "<'a>" } else { "" };
|
||||||
|
writeln!(f, " pub struct {}{}{} {{", message.camel_name, suffix, lifetime)?;
|
||||||
|
writeln!(f, " pub self_id: {}Id,", obj)?;
|
||||||
|
for field in &message.fields {
|
||||||
|
write_field(f, &field.val, role)?;
|
||||||
|
}
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " impl{} std::fmt::Debug for {}{}{} {{", lifetime, message.camel_name, suffix, lifetime)?;
|
||||||
|
writeln!(f, " fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {{")?;
|
||||||
|
write!(f, r#" write!(fmt, "{}("#, message.name)?;
|
||||||
|
for (i, field) in message.fields.iter().enumerate() {
|
||||||
|
if i > 0 {
|
||||||
|
write!(f, ", ")?;
|
||||||
|
}
|
||||||
|
let formatter = match &field.val.ty.val {
|
||||||
|
Type::Str | Type::Fd | Type::Array(..) => "{:?}",
|
||||||
|
_ => "{}",
|
||||||
|
};
|
||||||
|
write!(f, "{}: {}", field.val.name, formatter)?;
|
||||||
|
}
|
||||||
|
write!(f, r#")""#)?;
|
||||||
|
for field in &message.fields {
|
||||||
|
write!(f, ", self.{}", field.val.name)?;
|
||||||
|
}
|
||||||
|
writeln!(f, r")")?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_message<W: Write>(f: &mut W, obj: &BStr, message: &Message) -> Result<()> {
|
||||||
|
let has_reference_type = message.fields.iter().any(|f| match &f.val.ty.val {
|
||||||
|
Type::Str | Type::BStr | Type::Array(..) => true,
|
||||||
|
_ => false,
|
||||||
|
});
|
||||||
|
let uppercase = message.name.to_ascii_uppercase();
|
||||||
|
let uppercase = uppercase.as_bstr();
|
||||||
|
writeln!(f)?;
|
||||||
|
writeln!(f, " pub const {}: u32 = {};", uppercase, message.id.val)?;
|
||||||
|
if has_reference_type {
|
||||||
|
write_message_type(f, obj, message, TypeRole::In)?;
|
||||||
|
write_message_type(f, obj, message, TypeRole::Out)?;
|
||||||
|
} else {
|
||||||
|
write_message_type(f, obj, message, TypeRole::Unified)?;
|
||||||
|
}
|
||||||
|
let lifetime = if has_reference_type { "<'a>"} else {""};
|
||||||
|
writeln!(f, " impl<'a> RequestParser<'a> for {}{}{} {{", message.camel_name, if has_reference_type { "In" } else { "" }, lifetime)?;
|
||||||
|
writeln!(f, " fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {{")?;
|
||||||
|
writeln!(f, " Ok(Self {{")?;
|
||||||
|
writeln!(f, " self_id: {}Id::NONE,", obj)?;
|
||||||
|
for field in &message.fields {
|
||||||
|
write!(f, " {}: ", field.val.name)?;
|
||||||
|
if let Type::Array(_) = &field.val.ty.val {
|
||||||
|
writeln!(f, "{{")?;
|
||||||
|
writeln!(f, " let array = parser.array()?;")?;
|
||||||
|
writeln!(f, " unsafe {{")?;
|
||||||
|
writeln!(f, " std::slice::from_raw_parts(array.as_ptr() as _, array.len() / 4)")?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " }},")?;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let p = match &field.val.ty.val {
|
||||||
|
Type::Id(_) => "object",
|
||||||
|
Type::U32 => "uint",
|
||||||
|
Type::I32 => "int",
|
||||||
|
Type::Str => "str",
|
||||||
|
Type::Fixed => "fixed",
|
||||||
|
Type::Fd => "fd",
|
||||||
|
Type::BStr => "bstr",
|
||||||
|
Type::Array(_) => unreachable!(),
|
||||||
|
};
|
||||||
|
writeln!(f, "parser.{}()?,", p)?;
|
||||||
|
}
|
||||||
|
writeln!(f, " }})")?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " impl EventFormatter for {}{} {{", message.camel_name, if has_reference_type { "Out" } else { "" })?;
|
||||||
|
writeln!(f, " fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {{")?;
|
||||||
|
writeln!(f, " fmt.header(self.self_id, {});", uppercase)?;
|
||||||
|
fn write_fmt_expr<W: Write>(f: &mut W, prefix: &str, ty: &Type, access: &str) -> Result<()> {
|
||||||
|
if let Type::Array(n) = &ty {
|
||||||
|
let new_prefix = format!(" {}", prefix);
|
||||||
|
writeln!(f, " {}fmt.array(|fmt| {{", prefix)?;
|
||||||
|
writeln!(f, " {} for el in {}.iter() {{", prefix, access)?;
|
||||||
|
write_fmt_expr(f, &new_prefix, n, "*el")?;
|
||||||
|
writeln!(f, " {} }}", prefix)?;
|
||||||
|
writeln!(f, " {}}});", prefix)?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let p = match ty {
|
||||||
|
Type::Id(_) => "object",
|
||||||
|
Type::U32 => "uint",
|
||||||
|
Type::I32 => "int",
|
||||||
|
Type::Str | Type::BStr => "string",
|
||||||
|
Type::Fixed => "fixed",
|
||||||
|
Type::Fd => "fd",
|
||||||
|
Type::Array(..) => unreachable!(),
|
||||||
|
};
|
||||||
|
let rf = match ty {
|
||||||
|
Type::Str | Type::BStr => "&",
|
||||||
|
_ => "",
|
||||||
|
};
|
||||||
|
writeln!(f, " {}fmt.{}({}{});", prefix, p, rf, access)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
for field in &message.fields {
|
||||||
|
write_fmt_expr(f, "", &field.val.ty.val, &format!("self.{}", field.val.name))?;
|
||||||
|
}
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " fn id(&self) -> ObjectId {{")?;
|
||||||
|
writeln!(f, " self.self_id.into()")?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " fn interface(&self) -> crate::object::Interface {{")?;
|
||||||
|
writeln!(f, " crate::object::Interface::{}", obj)?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
writeln!(f, " }}")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_file<W: Write>(f: &mut W, file: &DirEntry) -> Result<()> {
|
||||||
|
let file_name = file.file_name();
|
||||||
|
let file_name = file_name.as_bytes().as_bstr();
|
||||||
|
println!("cargo:rerun-if-changed=wire/{}", file_name);
|
||||||
|
let obj_name = file_name.split_str(".").next().unwrap().as_bstr();
|
||||||
|
let camel_obj_name = to_camel(obj_name);
|
||||||
|
writeln!(f)?;
|
||||||
|
writeln!(f, "id!({}Id);", camel_obj_name)?;
|
||||||
|
let contents = std::fs::read(file.path())?;
|
||||||
|
let messages = parse_messages(&contents)?;
|
||||||
|
if messages.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
writeln!(f)?;
|
||||||
|
writeln!(f, "pub mod {} {{", obj_name)?;
|
||||||
|
writeln!(f, " pub use super::*;")?;
|
||||||
|
for message in &messages {
|
||||||
|
write_message(f, camel_obj_name.as_bstr(), &message.val)?;
|
||||||
|
}
|
||||||
|
writeln!(f, "}}")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn main() -> Result<()> {
|
||||||
|
let mut f = open("wire.rs")?;
|
||||||
|
writeln!(f, "use std::rc::Rc;")?;
|
||||||
|
writeln!(f, "use uapi::OwnedFd;")?;
|
||||||
|
writeln!(f, "use bstr::{{BStr, BString}};")?;
|
||||||
|
writeln!(f, "use crate::fixed::Fixed;")?;
|
||||||
|
writeln!(f, "use crate::client::{{EventFormatter, RequestParser}};")?;
|
||||||
|
writeln!(f, "use crate::object::ObjectId;")?;
|
||||||
|
writeln!(f, "use crate::utils::buffd::{{MsgFormatter, MsgParser, MsgParserError}};")?;
|
||||||
|
println!("cargo:rerun-if-changed=wire");
|
||||||
|
let mut files = vec!();
|
||||||
|
for file in std::fs::read_dir("wire")? {
|
||||||
|
files.push(file?);
|
||||||
|
}
|
||||||
|
files.sort_by_key(|f| f.file_name());
|
||||||
|
for file in files {
|
||||||
|
write_file(&mut f, &file).with_context(|| format!("While processing {}", file.path().display()))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -164,10 +164,8 @@ impl Drop for ClientHolder {
|
||||||
|
|
||||||
pub trait EventFormatter: Debug {
|
pub trait EventFormatter: Debug {
|
||||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>);
|
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>);
|
||||||
fn obj(&self) -> &dyn Object;
|
fn id(&self) -> ObjectId;
|
||||||
fn should_log(&self) -> bool {
|
fn interface(&self) -> Interface;
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type DynEventFormatter = Box<dyn EventFormatter>;
|
pub type DynEventFormatter = Box<dyn EventFormatter>;
|
||||||
|
|
|
||||||
|
|
@ -4,22 +4,16 @@ use crate::utils::buffd::MsgParser;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::org_kde_kwin_server_decoration::*;
|
||||||
|
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
const RELEASE: u32 = 0;
|
|
||||||
const REQUEST_MODE: u32 = 1;
|
|
||||||
|
|
||||||
const MODE: u32 = 0;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const NONE: u32 = 0;
|
const NONE: u32 = 0;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const CLIENT: u32 = 1;
|
const CLIENT: u32 = 1;
|
||||||
const SERVER: u32 = 2;
|
const SERVER: u32 = 2;
|
||||||
|
|
||||||
id!(OrgKdeKwinServerDecorationId);
|
|
||||||
|
|
||||||
pub struct OrgKdeKwinServerDecoration {
|
pub struct OrgKdeKwinServerDecoration {
|
||||||
id: OrgKdeKwinServerDecorationId,
|
id: OrgKdeKwinServerDecorationId,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
|
|
@ -37,7 +31,7 @@ impl OrgKdeKwinServerDecoration {
|
||||||
|
|
||||||
pub fn mode(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
pub fn mode(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
||||||
Box::new(Mode {
|
Box::new(Mode {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
mode,
|
mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,49 +38,3 @@ pub enum RequestModeError {
|
||||||
}
|
}
|
||||||
efrom!(RequestModeError, ClientError);
|
efrom!(RequestModeError, ClientError);
|
||||||
efrom!(RequestModeError, ParseError, MsgParserError);
|
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 crate::utils::buffd::MsgParser;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::org_kde_kwin_server_decoration_manager::*;
|
||||||
|
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
const CREATE: u32 = 0;
|
|
||||||
|
|
||||||
const DEFAULT_MODE: u32 = 0;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const NONE: u32 = 0;
|
const NONE: u32 = 0;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const CLIENT: u32 = 1;
|
const CLIENT: u32 = 1;
|
||||||
const SERVER: u32 = 2;
|
const SERVER: u32 = 2;
|
||||||
|
|
||||||
id!(OrgKdeKwinServerDecorationManagerGlobalId);
|
|
||||||
|
|
||||||
pub struct OrgKdeKwinServerDecorationManagerGlobal {
|
pub struct OrgKdeKwinServerDecorationManagerGlobal {
|
||||||
name: GlobalName,
|
name: GlobalName,
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +67,7 @@ pub struct OrgKdeKwinServerDecorationManager {
|
||||||
impl OrgKdeKwinServerDecorationManager {
|
impl OrgKdeKwinServerDecorationManager {
|
||||||
fn default_mode(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
fn default_mode(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
||||||
Box::new(DefaultMode {
|
Box::new(DefaultMode {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
mode,
|
mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,39 +32,3 @@ pub enum CreateError {
|
||||||
}
|
}
|
||||||
efrom!(CreateError, ClientError);
|
efrom!(CreateError, ClientError);
|
||||||
efrom!(CreateError, ParseError, MsgParserError);
|
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 crate::utils::clonecell::CloneCell;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use crate::wire::wl_buffer::*;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
|
||||||
const DESTROY: u32 = 0;
|
|
||||||
|
|
||||||
const RELEASE: u32 = 0;
|
|
||||||
|
|
||||||
id!(WlBufferId);
|
|
||||||
|
|
||||||
pub enum WlBufferStorage {
|
pub enum WlBufferStorage {
|
||||||
Shm { mem: ClientMemOffset, stride: i32 },
|
Shm { mem: ClientMemOffset, stride: i32 },
|
||||||
Dmabuf(Rc<Image>),
|
Dmabuf(Rc<Image>),
|
||||||
|
|
@ -122,8 +117,8 @@ impl WlBuffer {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn release(self: &Rc<Self>) -> DynEventFormatter {
|
pub fn release(&self) -> DynEventFormatter {
|
||||||
Box::new(Release { obj: self.clone() })
|
Box::new(Release { self_id: self.id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,32 +33,3 @@ pub enum DestroyError {
|
||||||
}
|
}
|
||||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||||
efrom!(DestroyError, ClientError);
|
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 crate::object::Object;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use types::*;
|
use types::*;
|
||||||
|
use crate::wire::wl_callback::*;
|
||||||
const DONE: u32 = 0;
|
|
||||||
|
|
||||||
id!(WlCallbackId);
|
|
||||||
|
|
||||||
pub struct WlCallback {
|
pub struct WlCallback {
|
||||||
id: WlCallbackId,
|
id: WlCallbackId,
|
||||||
|
|
@ -19,7 +16,7 @@ impl WlCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn done(self: &Rc<Self>) -> DynEventFormatter {
|
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)]
|
#[derive(Debug, Error)]
|
||||||
pub enum WlCallbackError {}
|
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, ParseFailed, MsgParserError);
|
||||||
efrom!(CreateRegionError, ClientError, ClientError);
|
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 crate::utils::buffd::MsgParser;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_data_device::*;
|
||||||
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;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const ROLE: u32 = 0;
|
const ROLE: u32 = 0;
|
||||||
|
|
||||||
id!(WlDataDeviceId);
|
|
||||||
|
|
||||||
pub struct WlDataDevice {
|
pub struct WlDataDevice {
|
||||||
pub id: WlDataDeviceId,
|
pub id: WlDataDeviceId,
|
||||||
pub manager: Rc<WlDataDeviceManager>,
|
pub manager: Rc<WlDataDeviceManager>,
|
||||||
|
|
@ -42,14 +30,14 @@ impl WlDataDevice {
|
||||||
|
|
||||||
pub fn data_offer(self: &Rc<Self>, id: WlDataOfferId) -> DynEventFormatter {
|
pub fn data_offer(self: &Rc<Self>, id: WlDataOfferId) -> DynEventFormatter {
|
||||||
Box::new(DataOffer {
|
Box::new(DataOffer {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
id,
|
id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn selection(self: &Rc<Self>, id: WlDataOfferId) -> DynEventFormatter {
|
pub fn selection(self: &Rc<Self>, id: WlDataOfferId) -> DynEventFormatter {
|
||||||
Box::new(Selection {
|
Box::new(Selection {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
id,
|
id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,197 +55,3 @@ pub enum ReleaseError {
|
||||||
}
|
}
|
||||||
efrom!(ReleaseError, ParseFailed, MsgParserError);
|
efrom!(ReleaseError, ParseFailed, MsgParserError);
|
||||||
efrom!(ReleaseError, ClientError);
|
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 crate::utils::buffd::MsgParser;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_data_device_manager::*;
|
||||||
const CREATE_DATA_SOURCE: u32 = 0;
|
|
||||||
const GET_DATA_DEVICE: u32 = 1;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const DND_NONE: u32 = 0;
|
const DND_NONE: u32 = 0;
|
||||||
|
|
@ -21,8 +19,6 @@ const DND_MOVE: u32 = 2;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const DND_ASK: u32 = 4;
|
const DND_ASK: u32 = 4;
|
||||||
|
|
||||||
id!(WlDataDeviceManagerId);
|
|
||||||
|
|
||||||
pub struct WlDataDeviceManagerGlobal {
|
pub struct WlDataDeviceManagerGlobal {
|
||||||
name: GlobalName,
|
name: GlobalName,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,37 +36,3 @@ pub enum GetDataDeviceError {
|
||||||
}
|
}
|
||||||
efrom!(GetDataDeviceError, ParseFailed, MsgParserError);
|
efrom!(GetDataDeviceError, ParseFailed, MsgParserError);
|
||||||
efrom!(GetDataDeviceError, ClientError);
|
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::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_data_offer::*;
|
||||||
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;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const INVALID_FINISH: u32 = 0;
|
const INVALID_FINISH: u32 = 0;
|
||||||
|
|
@ -29,8 +20,6 @@ const INVALID_ACTION: u32 = 2;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const INVALID_OFFER: u32 = 3;
|
const INVALID_OFFER: u32 = 3;
|
||||||
|
|
||||||
id!(WlDataOfferId);
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
pub enum DataOfferRole {
|
pub enum DataOfferRole {
|
||||||
Selection,
|
Selection,
|
||||||
|
|
@ -79,19 +68,19 @@ impl WlDataOffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn offer(self: &Rc<Self>, mime_type: &str) -> DynEventFormatter {
|
pub fn offer(self: &Rc<Self>, mime_type: &str) -> DynEventFormatter {
|
||||||
Box::new(Offer {
|
Box::new(OfferOut {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
mime_type: mime_type.to_string(),
|
mime_type: mime_type.to_string(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn accept(&self, parser: MsgParser<'_, '_>) -> Result<(), AcceptError> {
|
fn accept(&self, parser: MsgParser<'_, '_>) -> Result<(), AcceptError> {
|
||||||
let _req: Accept = self.client.parse(self, parser)?;
|
let _req: AcceptIn = self.client.parse(self, parser)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ReceiveError> {
|
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() {
|
if let Some(src) = self.source.get() {
|
||||||
src.client.event(src.send(req.mime_type, req.fd));
|
src.client.event(src.send(req.mime_type, req.fd));
|
||||||
src.client.flush();
|
src.client.flush();
|
||||||
|
|
|
||||||
|
|
@ -74,149 +74,3 @@ pub enum SetActionsError {
|
||||||
}
|
}
|
||||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||||
efrom!(SetActionsError, ClientError);
|
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;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
use uapi::OwnedFd;
|
use uapi::OwnedFd;
|
||||||
|
use crate::wire::wl_data_source::*;
|
||||||
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;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const INVALID_ACTION_MASK: u32 = 0;
|
const INVALID_ACTION_MASK: u32 = 0;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const INVALID_SOURCE: u32 = 1;
|
const INVALID_SOURCE: u32 = 1;
|
||||||
|
|
||||||
id!(WlDataSourceId);
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Attachment {
|
struct Attachment {
|
||||||
seat: Rc<WlSeatGlobal>,
|
seat: Rc<WlSeatGlobal>,
|
||||||
|
|
@ -101,19 +89,19 @@ impl WlDataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cancelled(self: &Rc<Self>) -> DynEventFormatter {
|
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 {
|
pub fn send(&self, mime_type: &str, fd: Rc<OwnedFd>) -> DynEventFormatter {
|
||||||
Box::new(Send {
|
Box::new(SendOut {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
mime_type: mime_type.to_string(),
|
mime_type: mime_type.to_string(),
|
||||||
fd: Rc::new(fd),
|
fd,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), OfferError> {
|
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
|
if self
|
||||||
.mime_types
|
.mime_types
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
||||||
|
|
@ -54,160 +54,3 @@ pub enum SetActionsError {
|
||||||
}
|
}
|
||||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||||
efrom!(SetActionsError, ClientError);
|
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 crate::utils::buffd::MsgParser;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_display::*;
|
||||||
const SYNC: u32 = 0;
|
|
||||||
const GET_REGISTRY: u32 = 1;
|
|
||||||
|
|
||||||
const ERROR: u32 = 0;
|
|
||||||
const DELETE_ID: u32 = 1;
|
|
||||||
|
|
||||||
const INVALID_OBJECT: u32 = 0;
|
const INVALID_OBJECT: u32 = 0;
|
||||||
const INVALID_METHOD: u32 = 1;
|
const INVALID_METHOD: u32 = 1;
|
||||||
|
|
@ -21,7 +16,7 @@ const NO_MEMORY: u32 = 2;
|
||||||
const IMPLEMENTATION: u32 = 3;
|
const IMPLEMENTATION: u32 = 3;
|
||||||
|
|
||||||
pub struct WlDisplay {
|
pub struct WlDisplay {
|
||||||
id: ObjectId,
|
id: WlDisplayId,
|
||||||
client: Rc<Client>,
|
client: Rc<Client>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,15 +48,15 @@ impl WlDisplay {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn error(
|
pub fn error<O: Into<ObjectId>>(
|
||||||
self: &Rc<Self>,
|
self: &Rc<Self>,
|
||||||
object_id: ObjectId,
|
object_id: O,
|
||||||
code: u32,
|
code: u32,
|
||||||
message: String,
|
message: String,
|
||||||
) -> DynEventFormatter {
|
) -> DynEventFormatter {
|
||||||
Box::new(Error {
|
Box::new(ErrorOut {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
object_id,
|
object_id: object_id.into(),
|
||||||
code,
|
code,
|
||||||
message,
|
message,
|
||||||
})
|
})
|
||||||
|
|
@ -89,8 +84,8 @@ impl WlDisplay {
|
||||||
|
|
||||||
pub fn delete_id(self: &Rc<Self>, id: ObjectId) -> DynEventFormatter {
|
pub fn delete_id(self: &Rc<Self>, id: ObjectId) -> DynEventFormatter {
|
||||||
Box::new(DeleteId {
|
Box::new(DeleteId {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
id,
|
id: id.raw(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,80 +44,3 @@ pub enum SyncError {
|
||||||
|
|
||||||
efrom!(SyncError, ParseFailed, MsgParserError);
|
efrom!(SyncError, ParseFailed, MsgParserError);
|
||||||
efrom!(SyncError, ClientError);
|
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 crate::utils::buffd::MsgParser;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use bstr::ByteSlice;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_drm::*;
|
||||||
|
|
||||||
mod types;
|
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;
|
const PRIME: u32 = 1;
|
||||||
|
|
||||||
pub struct WlDrmGlobal {
|
pub struct WlDrmGlobal {
|
||||||
|
|
@ -72,19 +63,19 @@ pub struct WlDrm {
|
||||||
|
|
||||||
impl WlDrm {
|
impl WlDrm {
|
||||||
fn device(self: &Rc<Self>, device: &Rc<CString>) -> DynEventFormatter {
|
fn device(self: &Rc<Self>, device: &Rc<CString>) -> DynEventFormatter {
|
||||||
Box::new(Device {
|
Box::new(DeviceOut {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
name: device.clone(),
|
name: device.as_bytes().as_bstr().to_owned(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn authenticated(self: &Rc<Self>) -> DynEventFormatter {
|
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 {
|
fn capabilities(self: &Rc<Self>, value: u32) -> DynEventFormatter {
|
||||||
Box::new(Capabilities {
|
Box::new(Capabilities {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,166 +45,3 @@ pub enum CreatePlanarBufferError {
|
||||||
Unsupported,
|
Unsupported,
|
||||||
}
|
}
|
||||||
efrom!(CreatePlanarBufferError, ParseError, MsgParserError);
|
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::iter;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_output::*;
|
||||||
id!(WlOutputId);
|
|
||||||
|
|
||||||
const RELEASE: u32 = 0;
|
|
||||||
|
|
||||||
const GEOMETRY: u32 = 0;
|
|
||||||
const MODE: u32 = 1;
|
|
||||||
const DONE: u32 = 2;
|
|
||||||
const SCALE: u32 = 3;
|
|
||||||
|
|
||||||
const SP_UNKNOWN: i32 = 0;
|
const SP_UNKNOWN: i32 = 0;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -186,7 +178,7 @@ impl WlOutput {
|
||||||
|
|
||||||
fn mode(self: &Rc<Self>) -> DynEventFormatter {
|
fn mode(self: &Rc<Self>) -> DynEventFormatter {
|
||||||
Box::new(Mode {
|
Box::new(Mode {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
flags: MODE_CURRENT,
|
flags: MODE_CURRENT,
|
||||||
width: self.global.width.get() as _,
|
width: self.global.width.get() as _,
|
||||||
height: self.global.height.get() as _,
|
height: self.global.height.get() as _,
|
||||||
|
|
@ -196,13 +188,13 @@ impl WlOutput {
|
||||||
|
|
||||||
fn scale(self: &Rc<Self>) -> DynEventFormatter {
|
fn scale(self: &Rc<Self>) -> DynEventFormatter {
|
||||||
Box::new(Scale {
|
Box::new(Scale {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
factor: 1,
|
factor: 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn done(self: &Rc<Self>) -> DynEventFormatter {
|
fn done(self: &Rc<Self>) -> DynEventFormatter {
|
||||||
Box::new(Done { obj: self.clone() })
|
Box::new(Done { self_id: self.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_binding(&self) {
|
fn remove_binding(&self) {
|
||||||
|
|
|
||||||
|
|
@ -24,113 +24,3 @@ pub enum ReleaseError {
|
||||||
}
|
}
|
||||||
efrom!(ReleaseError, ClientError);
|
efrom!(ReleaseError, ClientError);
|
||||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
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::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_region::*;
|
||||||
const DESTROY: u32 = 0;
|
|
||||||
const ADD: u32 = 1;
|
|
||||||
const SUBTRACT: u32 = 2;
|
|
||||||
|
|
||||||
id!(WlRegionId);
|
|
||||||
|
|
||||||
pub struct WlRegion {
|
pub struct WlRegion {
|
||||||
id: WlRegionId,
|
id: WlRegionId,
|
||||||
|
|
|
||||||
|
|
@ -40,67 +40,3 @@ pub enum SubtractError {
|
||||||
NegativeExtents,
|
NegativeExtents,
|
||||||
}
|
}
|
||||||
efrom!(SubtractError, ParseFailed, MsgParserError);
|
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 crate::utils::buffd::MsgParser;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_registry::*;
|
||||||
const BIND: u32 = 0;
|
|
||||||
|
|
||||||
const GLOBAL: u32 = 0;
|
|
||||||
const GLOBAL_REMOVE: u32 = 1;
|
|
||||||
|
|
||||||
id!(WlRegistryId);
|
|
||||||
|
|
||||||
pub struct WlRegistry {
|
pub struct WlRegistry {
|
||||||
id: WlRegistryId,
|
id: WlRegistryId,
|
||||||
|
|
@ -28,16 +22,18 @@ impl WlRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global(self: &Rc<Self>, global: &Rc<dyn Global>) -> DynEventFormatter {
|
pub fn global(self: &Rc<Self>, global: &Rc<dyn Global>) -> DynEventFormatter {
|
||||||
Box::new(GlobalE {
|
Box::new(GlobalOut {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
global: global.clone(),
|
name: global.name().raw(),
|
||||||
|
interface: global.interface().name().to_string(),
|
||||||
|
version: global.version(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_remove(self: &Rc<Self>, name: GlobalName) -> DynEventFormatter {
|
pub fn global_remove(self: &Rc<Self>, name: GlobalName) -> DynEventFormatter {
|
||||||
Box::new(GlobalRemove {
|
Box::new(GlobalRemove {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
name,
|
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)]
|
#[error("Tried to bind to global {} of type {} and version {} using version {}", .0.name, .0.interface.name(), .0.version, .0.actual)]
|
||||||
InvalidVersion(VersionError),
|
InvalidVersion(VersionError),
|
||||||
}
|
}
|
||||||
|
efrom!(BindError, ParseError, MsgParserError);
|
||||||
|
efrom!(BindError, GlobalsError);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InterfaceError {
|
pub struct InterfaceError {
|
||||||
|
|
@ -43,76 +45,3 @@ pub struct VersionError {
|
||||||
pub actual: u32,
|
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::xdg_surface::XdgSurface;
|
||||||
use crate::ifs::wl_surface::WlSurface;
|
use crate::ifs::wl_surface::WlSurface;
|
||||||
use crate::ifs::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
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::tree::{FloatNode, FoundNode, Node};
|
||||||
use crate::utils::smallmap::SmallMap;
|
use crate::utils::smallmap::SmallMap;
|
||||||
use crate::xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP};
|
use crate::xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct NodeSeatState {
|
pub struct NodeSeatState {
|
||||||
|
|
@ -371,8 +371,8 @@ impl WlSeatGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn surface_primary_selection_device_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
fn surface_primary_selection_device_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
|
||||||
where
|
where
|
||||||
F: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>) -> DynEventFormatter,
|
F: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>) -> DynEventFormatter,
|
||||||
{
|
{
|
||||||
let client = &surface.client;
|
let client = &surface.client;
|
||||||
self.for_each_primary_selection_device(ver, client.id, |p| {
|
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::cell::{Cell, RefCell};
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
use uapi::{c, OwnedFd};
|
use uapi::{c, OwnedFd};
|
||||||
|
use crate::wire::wl_seat::*;
|
||||||
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;
|
|
||||||
|
|
||||||
const POINTER: u32 = 1;
|
const POINTER: u32 = 1;
|
||||||
const KEYBOARD: u32 = 2;
|
const KEYBOARD: u32 = 2;
|
||||||
|
|
@ -317,15 +309,15 @@ pub struct WlSeat {
|
||||||
impl WlSeat {
|
impl WlSeat {
|
||||||
fn capabilities(self: &Rc<Self>) -> DynEventFormatter {
|
fn capabilities(self: &Rc<Self>) -> DynEventFormatter {
|
||||||
Box::new(Capabilities {
|
Box::new(Capabilities {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
capabilities: POINTER | KEYBOARD,
|
capabilities: POINTER | KEYBOARD,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name(self: &Rc<Self>, name: &Rc<String>) -> DynEventFormatter {
|
fn name(self: &Rc<Self>, name: &Rc<String>) -> DynEventFormatter {
|
||||||
Box::new(Name {
|
Box::new(NameOut {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
name: name.clone(),
|
name: name.deref().clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,100 +66,3 @@ pub enum ReleaseError {
|
||||||
}
|
}
|
||||||
efrom!(ReleaseError, ClientError, ClientError);
|
efrom!(ReleaseError, ClientError, ClientError);
|
||||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
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;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
use uapi::{c, Errno, OwnedFd};
|
use uapi::{c, Errno, OwnedFd};
|
||||||
|
use crate::wire::wl_keyboard::*;
|
||||||
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;
|
|
||||||
|
|
||||||
pub const REPEAT_INFO_SINCE: u32 = 4;
|
pub const REPEAT_INFO_SINCE: u32 = 4;
|
||||||
|
|
||||||
|
|
@ -24,13 +16,9 @@ pub const REPEAT_INFO_SINCE: u32 = 4;
|
||||||
const NO_KEYMAP: u32 = 0;
|
const NO_KEYMAP: u32 = 0;
|
||||||
pub(super) const XKB_V1: u32 = 1;
|
pub(super) const XKB_V1: u32 = 1;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(super) const RELEASED: u32 = 0;
|
pub(super) const RELEASED: u32 = 0;
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(super) const PRESSED: u32 = 1;
|
pub(super) const PRESSED: u32 = 1;
|
||||||
|
|
||||||
id!(WlKeyboardId);
|
|
||||||
|
|
||||||
pub struct WlKeyboard {
|
pub struct WlKeyboard {
|
||||||
id: WlKeyboardId,
|
id: WlKeyboardId,
|
||||||
seat: Rc<WlSeat>,
|
seat: Rc<WlSeat>,
|
||||||
|
|
@ -76,41 +64,38 @@ impl WlKeyboard {
|
||||||
|
|
||||||
pub fn keymap(self: &Rc<Self>, format: u32, fd: Rc<OwnedFd>, size: u32) -> DynEventFormatter {
|
pub fn keymap(self: &Rc<Self>, format: u32, fd: Rc<OwnedFd>, size: u32) -> DynEventFormatter {
|
||||||
Box::new(Keymap {
|
Box::new(Keymap {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
format,
|
format,
|
||||||
fd,
|
fd,
|
||||||
size,
|
size,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn enter(
|
pub fn enter(
|
||||||
self: &Rc<Self>,
|
self: &Rc<Self>,
|
||||||
serial: u32,
|
serial: u32,
|
||||||
surface: WlSurfaceId,
|
surface: WlSurfaceId,
|
||||||
keys: Vec<u32>,
|
keys: Vec<u32>,
|
||||||
) -> DynEventFormatter {
|
) -> DynEventFormatter {
|
||||||
Box::new(Enter {
|
Box::new(EnterOut {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
surface,
|
surface,
|
||||||
keys,
|
keys,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
||||||
Box::new(Leave {
|
Box::new(Leave {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
surface,
|
surface,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn key(self: &Rc<Self>, serial: u32, time: u32, key: u32, state: u32) -> DynEventFormatter {
|
pub fn key(self: &Rc<Self>, serial: u32, time: u32, key: u32, state: u32) -> DynEventFormatter {
|
||||||
Box::new(Key {
|
Box::new(Key {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
key,
|
key,
|
||||||
|
|
@ -118,7 +103,6 @@ impl WlKeyboard {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn modifiers(
|
pub fn modifiers(
|
||||||
self: &Rc<Self>,
|
self: &Rc<Self>,
|
||||||
serial: u32,
|
serial: u32,
|
||||||
|
|
@ -128,7 +112,7 @@ impl WlKeyboard {
|
||||||
group: u32,
|
group: u32,
|
||||||
) -> DynEventFormatter {
|
) -> DynEventFormatter {
|
||||||
Box::new(Modifiers {
|
Box::new(Modifiers {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
mods_depressed,
|
mods_depressed,
|
||||||
mods_latched,
|
mods_latched,
|
||||||
|
|
@ -137,10 +121,9 @@ impl WlKeyboard {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn repeat_info(self: &Rc<Self>, rate: i32, delay: i32) -> DynEventFormatter {
|
pub fn repeat_info(self: &Rc<Self>, rate: i32, delay: i32) -> DynEventFormatter {
|
||||||
Box::new(RepeatInfo {
|
Box::new(RepeatInfo {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
rate,
|
rate,
|
||||||
delay,
|
delay,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -33,177 +33,3 @@ pub enum ReleaseError {
|
||||||
}
|
}
|
||||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||||
efrom!(ReleaseError, ClientError, ClientError);
|
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 crate::utils::buffd::MsgParser;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
use crate::wire::wl_pointer::*;
|
||||||
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;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const ROLE: u32 = 0;
|
const ROLE: u32 = 0;
|
||||||
|
|
@ -43,8 +31,6 @@ const WHEEL_TILT: u32 = 3;
|
||||||
|
|
||||||
pub const POINTER_FRAME_SINCE_VERSION: u32 = 5;
|
pub const POINTER_FRAME_SINCE_VERSION: u32 = 5;
|
||||||
|
|
||||||
id!(WlPointerId);
|
|
||||||
|
|
||||||
pub struct WlPointer {
|
pub struct WlPointer {
|
||||||
id: WlPointerId,
|
id: WlPointerId,
|
||||||
seat: Rc<WlSeat>,
|
seat: Rc<WlSeat>,
|
||||||
|
|
@ -66,7 +52,7 @@ impl WlPointer {
|
||||||
y: Fixed,
|
y: Fixed,
|
||||||
) -> DynEventFormatter {
|
) -> DynEventFormatter {
|
||||||
Box::new(Enter {
|
Box::new(Enter {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
surface,
|
surface,
|
||||||
surface_x: x,
|
surface_x: x,
|
||||||
|
|
@ -76,7 +62,7 @@ impl WlPointer {
|
||||||
|
|
||||||
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
pub fn leave(self: &Rc<Self>, serial: u32, surface: WlSurfaceId) -> DynEventFormatter {
|
||||||
Box::new(Leave {
|
Box::new(Leave {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
surface,
|
surface,
|
||||||
})
|
})
|
||||||
|
|
@ -84,7 +70,7 @@ impl WlPointer {
|
||||||
|
|
||||||
pub fn motion(self: &Rc<Self>, time: u32, x: Fixed, y: Fixed) -> DynEventFormatter {
|
pub fn motion(self: &Rc<Self>, time: u32, x: Fixed, y: Fixed) -> DynEventFormatter {
|
||||||
Box::new(Motion {
|
Box::new(Motion {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
time,
|
time,
|
||||||
surface_x: x,
|
surface_x: x,
|
||||||
surface_y: y,
|
surface_y: y,
|
||||||
|
|
@ -99,7 +85,7 @@ impl WlPointer {
|
||||||
state: u32,
|
state: u32,
|
||||||
) -> DynEventFormatter {
|
) -> DynEventFormatter {
|
||||||
Box::new(Button {
|
Box::new(Button {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
button,
|
button,
|
||||||
|
|
@ -109,7 +95,7 @@ impl WlPointer {
|
||||||
|
|
||||||
pub fn axis(self: &Rc<Self>, time: u32, axis: u32, value: Fixed) -> DynEventFormatter {
|
pub fn axis(self: &Rc<Self>, time: u32, axis: u32, value: Fixed) -> DynEventFormatter {
|
||||||
Box::new(Axis {
|
Box::new(Axis {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
time,
|
time,
|
||||||
axis,
|
axis,
|
||||||
value,
|
value,
|
||||||
|
|
@ -118,13 +104,13 @@ impl WlPointer {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn frame(self: &Rc<Self>) -> DynEventFormatter {
|
pub fn frame(self: &Rc<Self>) -> DynEventFormatter {
|
||||||
Box::new(Frame { obj: self.clone() })
|
Box::new(Frame { self_id: self.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn axis_source(self: &Rc<Self>, axis_source: u32) -> DynEventFormatter {
|
pub fn axis_source(self: &Rc<Self>, axis_source: u32) -> DynEventFormatter {
|
||||||
Box::new(AxisSource {
|
Box::new(AxisSource {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
axis_source,
|
axis_source,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +118,7 @@ impl WlPointer {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn axis_stop(self: &Rc<Self>, time: u32, axis: u32) -> DynEventFormatter {
|
pub fn axis_stop(self: &Rc<Self>, time: u32, axis: u32) -> DynEventFormatter {
|
||||||
Box::new(AxisStop {
|
Box::new(AxisStop {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
time,
|
time,
|
||||||
axis,
|
axis,
|
||||||
})
|
})
|
||||||
|
|
@ -141,7 +127,7 @@ impl WlPointer {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn axis_discrete(self: &Rc<Self>, axis: u32, discrete: i32) -> DynEventFormatter {
|
pub fn axis_discrete(self: &Rc<Self>, axis: u32, discrete: i32) -> DynEventFormatter {
|
||||||
Box::new(AxisDiscrete {
|
Box::new(AxisDiscrete {
|
||||||
obj: self.clone(),
|
self_id: self.id,
|
||||||
axis,
|
axis,
|
||||||
discrete,
|
discrete,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -44,265 +44,3 @@ pub enum ReleaseError {
|
||||||
}
|
}
|
||||||
efrom!(ReleaseError, ParseError, MsgParserError);
|
efrom!(ReleaseError, ParseError, MsgParserError);
|
||||||
efrom!(ReleaseError, ClientError, ClientError);
|
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 utils;
|
||||||
mod wheel;
|
mod wheel;
|
||||||
mod xkbcommon;
|
mod xkbcommon;
|
||||||
|
mod wire;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::builder()
|
env_logger::builder()
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ use crate::client::ClientError;
|
||||||
use crate::utils::buffd::MsgParser;
|
use crate::utils::buffd::MsgParser;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::rc::Rc;
|
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)]
|
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
pub struct ObjectId(u32);
|
pub struct ObjectId(u32);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::rc::Rc;
|
||||||
use crate::fixed::Fixed;
|
use crate::fixed::Fixed;
|
||||||
use crate::globals::GlobalName;
|
use crate::globals::GlobalName;
|
||||||
use crate::object::ObjectId;
|
use crate::object::ObjectId;
|
||||||
|
|
@ -65,18 +66,11 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bstr(&mut self) -> Result<&'b BStr, MsgParserError> {
|
pub fn bstr(&mut self) -> Result<&'b BStr, MsgParserError> {
|
||||||
let len = self.uint()? as usize;
|
let s = self.array()?;
|
||||||
if len == 0 {
|
if s.len() == 0 {
|
||||||
return Err(MsgParserError::EmptyString);
|
return Err(MsgParserError::EmptyString);
|
||||||
}
|
}
|
||||||
let cap = (len + 3) & !3;
|
Ok(s[..s.len()-1].as_bstr())
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn str(&mut self) -> Result<&'b str, MsgParserError> {
|
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() {
|
match self.buf.get_fd() {
|
||||||
Ok(fd) => Ok(fd),
|
Ok(fd) => Ok(Rc::new(fd)),
|
||||||
_ => Err(MsgParserError::MissingFd),
|
_ => Err(MsgParserError::MissingFd),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,4 +94,15 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
||||||
Err(MsgParserError::TrailingData)
|
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"));
|
||||||
15
wire/org_kde_kwin_server_decoration.txt
Normal file
15
wire/org_kde_kwin_server_decoration.txt
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg release = 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg request_mode = 1 {
|
||||||
|
mode: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg mode = 0 {
|
||||||
|
mode: u32,
|
||||||
|
}
|
||||||
12
wire/org_kde_kwin_server_decoration_manager.txt
Normal file
12
wire/org_kde_kwin_server_decoration_manager.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg create = 0 {
|
||||||
|
id: id(org_kde_kwin_server_decoration),
|
||||||
|
surface: id(wl_surface),
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg default_mode = 0 {
|
||||||
|
mode: u32,
|
||||||
|
}
|
||||||
11
wire/wl_buffer.txt
Normal file
11
wire/wl_buffer.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg destroy = 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg release = 0 {
|
||||||
|
|
||||||
|
}
|
||||||
5
wire/wl_callback.txt
Normal file
5
wire/wl_callback.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg done = 0 {
|
||||||
|
callback_data: u32,
|
||||||
|
}
|
||||||
9
wire/wl_compositor.txt
Normal file
9
wire/wl_compositor.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg create_surface = 0 {
|
||||||
|
id: id(wl_surface),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg create_region = 1 {
|
||||||
|
id: id(wl_region),
|
||||||
|
}
|
||||||
49
wire/wl_data_device.txt
Normal file
49
wire/wl_data_device.txt
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg start_drag = 0 {
|
||||||
|
source: id(wl_data_source),
|
||||||
|
origin: id(wl_surface),
|
||||||
|
icon: id(wl_surface),
|
||||||
|
serial: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg set_selection = 1 {
|
||||||
|
source: id(wl_data_source),
|
||||||
|
serial: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg release = 2 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg data_offer = 0 {
|
||||||
|
id: id(wl_data_offer),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg enter = 1 {
|
||||||
|
serial: u32,
|
||||||
|
surface: id(wl_surface),
|
||||||
|
x: fixed,
|
||||||
|
y: fixed,
|
||||||
|
id: id(wl_data_offer),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg leave = 2 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg motion = 3 {
|
||||||
|
time: u32,
|
||||||
|
x: fixed,
|
||||||
|
y: fixed,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg drop = 4 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg selection = 5 {
|
||||||
|
id: id(wl_data_offer),
|
||||||
|
}
|
||||||
10
wire/wl_data_device_manager.txt
Normal file
10
wire/wl_data_device_manager.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg create_data_source = 0 {
|
||||||
|
id: id(wl_data_source),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg get_data_device = 1 {
|
||||||
|
id: id(wl_data_device),
|
||||||
|
seat: id(wl_seat),
|
||||||
|
}
|
||||||
36
wire/wl_data_offer.txt
Normal file
36
wire/wl_data_offer.txt
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg accept = 0 {
|
||||||
|
serial: u32,
|
||||||
|
mime_type: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg receive = 1 {
|
||||||
|
mime_type: str,
|
||||||
|
fd: fd,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg destroy = 2 {
|
||||||
|
}
|
||||||
|
|
||||||
|
msg finish = 3 {
|
||||||
|
}
|
||||||
|
|
||||||
|
msg set_actions = 4 {
|
||||||
|
dnd_actions: u32,
|
||||||
|
preferred_action: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg offer = 0 {
|
||||||
|
mime_type: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg source_actions = 1 {
|
||||||
|
source_actions: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg action = 2 {
|
||||||
|
dnd_action: u32,
|
||||||
|
}
|
||||||
40
wire/wl_data_source.txt
Normal file
40
wire/wl_data_source.txt
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg offer = 0 {
|
||||||
|
mime_type: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg destroy = 1 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg set_actions = 2 {
|
||||||
|
dnd_actions: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg target = 0 {
|
||||||
|
mime_type: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg send = 1 {
|
||||||
|
mime_type: str,
|
||||||
|
fd: fd,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg cancelled = 2 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg dnd_drop_performed = 3 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg dnd_finished = 4 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg action = 5 {
|
||||||
|
dnd_action: u32,
|
||||||
|
}
|
||||||
21
wire/wl_display.txt
Normal file
21
wire/wl_display.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg sync = 0 {
|
||||||
|
callback: id(wl_callback),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg get_registry = 1 {
|
||||||
|
registry: id(wl_registry),
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg error = 0 {
|
||||||
|
object_id: id(object),
|
||||||
|
code: u32,
|
||||||
|
message: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg delete_id = 1 {
|
||||||
|
id: u32,
|
||||||
|
}
|
||||||
60
wire/wl_drm.txt
Normal file
60
wire/wl_drm.txt
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg authenticate = 0 {
|
||||||
|
id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg create_buffer = 1 {
|
||||||
|
id: id(wl_buffer),
|
||||||
|
name: u32,
|
||||||
|
width: i32,
|
||||||
|
height: i32,
|
||||||
|
stride: u32,
|
||||||
|
format: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg create_planar_buffer = 2 {
|
||||||
|
id: id(wl_buffer),
|
||||||
|
name: u32,
|
||||||
|
width: i32,
|
||||||
|
height: i32,
|
||||||
|
format: u32,
|
||||||
|
offset0: i32,
|
||||||
|
stride0: i32,
|
||||||
|
offset1: i32,
|
||||||
|
stride1: i32,
|
||||||
|
offset2: i32,
|
||||||
|
stride2: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg create_prime_buffer = 3 {
|
||||||
|
id: id(wl_buffer),
|
||||||
|
name: fd,
|
||||||
|
width : i32,
|
||||||
|
height : i32,
|
||||||
|
format : u32,
|
||||||
|
offset0 : i32,
|
||||||
|
stride0 : i32,
|
||||||
|
offset1 : i32,
|
||||||
|
stride1 : i32,
|
||||||
|
offset2 : i32,
|
||||||
|
stride2 : i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg device = 0 {
|
||||||
|
name: bstr,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg format = 1 {
|
||||||
|
format: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg authenticated = 2 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg capabilities = 3 {
|
||||||
|
value: u32,
|
||||||
|
}
|
||||||
44
wire/wl_keyboard.txt
Normal file
44
wire/wl_keyboard.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg release = 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg keymap = 0 {
|
||||||
|
format: u32,
|
||||||
|
fd: fd,
|
||||||
|
size: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg enter = 1 {
|
||||||
|
serial: u32,
|
||||||
|
surface: id(wl_surface),
|
||||||
|
keys: array(u32),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg leave = 2 {
|
||||||
|
serial: u32,
|
||||||
|
surface: id(wl_surface),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg key = 3 {
|
||||||
|
serial: u32,
|
||||||
|
time: u32,
|
||||||
|
key: u32,
|
||||||
|
state: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg modifiers = 4 {
|
||||||
|
serial: u32,
|
||||||
|
mods_depressed: u32,
|
||||||
|
mods_latched: u32,
|
||||||
|
mods_locked: u32,
|
||||||
|
group: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg repeat_info = 5 {
|
||||||
|
rate: i32,
|
||||||
|
delay: i32,
|
||||||
|
}
|
||||||
41
wire/wl_output.txt
Normal file
41
wire/wl_output.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg release = 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg geometry = 0 {
|
||||||
|
x : i32,
|
||||||
|
y : i32,
|
||||||
|
physical_width : i32,
|
||||||
|
physical_height : i32,
|
||||||
|
subpixel : i32,
|
||||||
|
make : str,
|
||||||
|
model : str,
|
||||||
|
transform : i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg mode = 1 {
|
||||||
|
flags : u32,
|
||||||
|
width : i32,
|
||||||
|
height : i32,
|
||||||
|
refresh : i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg done = 2 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg scale = 3 {
|
||||||
|
factor: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg name = 4 {
|
||||||
|
name: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg description = 5 {
|
||||||
|
description: str,
|
||||||
|
}
|
||||||
63
wire/wl_pointer.txt
Normal file
63
wire/wl_pointer.txt
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg set_cursor = 0 {
|
||||||
|
serial: u32,
|
||||||
|
surface: id(wl_surface),
|
||||||
|
hotspot_x: i32,
|
||||||
|
hotspot_y: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg release = 1 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg enter = 0 {
|
||||||
|
serial: u32,
|
||||||
|
surface: id(wl_surface),
|
||||||
|
surface_x: fixed,
|
||||||
|
surface_y: fixed,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg leave = 1 {
|
||||||
|
serial: u32,
|
||||||
|
surface: id(wl_surface),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg motion = 2 {
|
||||||
|
time: u32,
|
||||||
|
surface_x: fixed,
|
||||||
|
surface_y: fixed,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg button = 3 {
|
||||||
|
serial: u32,
|
||||||
|
time: u32,
|
||||||
|
button: u32,
|
||||||
|
state: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg axis = 4 {
|
||||||
|
time: u32,
|
||||||
|
axis: u32,
|
||||||
|
value: fixed,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg frame = 5 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg axis_source = 6 {
|
||||||
|
axis_source: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg axis_stop = 7 {
|
||||||
|
time: u32,
|
||||||
|
axis: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg axis_discrete = 8 {
|
||||||
|
axis: u32,
|
||||||
|
discrete: i32,
|
||||||
|
}
|
||||||
19
wire/wl_region.txt
Normal file
19
wire/wl_region.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg destroy = 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
msg add = 1 {
|
||||||
|
x: i32,
|
||||||
|
y: i32,
|
||||||
|
width: i32,
|
||||||
|
height: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg subtract = 2 {
|
||||||
|
x: i32,
|
||||||
|
y: i32,
|
||||||
|
width: i32,
|
||||||
|
height: i32,
|
||||||
|
}
|
||||||
20
wire/wl_registry.txt
Normal file
20
wire/wl_registry.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg bind = 0 {
|
||||||
|
name: u32,
|
||||||
|
id: id(object),
|
||||||
|
interface: str,
|
||||||
|
version: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg global = 0 {
|
||||||
|
name: u32,
|
||||||
|
interface: str,
|
||||||
|
version: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg global_remove = 1 {
|
||||||
|
name: u32,
|
||||||
|
}
|
||||||
26
wire/wl_seat.txt
Normal file
26
wire/wl_seat.txt
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# requests
|
||||||
|
|
||||||
|
msg get_pointer = 0 {
|
||||||
|
id: id(wl_pointer),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg get_keyboard = 1 {
|
||||||
|
id: id(wl_keyboard),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg get_touch = 2 {
|
||||||
|
id: id(wl_touch),
|
||||||
|
}
|
||||||
|
|
||||||
|
msg release = 3 {
|
||||||
|
}
|
||||||
|
|
||||||
|
# events
|
||||||
|
|
||||||
|
msg capabilities = 0 {
|
||||||
|
capabilities: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
msg name = 1 {
|
||||||
|
name: str,
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue