1
0
Fork 0
forked from wry/wry

autocommit 2022-01-03 18:56:52 CET

This commit is contained in:
Julian Orth 2022-01-03 18:56:52 +01:00
parent fc887b339e
commit 30376c595c
39 changed files with 3157 additions and 309 deletions

View file

@ -39,7 +39,7 @@ impl WlShmGlobal {
client: client.clone(),
});
client.add_client_obj(&obj)?;
for &format in Format::formats() {
for &format in client.state.formats.values() {
client
.event(Box::new(FormatE {
obj: obj.clone(),
@ -80,25 +80,6 @@ impl WlShmObj {
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Format {
Argb8888,
Xrgb8888,
}
impl Format {
fn uint(self) -> u32 {
match self {
Format::Argb8888 => 0,
Format::Xrgb8888 => 1,
}
}
fn formats() -> &'static [Format] {
&[Format::Argb8888, Format::Xrgb8888]
}
}
bind!(WlShmGlobal);
impl Global for WlShmGlobal {

View file

@ -1,5 +1,6 @@
use crate::client::{ClientError, EventFormatter, RequestParser};
use crate::ifs::wl_shm::{Format, WlShmObj, FORMAT};
use crate::format::Format;
use crate::ifs::wl_shm::{WlShmObj, FORMAT};
use crate::ifs::wl_shm_pool::WlShmPoolError;
use crate::object::{Object, ObjectId};
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
@ -60,11 +61,11 @@ impl Debug for CreatePool {
pub(super) struct FormatE {
pub obj: Rc<WlShmObj>,
pub format: Format,
pub format: &'static Format,
}
impl EventFormatter for FormatE {
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
fmt.header(self.obj.id, FORMAT).uint(self.format.uint());
fmt.header(self.obj.id, FORMAT).uint(self.format.id);
}
fn obj(&self) -> &dyn Object {
&*self.obj
@ -72,6 +73,10 @@ impl EventFormatter for FormatE {
}
impl Debug for FormatE {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "format(format: {:?})", self.format)
write!(
f,
"format(format: \"{}\" (0x{:x}))",
self.format.name, self.format.id
)
}
}