wire: remove unused user client layer
This commit is contained in:
parent
ce03990ea4
commit
5f02f22c8b
54 changed files with 11 additions and 3753 deletions
|
|
@ -274,47 +274,15 @@ fn write_message<W: Write>(f: &mut W, obj: &str, message: &Message) -> Result<()
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
enum RequestHandlerDirection {
|
||||
Request,
|
||||
Event,
|
||||
}
|
||||
|
||||
fn write_request_handler<W: Write>(
|
||||
f: &mut W,
|
||||
camel_obj_name: &str,
|
||||
messages: &[Lined<Message>],
|
||||
direction: RequestHandlerDirection,
|
||||
) -> Result<()> {
|
||||
let snake_direction;
|
||||
let camel_direction;
|
||||
let parent;
|
||||
let parser;
|
||||
let error;
|
||||
let param;
|
||||
writeln!(f)?;
|
||||
match direction {
|
||||
RequestHandlerDirection::Request => {
|
||||
snake_direction = "request";
|
||||
camel_direction = "Request";
|
||||
parent = "crate::object::Object";
|
||||
parser = "crate::client::Client";
|
||||
error = "crate::client::ClientError";
|
||||
param = "req";
|
||||
}
|
||||
RequestHandlerDirection::Event => {
|
||||
snake_direction = "event";
|
||||
camel_direction = "Event";
|
||||
parent = "crate::wl_usr::usr_object::UsrObject";
|
||||
parser = "crate::wl_usr::UsrCon";
|
||||
error = "crate::wl_usr::UsrConError";
|
||||
param = "ev";
|
||||
writeln!(f, " #[allow(clippy::allow_attributes, dead_code)]")?;
|
||||
}
|
||||
}
|
||||
writeln!(
|
||||
f,
|
||||
" pub trait {camel_obj_name}{camel_direction}Handler: {parent} + Sized {{"
|
||||
" pub trait {camel_obj_name}RequestHandler: crate::object::Object + Sized {{"
|
||||
)?;
|
||||
writeln!(f, " type Error: std::error::Error;")?;
|
||||
for message in messages {
|
||||
|
|
@ -326,24 +294,24 @@ fn write_request_handler<W: Write>(
|
|||
writeln!(f)?;
|
||||
writeln!(
|
||||
f,
|
||||
" fn {}(&self, {param}: {}{lt}, _slf: &Rc<Self>) -> Result<(), Self::Error>;",
|
||||
" fn {}(&self, req: {}{lt}, _slf: &Rc<Self>) -> Result<(), Self::Error>;",
|
||||
msg.safe_name, msg.camel_name
|
||||
)?;
|
||||
}
|
||||
writeln!(f)?;
|
||||
writeln!(f, " #[inline(always)]")?;
|
||||
writeln!(f, " fn handle_{snake_direction}_impl(")?;
|
||||
writeln!(f, " fn handle_request_impl(")?;
|
||||
writeln!(f, " self: Rc<Self>,")?;
|
||||
writeln!(f, " client: &{parser},")?;
|
||||
writeln!(f, " client: &crate::client::Client,")?;
|
||||
writeln!(f, " req: u32,")?;
|
||||
writeln!(
|
||||
f,
|
||||
" parser: crate::utils::buffd::MsgParser<'_, '_>,"
|
||||
)?;
|
||||
writeln!(f, " ) -> Result<(), {error}> {{")?;
|
||||
writeln!(f, " ) -> Result<(), crate::client::ClientError> {{")?;
|
||||
if messages.is_empty() {
|
||||
writeln!(f, " #![allow(unused_variables)]")?;
|
||||
writeln!(f, " Err({error}::InvalidMethod)")?;
|
||||
writeln!(f, " Err(crate::client::ClientError::InvalidMethod)")?;
|
||||
} else {
|
||||
writeln!(f, " let method;")?;
|
||||
writeln!(
|
||||
|
|
@ -379,10 +347,10 @@ fn write_request_handler<W: Write>(
|
|||
}
|
||||
writeln!(
|
||||
f,
|
||||
" _ => return Err({error}::InvalidMethod),"
|
||||
" _ => return Err(crate::client::ClientError::InvalidMethod),"
|
||||
)?;
|
||||
writeln!(f, " }};")?;
|
||||
writeln!(f, " Err({error}::MethodError {{")?;
|
||||
writeln!(f, " Err(crate::client::ClientError::MethodError {{")?;
|
||||
writeln!(f, " interface: {camel_obj_name},")?;
|
||||
writeln!(f, " id: self.id(),")?;
|
||||
writeln!(f, " method,")?;
|
||||
|
|
@ -417,6 +385,7 @@ fn write_file<W: Write>(
|
|||
let messages = parse_messages(&contents)?;
|
||||
writeln!(f)?;
|
||||
writeln!(f, "pub mod {} {{", obj_name)?;
|
||||
writeln!(f, " #![allow(dead_code)]")?;
|
||||
writeln!(f, " use super::*;")?;
|
||||
for message in messages.requests.iter().chain(messages.events.iter()) {
|
||||
write_message(f, &camel_obj_name, &message.val)?;
|
||||
|
|
@ -425,13 +394,6 @@ fn write_file<W: Write>(
|
|||
f,
|
||||
&camel_obj_name,
|
||||
&messages.requests,
|
||||
RequestHandlerDirection::Request,
|
||||
)?;
|
||||
write_request_handler(
|
||||
f,
|
||||
&camel_obj_name,
|
||||
&messages.events,
|
||||
RequestHandlerDirection::Event,
|
||||
)?;
|
||||
writeln!(f, "}}")?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ use {
|
|||
};
|
||||
pub use {
|
||||
error::{ClientError, ParserError},
|
||||
objects::MIN_SERVER_ID,
|
||||
};
|
||||
#[cfg(feature = "it")]
|
||||
pub use objects::MIN_SERVER_ID;
|
||||
|
||||
mod error;
|
||||
mod objects;
|
||||
|
|
|
|||
|
|
@ -11,33 +11,6 @@ macro_rules! efrom {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! usr_object_base {
|
||||
($self:ident = $oname:ident = $iname:ident; version = $version:expr;) => {
|
||||
impl crate::wl_usr::usr_object::UsrObjectBase for $oname {
|
||||
fn id(&$self) -> crate::object::ObjectId {
|
||||
$self.id.into()
|
||||
}
|
||||
|
||||
fn version(&$self) -> crate::object::Version {
|
||||
$version
|
||||
}
|
||||
|
||||
fn handle_event(
|
||||
$self: std::rc::Rc<Self>,
|
||||
con: &crate::wl_usr::UsrCon,
|
||||
event: u32,
|
||||
parser: crate::utils::buffd::MsgParser<'_, '_>,
|
||||
) -> Result<(), crate::wl_usr::UsrConError> {
|
||||
$self.handle_event_impl(con, event, parser)
|
||||
}
|
||||
|
||||
fn interface(&$self) -> crate::object::Interface {
|
||||
crate::wire::$iname
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! object_base {
|
||||
($self:ident = $oname:ident; version = $version:expr;) => {
|
||||
impl crate::object::ObjectBase for $oname {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,6 @@ mod wire;
|
|||
mod wire_dbus;
|
||||
mod wire_ei;
|
||||
mod wire_xcon;
|
||||
mod wl_usr;
|
||||
mod xcon;
|
||||
mod xwayland;
|
||||
|
||||
|
|
|
|||
370
src/wl_usr.rs
370
src/wl_usr.rs
|
|
@ -1,370 +0,0 @@
|
|||
pub mod usr_ifs;
|
||||
pub mod usr_object;
|
||||
|
||||
use {
|
||||
crate::{
|
||||
async_engine::{AsyncEngine, SpawnedFuture},
|
||||
client::{EventFormatter, MIN_SERVER_ID, RequestParser},
|
||||
io_uring::{IoUring, IoUringError},
|
||||
object::{Interface, ObjectId, Version, WL_DISPLAY_ID},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent,
|
||||
bitfield::Bitfield,
|
||||
buffd::{
|
||||
BufFdError, BufFdOut, MsgFormatter, MsgParser, MsgParserError, OutBuffer,
|
||||
OutBufferSwapchain, WlBufFdIn, WlMessage,
|
||||
},
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt,
|
||||
oserror::{OsError, OsErrorExt2},
|
||||
},
|
||||
video::dmabuf::DmaBufIds,
|
||||
wheel::Wheel,
|
||||
wire::wl_display,
|
||||
wl_usr::{
|
||||
usr_ifs::{
|
||||
usr_wl_callback::UsrWlCallback, usr_wl_display::UsrWlDisplay,
|
||||
usr_wl_registry::UsrWlRegistry,
|
||||
},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::VecDeque,
|
||||
error::Error,
|
||||
mem,
|
||||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
uapi::{OwnedFd, c},
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UsrConError {
|
||||
#[error("Could not create a socket")]
|
||||
CreateSocket(#[source] OsError),
|
||||
#[error("The socket path is too long")]
|
||||
SocketPathTooLong,
|
||||
#[error("Could not connect to the compositor")]
|
||||
Connect(#[source] IoUringError),
|
||||
#[error(transparent)]
|
||||
BufFdError(#[from] BufFdError),
|
||||
#[error("Could not read from the compositor")]
|
||||
Read(#[source] BufFdError),
|
||||
#[error("Could not write to the compositor")]
|
||||
Write(#[source] BufFdError),
|
||||
#[error("Server sent an event for object {0} that does not exist")]
|
||||
MissingObject(ObjectId),
|
||||
#[error("Could not process a `{}#{}.{}` event", .interface.name(), .id, .method)]
|
||||
MethodError {
|
||||
interface: Interface,
|
||||
id: ObjectId,
|
||||
method: &'static str,
|
||||
#[source]
|
||||
error: Box<dyn Error + 'static>,
|
||||
},
|
||||
#[error("Client tried to invoke a non-existent method")]
|
||||
InvalidMethod,
|
||||
}
|
||||
|
||||
pub struct UsrCon {
|
||||
pub ring: Rc<IoUring>,
|
||||
pub _wheel: Rc<Wheel>,
|
||||
pub eng: Rc<AsyncEngine>,
|
||||
pub server_id: u32,
|
||||
obj_ids: RefCell<Bitfield>,
|
||||
objects: CopyHashMap<ObjectId, Option<Rc<dyn UsrObject>>>,
|
||||
swapchain: Rc<RefCell<OutBufferSwapchain>>,
|
||||
flush_request: AsyncEvent,
|
||||
incoming: Cell<Option<SpawnedFuture<()>>>,
|
||||
outgoing: Cell<Option<SpawnedFuture<()>>>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrConOwner>>>,
|
||||
dead: Cell<bool>,
|
||||
dma_buf_ids: Rc<DmaBufIds>,
|
||||
}
|
||||
|
||||
pub trait UsrConOwner {
|
||||
fn killed(&self);
|
||||
}
|
||||
|
||||
impl UsrCon {
|
||||
pub async fn new(
|
||||
ring: &Rc<IoUring>,
|
||||
wheel: &Rc<Wheel>,
|
||||
eng: &Rc<AsyncEngine>,
|
||||
dma_buf_ids: &Rc<DmaBufIds>,
|
||||
path: &str,
|
||||
server_id: u32,
|
||||
) -> Result<Rc<Self>, UsrConError> {
|
||||
let socket = uapi::socket(c::AF_UNIX, c::SOCK_STREAM | c::SOCK_CLOEXEC, 0)
|
||||
.map(Rc::new)
|
||||
.map_os_err(UsrConError::CreateSocket)?;
|
||||
let mut addr: c::sockaddr_un = uapi::pod_zeroed();
|
||||
addr.sun_family = c::AF_UNIX as _;
|
||||
if path.len() >= addr.sun_path.len() {
|
||||
return Err(UsrConError::SocketPathTooLong);
|
||||
}
|
||||
let sun_path = uapi::as_bytes_mut(&mut addr.sun_path[..]);
|
||||
sun_path[..path.len()].copy_from_slice(path.as_bytes());
|
||||
sun_path[path.len()] = 0;
|
||||
if let Err(e) = ring.connect(&socket, &addr).await {
|
||||
return Err(UsrConError::Connect(e));
|
||||
}
|
||||
Ok(Self::from_socket(
|
||||
ring,
|
||||
wheel,
|
||||
eng,
|
||||
dma_buf_ids,
|
||||
&socket,
|
||||
server_id,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn from_socket(
|
||||
ring: &Rc<IoUring>,
|
||||
wheel: &Rc<Wheel>,
|
||||
eng: &Rc<AsyncEngine>,
|
||||
dma_buf_ids: &Rc<DmaBufIds>,
|
||||
socket: &Rc<OwnedFd>,
|
||||
server_id: u32,
|
||||
) -> Rc<Self> {
|
||||
let mut obj_ids = Bitfield::default();
|
||||
obj_ids.take(0);
|
||||
obj_ids.take(1);
|
||||
let slf = Rc::new(Self {
|
||||
ring: ring.clone(),
|
||||
_wheel: wheel.clone(),
|
||||
eng: eng.clone(),
|
||||
server_id,
|
||||
obj_ids: RefCell::new(obj_ids),
|
||||
objects: Default::default(),
|
||||
swapchain: Default::default(),
|
||||
flush_request: Default::default(),
|
||||
incoming: Default::default(),
|
||||
outgoing: Default::default(),
|
||||
owner: Default::default(),
|
||||
dead: Cell::new(false),
|
||||
dma_buf_ids: dma_buf_ids.clone(),
|
||||
});
|
||||
slf.objects.set(
|
||||
WL_DISPLAY_ID.into(),
|
||||
Some(Rc::new(UsrWlDisplay {
|
||||
id: WL_DISPLAY_ID,
|
||||
con: slf.clone(),
|
||||
version: Version(1),
|
||||
})),
|
||||
);
|
||||
slf.incoming.set(Some(
|
||||
slf.eng.spawn(
|
||||
"wl_usr incoming",
|
||||
Incoming {
|
||||
con: slf.clone(),
|
||||
buf: WlBufFdIn::new(socket, &slf.ring),
|
||||
}
|
||||
.run(),
|
||||
),
|
||||
));
|
||||
slf.outgoing.set(Some(
|
||||
slf.eng.spawn(
|
||||
"wl_usr outgoing",
|
||||
Outgoing {
|
||||
con: slf.clone(),
|
||||
buf: BufFdOut::new(socket, &slf.ring),
|
||||
buffers: Default::default(),
|
||||
}
|
||||
.run(),
|
||||
),
|
||||
));
|
||||
slf
|
||||
}
|
||||
|
||||
pub fn kill(&self) {
|
||||
self.dead.set(true);
|
||||
for obj in self.objects.lock().drain_values() {
|
||||
if let Some(obj) = obj {
|
||||
obj.break_loops();
|
||||
}
|
||||
}
|
||||
self.incoming.take();
|
||||
self.outgoing.take();
|
||||
if let Some(owner) = self.owner.take() {
|
||||
owner.killed();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn release_id(&self, id: u32) {
|
||||
self.obj_ids.borrow_mut().release(id);
|
||||
self.objects.remove(&ObjectId::from_raw(id));
|
||||
}
|
||||
|
||||
pub fn remove_obj(&self, obj: &impl UsrObject) {
|
||||
obj.destroy();
|
||||
obj.break_loops();
|
||||
if obj.id().raw() >= MIN_SERVER_ID {
|
||||
self.objects.remove(&obj.id());
|
||||
} else {
|
||||
self.objects.set(obj.id(), None);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_object(&self, obj: Rc<dyn UsrObject>) {
|
||||
if !self.dead.get() {
|
||||
self.objects.set(obj.id(), Some(obj));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_registry(self: &Rc<Self>) -> Rc<UsrWlRegistry> {
|
||||
let registry = Rc::new(UsrWlRegistry {
|
||||
id: self.id(),
|
||||
con: self.clone(),
|
||||
owner: Default::default(),
|
||||
version: Version(1),
|
||||
});
|
||||
self.request(wl_display::GetRegistry {
|
||||
self_id: WL_DISPLAY_ID,
|
||||
registry: registry.id,
|
||||
});
|
||||
self.add_object(registry.clone());
|
||||
registry
|
||||
}
|
||||
|
||||
pub fn sync<F>(self: &Rc<Self>, handler: F)
|
||||
where
|
||||
F: FnOnce() + 'static,
|
||||
{
|
||||
let callback = Rc::new(UsrWlCallback::new(self));
|
||||
callback.owner.set(Some(Rc::new(Cell::new(Some(handler)))));
|
||||
self.request(wl_display::Sync {
|
||||
self_id: WL_DISPLAY_ID,
|
||||
callback: callback.id,
|
||||
});
|
||||
self.add_object(callback);
|
||||
}
|
||||
|
||||
pub fn parse<'a, R: RequestParser<'a>>(
|
||||
&self,
|
||||
obj: &impl UsrObject,
|
||||
mut parser: MsgParser<'_, 'a>,
|
||||
) -> Result<R, MsgParserError> {
|
||||
let res = R::parse(&mut parser)?;
|
||||
log::trace!(
|
||||
"Server {} -> {}@{}.{:?}",
|
||||
self.server_id,
|
||||
obj.interface().name(),
|
||||
obj.id(),
|
||||
res
|
||||
);
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn request<T: EventFormatter>(self: &Rc<Self>, event: T) {
|
||||
if self.dead.get() {
|
||||
return;
|
||||
}
|
||||
if log::log_enabled!(log::Level::Trace) {
|
||||
log::trace!(
|
||||
"Server {} <= {}@{}.{:?}",
|
||||
self.server_id,
|
||||
event.interface().name(),
|
||||
event.id(),
|
||||
event,
|
||||
);
|
||||
}
|
||||
let mut fds = vec![];
|
||||
let mut swapchain = self.swapchain.borrow_mut();
|
||||
let mut fmt = MsgFormatter::new(&mut swapchain.cur, &mut fds);
|
||||
event.format(&mut fmt);
|
||||
fmt.write_len();
|
||||
if swapchain.cur.is_full() {
|
||||
swapchain.commit();
|
||||
}
|
||||
self.flush_request.trigger();
|
||||
}
|
||||
|
||||
pub fn id<T: From<ObjectId>>(&self) -> T {
|
||||
let id = self.obj_ids.borrow_mut().acquire();
|
||||
ObjectId::from_raw(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
struct Outgoing {
|
||||
con: Rc<UsrCon>,
|
||||
buf: BufFdOut,
|
||||
buffers: VecDeque<OutBuffer>,
|
||||
}
|
||||
|
||||
impl Outgoing {
|
||||
async fn run(mut self) {
|
||||
loop {
|
||||
self.con.flush_request.triggered().await;
|
||||
if let Err(e) = self.flush().await {
|
||||
log::error!(
|
||||
"Server {}: Could not process an outgoing message: {}",
|
||||
self.con.server_id,
|
||||
ErrorFmt(e)
|
||||
);
|
||||
self.con.kill();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn flush(&mut self) -> Result<(), UsrConError> {
|
||||
{
|
||||
let mut swapchain = self.con.swapchain.borrow_mut();
|
||||
swapchain.commit();
|
||||
mem::swap(&mut swapchain.pending, &mut self.buffers);
|
||||
}
|
||||
while let Some(mut cur) = self.buffers.pop_front() {
|
||||
if let Err(e) = self.buf.flush_no_timeout(&mut cur).await {
|
||||
return Err(UsrConError::Write(e));
|
||||
}
|
||||
self.con.swapchain.borrow_mut().free.push(cur);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
struct Incoming {
|
||||
con: Rc<UsrCon>,
|
||||
buf: WlBufFdIn,
|
||||
}
|
||||
|
||||
impl Incoming {
|
||||
async fn run(mut self) {
|
||||
loop {
|
||||
if let Err(e) = self.handle_msg().await {
|
||||
log::error!(
|
||||
"Server {}: Could not process an incoming message: {}",
|
||||
self.con.server_id,
|
||||
ErrorFmt(e)
|
||||
);
|
||||
self.con.kill();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_msg(&mut self) -> Result<(), UsrConError> {
|
||||
let WlMessage {
|
||||
obj_id,
|
||||
message,
|
||||
body,
|
||||
fds,
|
||||
} = self.buf.read_message().await.map_err(UsrConError::Read)?;
|
||||
if let Some(obj) = self.con.objects.get(&obj_id) {
|
||||
if let Some(obj) = obj {
|
||||
let parser = MsgParser::new(fds, body);
|
||||
obj.handle_event(&self.con, message, parser)?;
|
||||
}
|
||||
} else if obj_id.raw() < MIN_SERVER_ID {
|
||||
return Err(UsrConError::MissingObject(obj_id));
|
||||
} else {
|
||||
// ignore events for server-created objects that were never added to the state
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
pub mod usr_jay_compositor;
|
||||
pub mod usr_jay_ei_session;
|
||||
pub mod usr_jay_ei_session_builder;
|
||||
pub mod usr_jay_output;
|
||||
pub mod usr_jay_pointer;
|
||||
pub mod usr_jay_render_ctx;
|
||||
pub mod usr_jay_select_toplevel;
|
||||
pub mod usr_jay_select_workspace;
|
||||
pub mod usr_jay_sync_file_release;
|
||||
pub mod usr_jay_sync_file_surface;
|
||||
pub mod usr_jay_toplevel;
|
||||
pub mod usr_jay_workspace;
|
||||
pub mod usr_jay_workspace_watcher;
|
||||
pub mod usr_linux_buffer_params;
|
||||
pub mod usr_linux_dmabuf;
|
||||
pub mod usr_wl_buffer;
|
||||
pub mod usr_wl_callback;
|
||||
pub mod usr_wl_compositor;
|
||||
pub mod usr_wl_data_device;
|
||||
pub mod usr_wl_data_device_manager;
|
||||
pub mod usr_wl_data_offer;
|
||||
pub mod usr_wl_data_source;
|
||||
pub mod usr_wl_display;
|
||||
pub mod usr_wl_keyboard;
|
||||
pub mod usr_wl_output;
|
||||
pub mod usr_wl_pointer;
|
||||
pub mod usr_wl_registry;
|
||||
pub mod usr_wl_seat;
|
||||
pub mod usr_wl_shm;
|
||||
pub mod usr_wl_shm_pool;
|
||||
pub mod usr_wl_surface;
|
||||
pub mod usr_wlr_layer_shell;
|
||||
pub mod usr_wlr_layer_surface;
|
||||
pub mod usr_wp_cursor_shape_device_v1;
|
||||
pub mod usr_wp_cursor_shape_manager_v1;
|
||||
pub mod usr_wp_fractional_scale;
|
||||
pub mod usr_wp_fractional_scale_manager;
|
||||
pub mod usr_wp_viewport;
|
||||
pub mod usr_wp_viewporter;
|
||||
pub mod usr_xdg_surface;
|
||||
pub mod usr_xdg_toplevel;
|
||||
pub mod usr_xdg_wm_base;
|
||||
pub mod usr_zwlr_screencopy_frame;
|
||||
pub mod usr_zwlr_screencopy_manager;
|
||||
pub mod usr_zwp_linux_buffer_params_v1;
|
||||
pub mod usr_zwp_linux_dmabuf_v1;
|
||||
pub mod usr_zwp_primary_selection_device_manager;
|
||||
|
|
@ -1,218 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::jay_compositor::Cap,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JayCompositorId, jay_compositor::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::{
|
||||
usr_jay_ei_session_builder::UsrJayEiSessionBuilder, usr_jay_output::UsrJayOutput,
|
||||
usr_jay_pointer::UsrJayPointer, usr_jay_render_ctx::UsrJayRenderCtx,
|
||||
usr_jay_select_toplevel::UsrJaySelectToplevel,
|
||||
usr_jay_select_workspace::UsrJaySelectWorkspace,
|
||||
usr_jay_workspace_watcher::UsrJayWorkspaceWatcher, usr_wl_output::UsrWlOutput,
|
||||
usr_wl_seat::UsrWlSeat,
|
||||
},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{cell::Cell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayCompositor {
|
||||
pub id: JayCompositorId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayCompositorOwner>>>,
|
||||
pub caps: UsrJayCompositorCaps,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct UsrJayCompositorCaps {
|
||||
pub select_workspace: Cell<bool>,
|
||||
}
|
||||
|
||||
pub trait UsrJayCompositorOwner {
|
||||
fn client_id(&self, ev: ClientId) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn seat(&self, ev: Seat) {
|
||||
let _ = ev;
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrJayCompositor {
|
||||
pub fn get_render_context(&self) -> Rc<UsrJayRenderCtx> {
|
||||
let rc = Rc::new(UsrJayRenderCtx {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
formats: Default::default(),
|
||||
});
|
||||
self.con.request(GetRenderCtx {
|
||||
self_id: self.id,
|
||||
id: rc.id,
|
||||
});
|
||||
self.con.add_object(rc.clone());
|
||||
rc
|
||||
}
|
||||
|
||||
pub fn get_output(&self, output: &UsrWlOutput) -> Rc<UsrJayOutput> {
|
||||
let jo = Rc::new(UsrJayOutput {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(GetOutput {
|
||||
self_id: self.id,
|
||||
id: jo.id,
|
||||
output: output.id,
|
||||
});
|
||||
self.con.add_object(jo.clone());
|
||||
jo
|
||||
}
|
||||
|
||||
pub fn watch_workspaces(&self) -> Rc<UsrJayWorkspaceWatcher> {
|
||||
let ww = Rc::new(UsrJayWorkspaceWatcher {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(WatchWorkspaces {
|
||||
self_id: self.id,
|
||||
id: ww.id,
|
||||
});
|
||||
self.con.add_object(ww.clone());
|
||||
ww
|
||||
}
|
||||
|
||||
pub fn get_pointer(&self, seat: &UsrWlSeat) -> Rc<UsrJayPointer> {
|
||||
let jp = Rc::new(UsrJayPointer {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.add_object(jp.clone());
|
||||
self.con.request(GetPointer {
|
||||
self_id: self.id,
|
||||
id: jp.id,
|
||||
seat: seat.id,
|
||||
});
|
||||
jp
|
||||
}
|
||||
|
||||
pub fn select_toplevel(&self, seat: &UsrWlSeat) -> Rc<UsrJaySelectToplevel> {
|
||||
let sc = Rc::new(UsrJaySelectToplevel {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(SelectToplevel {
|
||||
self_id: self.id,
|
||||
id: sc.id,
|
||||
seat: seat.id,
|
||||
});
|
||||
self.con.add_object(sc.clone());
|
||||
sc
|
||||
}
|
||||
|
||||
pub fn get_toplevel(&self, id: &str) -> Rc<UsrJaySelectToplevel> {
|
||||
let sc = Rc::new(UsrJaySelectToplevel {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(GetToplevel {
|
||||
self_id: self.id,
|
||||
id: sc.id,
|
||||
toplevel_id: id,
|
||||
});
|
||||
self.con.add_object(sc.clone());
|
||||
sc
|
||||
}
|
||||
|
||||
pub fn select_workspace(&self, seat: &UsrWlSeat) -> Rc<UsrJaySelectWorkspace> {
|
||||
let sc = Rc::new(UsrJaySelectWorkspace {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(SelectWorkspace {
|
||||
self_id: self.id,
|
||||
id: sc.id,
|
||||
seat: seat.id,
|
||||
});
|
||||
self.con.add_object(sc.clone());
|
||||
sc
|
||||
}
|
||||
|
||||
pub fn create_ei_session(&self) -> Rc<UsrJayEiSessionBuilder> {
|
||||
let obj = Rc::new(UsrJayEiSessionBuilder {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(CreateEiSession {
|
||||
self_id: self.id,
|
||||
id: obj.id,
|
||||
});
|
||||
self.con.add_object(obj.clone());
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
||||
impl JayCompositorEventHandler for UsrJayCompositor {
|
||||
type Error = Infallible;
|
||||
|
||||
fn client_id(&self, ev: ClientId, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.client_id(ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn seat(&self, ev: Seat<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.seat(ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn capabilities(&self, ev: Capabilities<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
for &cap in ev.cap {
|
||||
match cap {
|
||||
Cap::NONE => {}
|
||||
Cap::SELECT_WORKSPACE => self.caps.select_workspace.set(true),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pid(&self, _ev: Pid, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayCompositor = JayCompositor;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayCompositor {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{
|
||||
JayEiSessionId,
|
||||
jay_ei_session::{Created, Destroyed, Failed, JayEiSessionEventHandler, Release},
|
||||
},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct UsrJayEiSession {
|
||||
pub id: JayEiSessionId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayEiSessionOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrJayEiSessionOwner {
|
||||
fn destroyed(&self) {}
|
||||
|
||||
fn created(&self, fd: &Rc<OwnedFd>) {
|
||||
let _ = fd;
|
||||
}
|
||||
|
||||
fn failed(&self, reason: &str) {
|
||||
let _ = reason;
|
||||
}
|
||||
}
|
||||
|
||||
impl JayEiSessionEventHandler for UsrJayEiSession {
|
||||
type Error = Infallible;
|
||||
|
||||
fn destroyed(&self, _ev: Destroyed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.destroyed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn created(&self, ev: Created, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.created(&ev.fd);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn failed(&self, ev: Failed<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.failed(ev.reason);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayEiSession = JayEiSession;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayEiSession {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Release { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{
|
||||
JayEiSessionBuilderId,
|
||||
jay_ei_session_builder::{Commit, JayEiSessionBuilderEventHandler, SetAppId},
|
||||
},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_jay_ei_session::UsrJayEiSession, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayEiSessionBuilder {
|
||||
pub id: JayEiSessionBuilderId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrJayEiSessionBuilder {
|
||||
pub fn set_app_id(&self, app_id: &str) {
|
||||
self.con.request(SetAppId {
|
||||
self_id: self.id,
|
||||
app_id,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn commit(&self) -> Rc<UsrJayEiSession> {
|
||||
let obj = Rc::new(UsrJayEiSession {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.add_object(obj.clone());
|
||||
self.con.request(Commit {
|
||||
self_id: self.id,
|
||||
id: obj.id,
|
||||
});
|
||||
self.con.remove_obj(self);
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
||||
impl JayEiSessionBuilderEventHandler for UsrJayEiSessionBuilder {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayEiSessionBuilder = JayEiSessionBuilder;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayEiSessionBuilder {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JayOutputId, jay_output::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayOutput {
|
||||
pub id: JayOutputId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayOutputOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrJayOutputOwner {
|
||||
fn linear_id(self: Rc<Self>, ev: &LinearId) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn destroyed(&self) {}
|
||||
}
|
||||
|
||||
impl JayOutputEventHandler for UsrJayOutput {
|
||||
type Error = Infallible;
|
||||
|
||||
fn linear_id(&self, ev: LinearId, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.linear_id(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unused(&self, _ev: Unused, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn destroyed(&self, _ev: Destroyed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.destroyed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayOutput = JayOutput;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayOutput {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.set(None);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
cursor::KnownCursor,
|
||||
object::Version,
|
||||
wire::{JayPointerId, jay_pointer::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayPointer {
|
||||
pub id: JayPointerId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrJayPointer {
|
||||
pub fn set_known_cursor(&self, cursor: KnownCursor) {
|
||||
self.con.request(SetKnownCursor {
|
||||
self_id: self.id,
|
||||
idx: cursor as usize as _,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl JayPointerEventHandler for UsrJayPointer {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayPointer = JayPointer;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayPointer {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
format::formats,
|
||||
gfx_api::{GfxFormat, GfxWriteModifier},
|
||||
ifs::jay_render_ctx::FORMATS_SINCE,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
video::Modifier,
|
||||
wire::{JayRenderCtxId, jay_render_ctx::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
ahash::AHashMap,
|
||||
std::{cell::RefCell, convert::Infallible, rc::Rc},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct UsrJayRenderCtx {
|
||||
pub id: JayRenderCtxId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayRenderCtxOwner>>>,
|
||||
pub version: Version,
|
||||
pub formats: RefCell<AHashMap<u32, GfxFormat>>,
|
||||
}
|
||||
|
||||
pub trait UsrJayRenderCtxOwner {
|
||||
fn no_device(&self) {}
|
||||
fn device(&self, fd: Rc<OwnedFd>, server_formats: Option<AHashMap<u32, GfxFormat>>) {
|
||||
let _ = fd;
|
||||
let _ = server_formats;
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrJayRenderCtx {
|
||||
fn add_write_modifier(&self, format: u32, modifier: Modifier, needs_render_usage: bool) {
|
||||
if let Some(format) = self.formats.borrow_mut().get_mut(&format) {
|
||||
format
|
||||
.write_modifiers
|
||||
.insert(modifier, GfxWriteModifier { needs_render_usage });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl JayRenderCtxEventHandler for UsrJayRenderCtx {
|
||||
type Error = Infallible;
|
||||
|
||||
fn no_device(&self, _ev: NoDevice, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.formats.take();
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.no_device();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn device(&self, ev: Device, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let formats = self.formats.take();
|
||||
let formats = (self.version >= FORMATS_SINCE).then_some(formats);
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.device(ev.fd, formats);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read_modifier(&self, ev: ReadModifier, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(format) = self.formats.borrow_mut().get_mut(&ev.format) {
|
||||
format.read_modifiers.insert(ev.modifier);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_modifier(&self, ev: WriteModifier, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.add_write_modifier(ev.format, ev.modifier, true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn format(&self, ev: Format, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(format) = formats().get(&ev.format) {
|
||||
self.formats.borrow_mut().insert(
|
||||
ev.format,
|
||||
GfxFormat {
|
||||
format,
|
||||
read_modifiers: Default::default(),
|
||||
write_modifiers: Default::default(),
|
||||
supports_shm: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_modifier2(&self, ev: WriteModifier2, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.add_write_modifier(ev.format, ev.modifier, ev.needs_render_usage != 0);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayRenderCtx = JayRenderCtx;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayRenderCtx {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::jay_toplevel::ID_SINCE,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JaySelectToplevelId, jay_select_toplevel::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::usr_jay_toplevel::{UsrJayToplevel, UsrJayToplevelOwner},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJaySelectToplevel {
|
||||
pub id: JaySelectToplevelId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJaySelectToplevelOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrJaySelectToplevel {
|
||||
fn send(&self, tl: Option<Rc<UsrJayToplevel>>) {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.done(tl);
|
||||
} else {
|
||||
if let Some(tl) = tl {
|
||||
self.con.remove_obj(&*tl);
|
||||
}
|
||||
}
|
||||
self.con.remove_obj(self);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait UsrJaySelectToplevelOwner {
|
||||
fn done(&self, toplevel: Option<Rc<UsrJayToplevel>>);
|
||||
}
|
||||
|
||||
impl JaySelectToplevelEventHandler for UsrJaySelectToplevel {
|
||||
type Error = Infallible;
|
||||
|
||||
fn done(&self, ev: Done, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let tl = if ev.id.is_none() {
|
||||
None
|
||||
} else {
|
||||
let tl = Rc::new(UsrJayToplevel {
|
||||
id: ev.id,
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
toplevel_id: Default::default(),
|
||||
});
|
||||
self.con.add_object(tl.clone());
|
||||
Some(tl)
|
||||
};
|
||||
'send: {
|
||||
if self.version >= ID_SINCE
|
||||
&& let Some(tl) = tl
|
||||
{
|
||||
tl.owner.set(Some(slf.clone()));
|
||||
break 'send;
|
||||
}
|
||||
self.send(tl);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrJayToplevelOwner for UsrJaySelectToplevel {
|
||||
fn done(&self, tl: &Rc<UsrJayToplevel>) {
|
||||
tl.owner.take();
|
||||
self.send(Some(tl.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJaySelectToplevel = JaySelectToplevel;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJaySelectToplevel {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
globals::GlobalName,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JaySelectWorkspaceId, jay_select_workspace::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::usr_jay_workspace::{UsrJayWorkspace, UsrJayWorkspaceOwner},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{cell::Cell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJaySelectWorkspace {
|
||||
pub id: JaySelectWorkspaceId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJaySelectWorkspaceOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrJaySelectWorkspaceOwner {
|
||||
fn done(&self, output: GlobalName, ws: Option<Rc<UsrJayWorkspace>>);
|
||||
}
|
||||
|
||||
impl JaySelectWorkspaceEventHandler for UsrJaySelectWorkspace {
|
||||
type Error = Infallible;
|
||||
|
||||
fn cancelled(&self, _ev: Cancelled, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.done(GlobalName::from_raw(0), None);
|
||||
}
|
||||
self.con.remove_obj(self);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn selected(&self, ev: Selected, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let tl = Rc::new(UsrJayWorkspace {
|
||||
id: ev.id,
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
linear_id: Default::default(),
|
||||
output: Cell::new(GlobalName::from_raw(0)),
|
||||
name: Default::default(),
|
||||
});
|
||||
self.con.add_object(tl.clone());
|
||||
tl.owner.set(Some(slf.clone()));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrJayWorkspaceOwner for UsrJaySelectWorkspace {
|
||||
fn done(&self, ws: &Rc<UsrJayWorkspace>) {
|
||||
ws.owner.take();
|
||||
match self.owner.get() {
|
||||
Some(owner) => owner.done(ws.output.get(), Some(ws.clone())),
|
||||
_ => self.con.remove_obj(&**ws),
|
||||
}
|
||||
self.con.remove_obj(self);
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJaySelectWorkspace = JaySelectWorkspace;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJaySelectWorkspace {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
gfx_api::SyncFile,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JaySyncFileReleaseId, jay_sync_file_release::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct UsrJaySyncFileRelease {
|
||||
pub id: JaySyncFileReleaseId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJaySyncFileReleaseOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrJaySyncFileReleaseOwner {
|
||||
fn release(&self, sync_file: Option<SyncFile>);
|
||||
}
|
||||
|
||||
impl UsrJaySyncFileRelease {
|
||||
fn release(&self, sf: Option<Rc<OwnedFd>>) {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.release(sf.map(SyncFile));
|
||||
}
|
||||
self.con.remove_obj(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl JaySyncFileReleaseEventHandler for UsrJaySyncFileRelease {
|
||||
type Error = Infallible;
|
||||
|
||||
fn release_immediate(&self, _ev: ReleaseImmediate, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.release(None);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn release_async(&self, ev: ReleaseAsync, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.release(Some(ev.sync_file));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJaySyncFileRelease = JaySyncFileRelease;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJaySyncFileRelease {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{JaySyncFileSurfaceId, jay_sync_file_surface::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJaySyncFileSurface {
|
||||
pub id: JaySyncFileSurfaceId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl JaySyncFileSurfaceEventHandler for UsrJaySyncFileSurface {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJaySyncFileSurface = JaySyncFileSurface;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJaySyncFileSurface {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JayToplevelId, jay_toplevel::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{cell::RefCell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayToplevel {
|
||||
pub id: JayToplevelId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayToplevelOwner>>>,
|
||||
pub version: Version,
|
||||
pub toplevel_id: RefCell<Option<String>>,
|
||||
}
|
||||
|
||||
pub trait UsrJayToplevelOwner {
|
||||
fn destroyed(&self) {}
|
||||
fn done(&self, tl: &Rc<UsrJayToplevel>);
|
||||
}
|
||||
|
||||
impl JayToplevelEventHandler for UsrJayToplevel {
|
||||
type Error = Infallible;
|
||||
|
||||
fn destroyed(&self, _ev: Destroyed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.destroyed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn id_(&self, ev: Id<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
*self.toplevel_id.borrow_mut() = Some(ev.id.to_string());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn client_id(&self, _ev: ClientId, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn done(&self, _ev: Done, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.done(slf);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayToplevel = JayToplevel;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayToplevel {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.set(None);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
globals::GlobalName,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JayWorkspaceId, jay_workspace::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
convert::Infallible,
|
||||
rc::Rc,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct UsrJayWorkspace {
|
||||
pub id: JayWorkspaceId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayWorkspaceOwner>>>,
|
||||
pub version: Version,
|
||||
pub linear_id: Cell<u32>,
|
||||
pub output: Cell<GlobalName>,
|
||||
pub name: RefCell<Option<String>>,
|
||||
}
|
||||
|
||||
pub trait UsrJayWorkspaceOwner {
|
||||
fn destroyed(&self, ws: &UsrJayWorkspace) {
|
||||
let _ = ws;
|
||||
}
|
||||
|
||||
fn done(&self, ws: &Rc<UsrJayWorkspace>) {
|
||||
let _ = ws;
|
||||
}
|
||||
|
||||
fn output(self: Rc<Self>, ev: &Output) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn visible(&self, visible: bool) {
|
||||
let _ = visible;
|
||||
}
|
||||
}
|
||||
|
||||
impl JayWorkspaceEventHandler for UsrJayWorkspace {
|
||||
type Error = Infallible;
|
||||
|
||||
fn linear_id(&self, ev: LinearId, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.linear_id.set(ev.linear_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn name(&self, ev: Name<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
*self.name.borrow_mut() = Some(ev.name.to_string());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroyed(&self, _ev: Destroyed, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.destroyed(slf);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn done(&self, _ev: Done, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.done(slf);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn output(&self, ev: Output, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.output.set(GlobalName::from_raw(ev.global_name));
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.output(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn visible(&self, ev: Visible, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.visible(ev.visible != 0);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayWorkspace = JayWorkspace;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayWorkspace {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.set(None);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
globals::GlobalName,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{JayWorkspaceWatcherId, jay_workspace_watcher::*},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_jay_workspace::UsrJayWorkspace, usr_object::UsrObject},
|
||||
},
|
||||
std::{cell::Cell, convert::Infallible, ops::Deref, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayWorkspaceWatcher {
|
||||
pub id: JayWorkspaceWatcherId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayWorkspaceWatcherOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrJayWorkspaceWatcherOwner {
|
||||
fn new(self: Rc<Self>, ev: Rc<UsrJayWorkspace>, linear_id: u32) {
|
||||
let _ = linear_id;
|
||||
ev.con.remove_obj(ev.deref());
|
||||
}
|
||||
}
|
||||
|
||||
impl JayWorkspaceWatcherEventHandler for UsrJayWorkspaceWatcher {
|
||||
type Error = Infallible;
|
||||
|
||||
fn new(&self, ev: New, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let jw = Rc::new(UsrJayWorkspace {
|
||||
id: ev.id,
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
linear_id: Default::default(),
|
||||
output: Cell::new(GlobalName::from_raw(0)),
|
||||
name: Default::default(),
|
||||
});
|
||||
self.con.add_object(jw.clone());
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.new(jw, ev.linear_id);
|
||||
} else {
|
||||
self.con.remove_obj(jw.deref());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrJayWorkspaceWatcher = JayWorkspaceWatcher;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayWorkspaceWatcher {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.set(None);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
video::dmabuf::DmaBuf,
|
||||
wire::{ZwpLinuxBufferParamsV1Id, zwp_linux_buffer_params_v1::*},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_wl_buffer::UsrWlBuffer, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, ops::Deref, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrLinuxBufferParams {
|
||||
pub id: ZwpLinuxBufferParamsV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrLinuxBufferParamsOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrLinuxBufferParamsOwner {
|
||||
fn created(&self, buffer: Rc<UsrWlBuffer>) {
|
||||
buffer.con.remove_obj(buffer.deref());
|
||||
}
|
||||
|
||||
fn failed(&self) {}
|
||||
}
|
||||
|
||||
impl UsrLinuxBufferParams {
|
||||
pub fn create(&self, buf: &DmaBuf) {
|
||||
for (idx, plane) in buf.planes.iter().enumerate() {
|
||||
self.con.request(Add {
|
||||
self_id: self.id,
|
||||
fd: plane.fd.clone(),
|
||||
plane_idx: idx as _,
|
||||
offset: plane.offset,
|
||||
stride: plane.stride,
|
||||
modifier: buf.modifier,
|
||||
});
|
||||
}
|
||||
self.con.request(Create {
|
||||
self_id: self.id,
|
||||
width: buf.width,
|
||||
height: buf.height,
|
||||
format: buf.format.drm,
|
||||
flags: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwpLinuxBufferParamsV1EventHandler for UsrLinuxBufferParams {
|
||||
type Error = Infallible;
|
||||
|
||||
fn created(&self, ev: Created, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let buffer = Rc::new(UsrWlBuffer {
|
||||
id: ev.buffer,
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.add_object(buffer.clone());
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.created(buffer);
|
||||
} else {
|
||||
self.con.remove_obj(buffer.deref());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn failed(&self, _ev: Failed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.failed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrLinuxBufferParams = ZwpLinuxBufferParamsV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrLinuxBufferParams {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
format::{Format, formats},
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{
|
||||
ZwpLinuxDmabufV1Id,
|
||||
zwp_linux_dmabuf_v1::{self, *},
|
||||
},
|
||||
wl_usr::{
|
||||
UsrCon, usr_ifs::usr_linux_buffer_params::UsrLinuxBufferParams, usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrLinuxDmabuf {
|
||||
pub id: ZwpLinuxDmabufV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrLinuxDmabufOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrLinuxDmabufOwner {
|
||||
fn modifier(&self, format: &'static Format, modifier: u64) {
|
||||
let _ = format;
|
||||
let _ = modifier;
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrLinuxDmabuf {
|
||||
pub fn create_params(&self) -> Rc<UsrLinuxBufferParams> {
|
||||
let params = Rc::new(UsrLinuxBufferParams {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(CreateParams {
|
||||
self_id: self.id,
|
||||
params_id: params.id,
|
||||
});
|
||||
self.con.add_object(params.clone());
|
||||
params
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwpLinuxDmabufV1EventHandler for UsrLinuxDmabuf {
|
||||
type Error = Infallible;
|
||||
|
||||
fn format(&self, _ev: zwp_linux_dmabuf_v1::Format, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn modifier(&self, ev: Modifier, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get()
|
||||
&& let Some(format) = formats().get(&ev.format)
|
||||
{
|
||||
owner.modifier(format, ev.modifier);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrLinuxDmabuf = ZwpLinuxDmabufV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrLinuxDmabuf {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WlBufferId, wl_buffer::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlBuffer {
|
||||
pub id: WlBufferId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlBufferOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWlBufferOwner {
|
||||
fn release(&self) {}
|
||||
}
|
||||
|
||||
impl WlBufferEventHandler for UsrWlBuffer {
|
||||
type Error = Infallible;
|
||||
|
||||
fn release(&self, _ev: Release, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.release();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlBuffer = WlBuffer;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlBuffer {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WlCallbackId, wl_callback::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{cell::Cell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlCallback {
|
||||
pub id: WlCallbackId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: Cell<Option<Rc<dyn UsrWlCallbackOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWlCallbackOwner {
|
||||
fn done(self: Rc<Self>);
|
||||
}
|
||||
|
||||
impl<T> UsrWlCallbackOwner for Cell<Option<T>>
|
||||
where
|
||||
T: FnOnce() + 'static,
|
||||
{
|
||||
fn done(self: Rc<Self>) {
|
||||
if let Some(slf) = self.take() {
|
||||
slf();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrWlCallback {
|
||||
pub fn new(con: &Rc<UsrCon>) -> Self {
|
||||
Self {
|
||||
id: con.id(),
|
||||
con: con.clone(),
|
||||
owner: Default::default(),
|
||||
version: Version(1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WlCallbackEventHandler for UsrWlCallback {
|
||||
type Error = Infallible;
|
||||
|
||||
fn done(&self, _ev: Done, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(handler) = self.owner.take() {
|
||||
handler.done();
|
||||
}
|
||||
self.con.remove_obj(self);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlCallback = WlCallback;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlCallback {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{
|
||||
WlCompositorId,
|
||||
wl_compositor::{CreateSurface, WlCompositorEventHandler},
|
||||
},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_wl_surface::UsrWlSurface, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlCompositor {
|
||||
pub id: WlCompositorId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWlCompositor {
|
||||
pub fn create_surface(&self) -> Rc<UsrWlSurface> {
|
||||
let sfc = Rc::new(UsrWlSurface {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(CreateSurface {
|
||||
self_id: self.id,
|
||||
id: sfc.id,
|
||||
});
|
||||
self.con.add_object(sfc.clone());
|
||||
sfc
|
||||
}
|
||||
}
|
||||
|
||||
impl WlCompositorEventHandler for UsrWlCompositor {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlCompositor = WlCompositor;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlCompositor {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WlDataDeviceId, wl_data_device::*},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_wl_data_offer::UsrWlDataOffer, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlDataDevice {
|
||||
pub id: WlDataDeviceId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
pub offer: CloneCell<Option<Rc<UsrWlDataOffer>>>,
|
||||
pub selection: CloneCell<Option<Rc<UsrWlDataOffer>>>,
|
||||
}
|
||||
|
||||
impl WlDataDeviceEventHandler for UsrWlDataDevice {
|
||||
type Error = Infallible;
|
||||
|
||||
fn data_offer(&self, ev: DataOffer, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let obj = Rc::new(UsrWlDataOffer {
|
||||
id: ev.id,
|
||||
con: self.con.clone(),
|
||||
version: self.version,
|
||||
mime_types: Default::default(),
|
||||
});
|
||||
self.con.add_object(obj.clone());
|
||||
if let Some(offer) = self.offer.set(Some(obj)) {
|
||||
self.con.remove_obj(&*offer);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn enter(&self, ev: Enter, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn leave(&self, ev: Leave, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn motion(&self, ev: Motion, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn drop_(&self, ev: Drop, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn selection(&self, ev: Selection, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.selection.take();
|
||||
if let Some(offer) = self.offer.get()
|
||||
&& offer.id == ev.id
|
||||
{
|
||||
self.selection.set(Some(offer));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlDataDevice = WlDataDevice;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlDataDevice {
|
||||
fn destroy(&self) {
|
||||
if let Some(offer) = self.offer.take() {
|
||||
self.con.remove_obj(&*offer);
|
||||
}
|
||||
self.con.request(Release { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.selection.take();
|
||||
self.offer.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WlDataDeviceManagerId, wl_data_device_manager::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlDataDeviceManager {
|
||||
pub id: WlDataDeviceManagerId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WlDataDeviceManagerEventHandler for UsrWlDataDeviceManager {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlDataDeviceManager = WlDataDeviceManager;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlDataDeviceManager {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Release { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WlDataOfferId, wl_data_offer::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
ahash::AHashSet,
|
||||
std::{cell::RefCell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlDataOffer {
|
||||
pub id: WlDataOfferId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
pub mime_types: RefCell<AHashSet<String>>,
|
||||
}
|
||||
|
||||
impl WlDataOfferEventHandler for UsrWlDataOffer {
|
||||
type Error = Infallible;
|
||||
|
||||
fn offer(&self, ev: Offer<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.mime_types
|
||||
.borrow_mut()
|
||||
.insert(ev.mime_type.to_string());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn source_actions(&self, _ev: SourceActions, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn action(&self, _ev: Action, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlDataOffer = WlDataOffer;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlDataOffer {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WlDataSourceId, wl_data_source::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct UsrWlDataSource {
|
||||
pub id: WlDataSourceId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlDataSourceOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWlDataSourceOwner {
|
||||
fn send(&self, mime_type: &str, fd: Rc<OwnedFd>);
|
||||
}
|
||||
|
||||
impl WlDataSourceEventHandler for UsrWlDataSource {
|
||||
type Error = Infallible;
|
||||
|
||||
fn target(&self, ev: Target<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn send(&self, ev: Send<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.send(ev.mime_type, ev.fd);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cancelled(&self, ev: Cancelled, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn dnd_drop_performed(&self, ev: DndDropPerformed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn dnd_finished(&self, ev: DndFinished, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn action(&self, ev: Action, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = ev;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlDataSource = WlDataSource;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlDataSource {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WlDisplayId, wl_display::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub struct UsrWlDisplay {
|
||||
pub id: WlDisplayId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WlDisplayEventHandler for UsrWlDisplay {
|
||||
type Error = UsrWlDisplayError;
|
||||
|
||||
fn error(&self, ev: Error<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Err(UsrWlDisplayError::ServerError(ev.message.to_owned()))
|
||||
}
|
||||
|
||||
fn delete_id(&self, ev: DeleteId, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.con.release_id(ev.id);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum UsrWlDisplayError {
|
||||
#[error("The server emitted an error: {0}")]
|
||||
ServerError(String),
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlDisplay = WlDisplay;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlDisplay {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::wl_seat::wl_keyboard,
|
||||
object::Version,
|
||||
utils::{clonecell::CloneCell, mmap::mmap, oserror::OsError},
|
||||
wire::{WlKeyboardId, WlSurfaceId, wl_keyboard::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
kbvm::{
|
||||
Components, Keycode, ModifierMask,
|
||||
lookup::{Lookup, LookupTable},
|
||||
xkb::{
|
||||
Context,
|
||||
diagnostic::{Diagnostic, WriteToLog},
|
||||
},
|
||||
},
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
thiserror::Error,
|
||||
uapi::c,
|
||||
};
|
||||
|
||||
pub struct UsrWlKeyboard {
|
||||
pub id: WlKeyboardId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub keyboard: RefCell<Option<Keyboard>>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlKeyboardOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub struct Keyboard {
|
||||
lookup: LookupTable,
|
||||
components: Components,
|
||||
}
|
||||
|
||||
pub trait UsrWlKeyboardOwner {
|
||||
fn focus(self: Rc<Self>, surface: WlSurfaceId, serial: u32);
|
||||
fn unfocus(self: Rc<Self>);
|
||||
fn modifiers(self: Rc<Self>, mods: ModifierMask);
|
||||
fn down(self: Rc<Self>, lookup: Lookup<'_>, serial: u32);
|
||||
fn repeat(self: Rc<Self>, lookup: Lookup<'_>, serial: u32);
|
||||
fn up(self: Rc<Self>, lookup: Lookup<'_>, serial: u32);
|
||||
}
|
||||
|
||||
impl WlKeyboardEventHandler for UsrWlKeyboard {
|
||||
type Error = UsrWlKeyboardError;
|
||||
|
||||
fn keymap(&self, ev: Keymap, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let map = mmap(ev.size as _, c::PROT_READ, c::MAP_PRIVATE, ev.fd.raw(), 0)
|
||||
.map_err(UsrWlKeyboardError::MapKeymap)?;
|
||||
let mut builder = Context::builder();
|
||||
builder.enable_default_includes(false);
|
||||
builder.enable_environment(false);
|
||||
let keymap = builder
|
||||
.build()
|
||||
.keymap_from_bytes(WriteToLog, None, unsafe { &*map.ptr })
|
||||
.map_err(UsrWlKeyboardError::ParseKeymap)?;
|
||||
let lookup = keymap.to_builder().build_lookup_table();
|
||||
let keyboard = Keyboard {
|
||||
lookup,
|
||||
components: Default::default(),
|
||||
};
|
||||
self.keyboard.replace(Some(keyboard));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn enter(&self, ev: Enter<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let Some(owner) = self.owner.get() else {
|
||||
return Ok(());
|
||||
};
|
||||
owner.focus(ev.surface, ev.serial);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn leave(&self, _ev: Leave, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let Some(owner) = self.owner.get() else {
|
||||
return Ok(());
|
||||
};
|
||||
owner.unfocus();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn key(&self, ev: Key, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let Some(kb) = &*self.keyboard.borrow() else {
|
||||
return Ok(());
|
||||
};
|
||||
let Some(owner) = self.owner.get() else {
|
||||
return Ok(());
|
||||
};
|
||||
let kc = Keycode::from_evdev(ev.key);
|
||||
let lookup = kb
|
||||
.lookup
|
||||
.lookup(kb.components.group, kb.components.mods, kc);
|
||||
if ev.state == wl_keyboard::PRESSED {
|
||||
owner.down(lookup, ev.serial);
|
||||
} else if ev.state == wl_keyboard::REPEATED {
|
||||
owner.repeat(lookup, ev.serial);
|
||||
} else if ev.state == wl_keyboard::RELEASED {
|
||||
owner.up(lookup, ev.serial);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn modifiers(&self, ev: Modifiers, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let Some(kb) = &mut *self.keyboard.borrow_mut() else {
|
||||
return Ok(());
|
||||
};
|
||||
kb.components.mods_pressed.0 = ev.mods_depressed;
|
||||
kb.components.mods_latched.0 = ev.mods_latched;
|
||||
kb.components.mods_locked.0 = ev.mods_locked;
|
||||
kb.components.group_locked.0 = ev.group;
|
||||
let old = kb.components.mods;
|
||||
kb.components.update_effective();
|
||||
let new = kb.components.mods;
|
||||
if old != new
|
||||
&& let Some(owner) = self.owner.get()
|
||||
{
|
||||
owner.modifiers(new);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn repeat_info(&self, _ev: RepeatInfo, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlKeyboard = WlKeyboard;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlKeyboard {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Release { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UsrWlKeyboardError {
|
||||
#[error("Could not map the keymap")]
|
||||
MapKeymap(#[source] OsError),
|
||||
#[error("Could not parse the keymap")]
|
||||
ParseKeymap(#[source] Diagnostic),
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WlOutputId, wl_output::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{cell::RefCell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlOutput {
|
||||
pub id: WlOutputId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlOutputOwner>>>,
|
||||
pub version: Version,
|
||||
pub name: RefCell<Option<String>>,
|
||||
}
|
||||
|
||||
pub trait UsrWlOutputOwner {
|
||||
fn geometry(&self, ev: &Geometry) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn mode(&self, ev: &Mode) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn done(&self) {}
|
||||
|
||||
fn scale(&self, ev: &Scale) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn name(&self, ev: &Name) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn description(&self, ev: &Description) {
|
||||
let _ = ev;
|
||||
}
|
||||
}
|
||||
|
||||
impl WlOutputEventHandler for UsrWlOutput {
|
||||
type Error = Infallible;
|
||||
|
||||
fn geometry(&self, ev: Geometry<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.geometry(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mode(&self, ev: Mode, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.mode(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn done(&self, _ev: Done, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.done();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn scale(&self, ev: Scale, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.scale(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn name(&self, ev: Name<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
*self.name.borrow_mut() = Some(ev.name.to_string());
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.name(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn description(&self, ev: Description<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.description(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlOutput = WlOutput;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlOutput {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Release { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.set(None);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::wl_seat::wl_pointer::PendingScroll,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WlPointerId, wl_pointer::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{cell::Cell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlPointer {
|
||||
pub id: WlPointerId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlPointerOwner>>>,
|
||||
pub any_scroll_events: Cell<bool>,
|
||||
pub pending_scroll: PendingScroll,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWlPointerOwner {
|
||||
fn enter(self: Rc<Self>, ev: &Enter) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn leave(self: Rc<Self>, ev: &Leave) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn motion(self: Rc<Self>, ev: &Motion) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, ev: &Button) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn scroll(self: Rc<Self>, ps: &PendingScroll) {
|
||||
let _ = ps;
|
||||
}
|
||||
}
|
||||
|
||||
impl WlPointerEventHandler for UsrWlPointer {
|
||||
type Error = Infallible;
|
||||
|
||||
fn enter(&self, ev: Enter, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.enter(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn leave(&self, ev: Leave, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.leave(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn motion(&self, ev: Motion, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.motion(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn button(&self, ev: Button, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.button(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn axis(&self, ev: Axis, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.pending_scroll.time_usec.set(ev.time as u64 * 1000);
|
||||
if ev.axis < 2 {
|
||||
self.pending_scroll.px[ev.axis as usize].set(Some(ev.value));
|
||||
}
|
||||
self.any_scroll_events.set(true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn frame(&self, _ev: Frame, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.any_scroll_events.take() {
|
||||
let pe = self.pending_scroll.take();
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.scroll(&pe);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn axis_source(&self, ev: AxisSource, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.pending_scroll.source.set(Some(ev.axis_source));
|
||||
self.any_scroll_events.set(true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn axis_stop(&self, ev: AxisStop, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.pending_scroll.time_usec.set(ev.time as u64 * 1000);
|
||||
if ev.axis < 2 {
|
||||
self.pending_scroll.stop[ev.axis as usize].set(true);
|
||||
}
|
||||
self.any_scroll_events.set(true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn axis_discrete(&self, _ev: AxisDiscrete, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.any_scroll_events.set(true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn axis_value120(&self, ev: AxisValue120, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if ev.axis < 2 {
|
||||
self.pending_scroll.v120[ev.axis as usize].set(Some(ev.value120));
|
||||
}
|
||||
self.any_scroll_events.set(true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn axis_relative_direction(
|
||||
&self,
|
||||
_ev: AxisRelativeDirection,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlPointer = WlPointer;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlPointer {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Release { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
globals::GlobalName,
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WlRegistryId, wl_registry::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlRegistry {
|
||||
pub id: WlRegistryId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlRegistryOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWlRegistryOwner {
|
||||
fn global(self: Rc<Self>, name: GlobalName, interface: &str, version: u32) {
|
||||
let _ = name;
|
||||
let _ = interface;
|
||||
let _ = version;
|
||||
}
|
||||
|
||||
fn global_remove(&self, name: GlobalName) {
|
||||
let _ = name;
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrWlRegistry {
|
||||
pub fn bind(&self, name: GlobalName, obj: &dyn UsrObject) {
|
||||
self.con.request(Bind {
|
||||
self_id: self.id,
|
||||
name: name.raw(),
|
||||
interface: obj.interface().name(),
|
||||
version: obj.version().0,
|
||||
id: obj.id(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl WlRegistryEventHandler for UsrWlRegistry {
|
||||
type Error = Infallible;
|
||||
|
||||
fn global(&self, ev: Global<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.global(GlobalName::from_raw(ev.name), ev.interface, ev.version);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn global_remove(&self, ev: GlobalRemove, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.global_remove(GlobalName::from_raw(ev.name));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlRegistry = WlRegistry;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlRegistry {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.set(None);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WlSeatId, wl_seat::*},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_wl_pointer::UsrWlPointer, usr_object::UsrObject},
|
||||
},
|
||||
std::{cell::Cell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlSeat {
|
||||
pub id: WlSeatId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlSeatOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWlSeatOwner {
|
||||
fn capabilities(self: Rc<Self>, value: u32) {
|
||||
let _ = value;
|
||||
}
|
||||
|
||||
fn name(&self, name: &str) {
|
||||
let _ = name;
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrWlSeat {
|
||||
pub fn get_pointer(&self) -> Rc<UsrWlPointer> {
|
||||
let ptr = Rc::new(UsrWlPointer {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
any_scroll_events: Cell::new(false),
|
||||
pending_scroll: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.add_object(ptr.clone());
|
||||
self.con.request(GetPointer {
|
||||
self_id: self.id,
|
||||
id: ptr.id,
|
||||
});
|
||||
ptr
|
||||
}
|
||||
}
|
||||
|
||||
impl WlSeatEventHandler for UsrWlSeat {
|
||||
type Error = Infallible;
|
||||
|
||||
fn capabilities(&self, ev: Capabilities, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.capabilities(ev.capabilities);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn name(&self, ev: Name<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.name(ev.name);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlSeat = WlSeat;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlSeat {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Release { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
format::{formats, map_wayland_format_id},
|
||||
object::Version,
|
||||
utils::copyhashmap::CopyHashMap,
|
||||
wire::{WlShmId, wl_shm::*},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_wl_shm_pool::UsrWlShmPool, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct UsrWlShm {
|
||||
pub id: WlShmId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub formats: CopyHashMap<u32, &'static crate::format::Format>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWlShm {
|
||||
#[expect(dead_code)]
|
||||
pub fn create_pool(&self, fd: &Rc<OwnedFd>, size: i32) -> Rc<UsrWlShmPool> {
|
||||
let pool = Rc::new(UsrWlShmPool {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(CreatePool {
|
||||
self_id: self.id,
|
||||
id: pool.id,
|
||||
fd: fd.clone(),
|
||||
size,
|
||||
});
|
||||
self.con.add_object(pool.clone());
|
||||
pool
|
||||
}
|
||||
}
|
||||
|
||||
impl WlShmEventHandler for UsrWlShm {
|
||||
type Error = Infallible;
|
||||
|
||||
fn format(&self, ev: Format, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let format = map_wayland_format_id(ev.format);
|
||||
if let Some(format) = formats().get(&format) {
|
||||
self.formats.set(format.drm, *format);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlShm = WlShm;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlShm {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WlShmPoolId, wl_shm_pool::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlShmPool {
|
||||
pub id: WlShmPoolId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWlShmPool {
|
||||
#[expect(dead_code)]
|
||||
pub fn resize(&self, size: i32) {
|
||||
self.con.request(Resize {
|
||||
self_id: self.id,
|
||||
size,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl WlShmPoolEventHandler for UsrWlShmPool {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlShmPool = WlShmPool;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlShmPool {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WlSurfaceId, wl_surface::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::{usr_wl_buffer::UsrWlBuffer, usr_wl_callback::UsrWlCallback},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlSurface {
|
||||
pub id: WlSurfaceId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWlSurface {
|
||||
pub fn attach(&self, buffer: &UsrWlBuffer) {
|
||||
self.con.request(Attach {
|
||||
self_id: self.id,
|
||||
buffer: buffer.id,
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn damage(&self) {
|
||||
self.con.request(DamageBuffer {
|
||||
self_id: self.id,
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: i32::MAX,
|
||||
height: i32::MAX,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn frame(&self) -> Rc<UsrWlCallback> {
|
||||
let cb = Rc::new(UsrWlCallback::new(&self.con));
|
||||
self.con.request(Frame {
|
||||
self_id: self.id,
|
||||
callback: cb.id,
|
||||
});
|
||||
self.con.add_object(cb.clone());
|
||||
cb
|
||||
}
|
||||
|
||||
pub fn commit(&self) {
|
||||
self.con.request(Commit { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
||||
impl WlSurfaceEventHandler for UsrWlSurface {
|
||||
type Error = Infallible;
|
||||
|
||||
fn enter(&self, _ev: Enter, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn leave(&self, _ev: Leave, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn preferred_buffer_scale(
|
||||
&self,
|
||||
_ev: PreferredBufferScale,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn preferred_buffer_transform(
|
||||
&self,
|
||||
_ev: PreferredBufferTransform,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlSurface = WlSurface;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlSurface {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{ZwlrLayerShellV1Id, zwlr_layer_shell_v1::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::{
|
||||
usr_wl_output::UsrWlOutput, usr_wl_surface::UsrWlSurface,
|
||||
usr_wlr_layer_surface::UsrWlrLayerSurface,
|
||||
},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlrLayerShell {
|
||||
pub id: ZwlrLayerShellV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWlrLayerShell {
|
||||
pub fn get_layer_surface(
|
||||
&self,
|
||||
surface: &UsrWlSurface,
|
||||
output: &UsrWlOutput,
|
||||
layer: u32,
|
||||
) -> Rc<UsrWlrLayerSurface> {
|
||||
let sfc = Rc::new(UsrWlrLayerSurface {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.add_object(sfc.clone());
|
||||
self.con.request(GetLayerSurface {
|
||||
self_id: self.id,
|
||||
id: sfc.id,
|
||||
surface: surface.id,
|
||||
output: output.id,
|
||||
layer,
|
||||
namespace: "",
|
||||
});
|
||||
sfc
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwlrLayerShellV1EventHandler for UsrWlrLayerShell {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlrLayerShell = ZwlrLayerShellV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlrLayerShell {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{ZwlrLayerSurfaceV1Id, zwlr_layer_surface_v1::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWlrLayerSurface {
|
||||
pub id: ZwlrLayerSurfaceV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlrLayerSurfaceOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWlrLayerSurfaceOwner {
|
||||
fn configure(&self, ev: &Configure) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn closed(&self) {}
|
||||
}
|
||||
|
||||
impl UsrWlrLayerSurface {
|
||||
pub fn set_size(&self, width: i32, height: i32) {
|
||||
self.con.request(SetSize {
|
||||
self_id: self.id,
|
||||
width: width as _,
|
||||
height: height as _,
|
||||
});
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub fn set_keyboard_interactivity(&self, ki: u32) {
|
||||
self.con.request(SetKeyboardInteractivity {
|
||||
self_id: self.id,
|
||||
keyboard_interactivity: ki,
|
||||
});
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub fn set_layer(&self, layer: u32) {
|
||||
self.con.request(SetLayer {
|
||||
self_id: self.id,
|
||||
layer,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwlrLayerSurfaceV1EventHandler for UsrWlrLayerSurface {
|
||||
type Error = Infallible;
|
||||
|
||||
fn configure(&self, ev: Configure, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.configure(&ev);
|
||||
}
|
||||
self.con.request(AckConfigure {
|
||||
self_id: self.id,
|
||||
serial: ev.serial,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn closed(&self, _ev: Closed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.closed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWlrLayerSurface = ZwlrLayerSurfaceV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlrLayerSurface {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WpCursorShapeDeviceV1Id, wp_cursor_shape_device_v1::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWpCursorShapeDeviceV1 {
|
||||
pub id: WpCursorShapeDeviceV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WpCursorShapeDeviceV1EventHandler for UsrWpCursorShapeDeviceV1 {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWpCursorShapeDeviceV1 = WpCursorShapeDeviceV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWpCursorShapeDeviceV1 {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WpCursorShapeManagerV1Id, wp_cursor_shape_manager_v1::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWpCursorShapeManagerV1 {
|
||||
pub id: WpCursorShapeManagerV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WpCursorShapeManagerV1EventHandler for UsrWpCursorShapeManagerV1 {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWpCursorShapeManagerV1 = WpCursorShapeManagerV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWpCursorShapeManagerV1 {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{WpFractionalScaleV1Id, wp_fractional_scale_v1::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWpFractionalScale {
|
||||
pub id: WpFractionalScaleV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWpFractionalScaleOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrWpFractionalScaleOwner {
|
||||
fn preferred_scale(self: Rc<Self>, ev: &PreferredScale) {
|
||||
let _ = ev;
|
||||
}
|
||||
}
|
||||
|
||||
impl WpFractionalScaleV1EventHandler for UsrWpFractionalScale {
|
||||
type Error = Infallible;
|
||||
|
||||
fn preferred_scale(&self, ev: PreferredScale, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.preferred_scale(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWpFractionalScale = WpFractionalScaleV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWpFractionalScale {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WpFractionalScaleManagerV1Id, wp_fractional_scale_manager_v1::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::{
|
||||
usr_wl_surface::UsrWlSurface, usr_wp_fractional_scale::UsrWpFractionalScale,
|
||||
},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWpFractionalScaleManager {
|
||||
pub id: WpFractionalScaleManagerV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWpFractionalScaleManager {
|
||||
pub fn get_fractional_scale(&self, surface: &UsrWlSurface) -> Rc<UsrWpFractionalScale> {
|
||||
let fs = Rc::new(UsrWpFractionalScale {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.add_object(fs.clone());
|
||||
self.con.request(GetFractionalScale {
|
||||
self_id: self.id,
|
||||
id: fs.id,
|
||||
surface: surface.id,
|
||||
});
|
||||
fs
|
||||
}
|
||||
}
|
||||
|
||||
impl WpFractionalScaleManagerV1EventHandler for UsrWpFractionalScaleManager {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWpFractionalScaleManager = WpFractionalScaleManagerV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWpFractionalScaleManager {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
fixed::Fixed,
|
||||
object::Version,
|
||||
wire::{WpViewportId, wp_viewport::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWpViewport {
|
||||
pub id: WpViewportId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWpViewport {
|
||||
#[expect(dead_code)]
|
||||
pub fn set_source(&self, x: Fixed, y: Fixed, width: Fixed, height: Fixed) {
|
||||
self.con.request(SetSource {
|
||||
self_id: self.id,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn set_destination(&self, width: i32, height: i32) {
|
||||
self.con.request(SetDestination {
|
||||
self_id: self.id,
|
||||
width,
|
||||
height,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl WpViewportEventHandler for UsrWpViewport {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWpViewport = WpViewport;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWpViewport {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{WpViewporterId, wp_viewporter::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::{usr_wl_surface::UsrWlSurface, usr_wp_viewport::UsrWpViewport},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrWpViewporter {
|
||||
pub id: WpViewporterId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrWpViewporter {
|
||||
pub fn get_viewport(&self, surface: &UsrWlSurface) -> Rc<UsrWpViewport> {
|
||||
let wv = Rc::new(UsrWpViewport {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.add_object(wv.clone());
|
||||
self.con.request(GetViewport {
|
||||
self_id: self.id,
|
||||
id: wv.id,
|
||||
surface: surface.id,
|
||||
});
|
||||
wv
|
||||
}
|
||||
}
|
||||
|
||||
impl WpViewporterEventHandler for UsrWpViewporter {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrWpViewporter = WpViewporter;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWpViewporter {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{XdgSurfaceId, xdg_surface::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrXdgSurface {
|
||||
pub id: XdgSurfaceId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrXdgSurfaceOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrXdgSurfaceOwner {
|
||||
fn configure(&self) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgSurfaceEventHandler for UsrXdgSurface {
|
||||
type Error = Infallible;
|
||||
|
||||
fn configure(&self, ev: Configure, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.con.request(AckConfigure {
|
||||
self_id: self.id,
|
||||
serial: ev.serial,
|
||||
});
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.configure();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrXdgSurface = XdgSurface;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrXdgSurface {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{XdgToplevelId, xdg_toplevel::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrXdgToplevel {
|
||||
pub id: XdgToplevelId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrXdgToplevelOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrXdgToplevelOwner {
|
||||
fn configure(&self, width: i32, height: i32) {
|
||||
let _ = width;
|
||||
let _ = height;
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgToplevelEventHandler for UsrXdgToplevel {
|
||||
type Error = Infallible;
|
||||
|
||||
fn configure(&self, ev: Configure<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.configure(ev.width, ev.height);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn close(&self, _ev: Close, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.close();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn configure_bounds(&self, _ev: ConfigureBounds, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn wm_capabilities(&self, _ev: WmCapabilities<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrXdgToplevel = XdgToplevel;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrXdgToplevel {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{XdgWmBaseId, xdg_wm_base::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrXdgWmBase {
|
||||
pub id: XdgWmBaseId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl XdgWmBaseEventHandler for UsrXdgWmBase {
|
||||
type Error = Infallible;
|
||||
|
||||
fn ping(&self, ev: Ping, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.con.request(Pong {
|
||||
self_id: self.id,
|
||||
serial: ev.serial,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrXdgWmBase = XdgWmBase;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrXdgWmBase {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{ZwlrScreencopyFrameV1Id, zwlr_screencopy_frame_v1::*},
|
||||
wl_usr::{UsrCon, usr_ifs::usr_wl_buffer::UsrWlBuffer, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrZwlrScreencopyFrame {
|
||||
pub id: ZwlrScreencopyFrameV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrZwlrScreencopyFrameOwner>>>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
pub trait UsrZwlrScreencopyFrameOwner {
|
||||
fn buffer(&self, buffer: &Buffer) {
|
||||
let _ = buffer;
|
||||
}
|
||||
|
||||
fn flags(&self, flags: &Flags) {
|
||||
let _ = flags;
|
||||
}
|
||||
|
||||
fn ready(&self, ready: &Ready) {
|
||||
let _ = ready;
|
||||
}
|
||||
|
||||
fn failed(&self) {}
|
||||
|
||||
fn damage(&self, damage: &Damage) {
|
||||
let _ = damage;
|
||||
}
|
||||
|
||||
fn linux_dmabuf(&self, dmabuf: &LinuxDmabuf) {
|
||||
let _ = dmabuf;
|
||||
}
|
||||
|
||||
fn buffer_done(&self) {}
|
||||
}
|
||||
|
||||
impl UsrZwlrScreencopyFrame {
|
||||
#[expect(dead_code)]
|
||||
pub fn copy(&self, buffer: &UsrWlBuffer) {
|
||||
self.con.request(Copy {
|
||||
self_id: self.id,
|
||||
buffer: buffer.id,
|
||||
});
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub fn copy_with_damage(&self, buffer: &UsrWlBuffer) {
|
||||
self.con.request(CopyWithDamage {
|
||||
self_id: self.id,
|
||||
buffer: buffer.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwlrScreencopyFrameV1EventHandler for UsrZwlrScreencopyFrame {
|
||||
type Error = Infallible;
|
||||
|
||||
fn buffer(&self, ev: Buffer, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.buffer(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn flags(&self, ev: Flags, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.flags(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ready(&self, ev: Ready, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.ready(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn failed(&self, _ev: Failed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.failed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn damage(&self, ev: Damage, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.damage(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn linux_dmabuf(&self, ev: LinuxDmabuf, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.linux_dmabuf(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn buffer_done(&self, _ev: BufferDone, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.buffer_done();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrZwlrScreencopyFrame = ZwlrScreencopyFrameV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrZwlrScreencopyFrame {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{ZwlrScreencopyManagerV1Id, zwlr_screencopy_manager_v1::*},
|
||||
wl_usr::{
|
||||
UsrCon,
|
||||
usr_ifs::{
|
||||
usr_wl_output::UsrWlOutput, usr_zwlr_screencopy_frame::UsrZwlrScreencopyFrame,
|
||||
},
|
||||
usr_object::UsrObject,
|
||||
},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrZwlrScreencopyManager {
|
||||
pub id: ZwlrScreencopyManagerV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrZwlrScreencopyManager {
|
||||
#[expect(dead_code)]
|
||||
pub fn capture_output(&self, output: &UsrWlOutput) -> Rc<UsrZwlrScreencopyFrame> {
|
||||
let frame = Rc::new(UsrZwlrScreencopyFrame {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
self.con.request(CaptureOutput {
|
||||
self_id: self.id,
|
||||
frame: frame.id,
|
||||
overlay_cursor: 0,
|
||||
output: output.id,
|
||||
});
|
||||
self.con.add_object(frame.clone());
|
||||
frame
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwlrScreencopyManagerV1EventHandler for UsrZwlrScreencopyManager {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrZwlrScreencopyManager = ZwlrScreencopyManagerV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrZwlrScreencopyManager {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{ZwpLinuxBufferParamsV1Id, zwp_linux_buffer_params_v1::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrZwpLinuxBufferParamsV1 {
|
||||
pub id: ZwpLinuxBufferParamsV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl ZwpLinuxBufferParamsV1EventHandler for UsrZwpLinuxBufferParamsV1 {
|
||||
type Error = Infallible;
|
||||
|
||||
fn created(&self, _ev: Created, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn failed(&self, _ev: Failed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrZwpLinuxBufferParamsV1 = ZwpLinuxBufferParamsV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrZwpLinuxBufferParamsV1 {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{ZwpLinuxDmabufV1Id, zwp_linux_dmabuf_v1::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrZwpLinuxDmabufV1 {
|
||||
pub id: ZwpLinuxDmabufV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl ZwpLinuxDmabufV1EventHandler for UsrZwpLinuxDmabufV1 {
|
||||
type Error = Infallible;
|
||||
|
||||
fn format(&self, _ev: Format, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn modifier(&self, _ev: Modifier, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrZwpLinuxDmabufV1 = ZwpLinuxDmabufV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrZwpLinuxDmabufV1 {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::Version,
|
||||
wire::{ZwpPrimarySelectionDeviceManagerV1Id, zwp_primary_selection_device_manager_v1::*},
|
||||
wl_usr::{UsrCon, usr_object::UsrObject},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrZwpPrimarySelectionDeviceManagerV1 {
|
||||
pub id: ZwpPrimarySelectionDeviceManagerV1Id,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl UsrZwpPrimarySelectionDeviceManagerV1 {}
|
||||
|
||||
impl ZwpPrimarySelectionDeviceManagerV1EventHandler for UsrZwpPrimarySelectionDeviceManagerV1 {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
self = UsrZwpPrimarySelectionDeviceManagerV1 = ZwpPrimarySelectionDeviceManagerV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl UsrObject for UsrZwpPrimarySelectionDeviceManagerV1 {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
object::{Interface, ObjectId, Version},
|
||||
utils::buffd::MsgParser,
|
||||
wl_usr::{UsrCon, UsrConError},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub trait UsrObjectBase {
|
||||
fn id(&self) -> ObjectId;
|
||||
fn handle_event(
|
||||
self: Rc<Self>,
|
||||
con: &UsrCon,
|
||||
event: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), UsrConError>;
|
||||
fn interface(&self) -> Interface;
|
||||
fn version(&self) -> Version;
|
||||
}
|
||||
|
||||
pub trait UsrObject: UsrObjectBase + 'static {
|
||||
fn destroy(&self);
|
||||
|
||||
fn break_loops(&self) {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue