1
0
Fork 0
forked from wry/wry

autocommit 2022-02-05 18:14:24 CET

This commit is contained in:
Julian Orth 2022-02-05 18:14:24 +01:00
parent 2d8b3a200e
commit 3a4ae99b9a
71 changed files with 1626 additions and 1306 deletions

View file

@ -3,7 +3,7 @@ mod types;
use crate::backend::Output;
use crate::client::{Client, ClientId, DynEventFormatter, WlEvent};
use crate::globals::{Global, GlobalName};
use crate::object::{Interface, Object, ObjectId};
use crate::object::{Interface, Object};
use crate::utils::buffd::MsgParser;
use ahash::AHashMap;
use std::cell::{Cell, RefCell};
@ -60,7 +60,7 @@ pub struct WlOutputGlobal {
pub y: Cell<i32>,
width: Cell<i32>,
height: Cell<i32>,
pub bindings: RefCell<AHashMap<ClientId, AHashMap<WlOutputId, Rc<WlOutputObj>>>>,
pub bindings: RefCell<AHashMap<ClientId, AHashMap<WlOutputId, Rc<WlOutput>>>>,
}
impl WlOutputGlobal {
@ -112,7 +112,7 @@ impl WlOutputGlobal {
client: &Rc<Client>,
version: u32,
) -> Result<(), WlOutputError> {
let obj = Rc::new(WlOutputObj {
let obj = Rc::new(WlOutput {
global: self.clone(),
id,
client: client.clone(),
@ -160,14 +160,16 @@ impl Global for WlOutputGlobal {
}
}
pub struct WlOutputObj {
dedicated_add_global!(WlOutputGlobal, outputs);
pub struct WlOutput {
global: Rc<WlOutputGlobal>,
pub id: WlOutputId,
client: Rc<Client>,
version: u32,
}
impl WlOutputObj {
impl WlOutput {
fn send_done(&self) -> bool {
self.version >= 2
}
@ -226,31 +228,15 @@ impl WlOutputObj {
self.client.remove_obj(self)?;
Ok(())
}
fn handle_request_(
&self,
request: u32,
parser: MsgParser<'_, '_>,
) -> Result<(), WlOutputError> {
match request {
RELEASE => self.release(parser)?,
_ => unreachable!(),
}
Ok(())
}
}
handle_request!(WlOutputObj);
object_base! {
WlOutput, WlOutputError;
impl Object for WlOutputObj {
fn id(&self) -> ObjectId {
self.id.into()
}
fn interface(&self) -> Interface {
Interface::WlOutput
}
RELEASE => release,
}
impl Object for WlOutput {
fn num_requests(&self) -> u32 {
if self.version < 3 {
0
@ -263,3 +249,5 @@ impl Object for WlOutputObj {
self.remove_binding();
}
}
simple_add_obj!(WlOutput);

View file

@ -1,5 +1,5 @@
use crate::client::{ClientError, EventFormatter, RequestParser};
use crate::ifs::wl_output::{WlOutputObj, DONE, GEOMETRY, MODE, SCALE};
use crate::ifs::wl_output::{WlOutput, DONE, GEOMETRY, MODE, SCALE};
use crate::object::Object;
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
use std::fmt::{Debug, Formatter};
@ -38,7 +38,7 @@ impl Debug for Release {
}
pub(super) struct Geometry {
pub obj: Rc<WlOutputObj>,
pub obj: Rc<WlOutput>,
pub x: i32,
pub y: i32,
pub physical_width: i32,
@ -72,7 +72,7 @@ impl Debug for Geometry {
}
pub(super) struct Mode {
pub obj: Rc<WlOutputObj>,
pub obj: Rc<WlOutput>,
pub flags: u32,
pub width: i32,
pub height: i32,
@ -101,7 +101,7 @@ impl Debug for Mode {
}
pub(super) struct Done {
pub obj: Rc<WlOutputObj>,
pub obj: Rc<WlOutput>,
}
impl EventFormatter for Done {
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
@ -118,7 +118,7 @@ impl Debug for Done {
}
pub(super) struct Scale {
pub obj: Rc<WlOutputObj>,
pub obj: Rc<WlOutput>,
pub factor: i32,
}
impl EventFormatter for Scale {