autocommit 2022-02-05 18:14:24 CET
This commit is contained in:
parent
2d8b3a200e
commit
3a4ae99b9a
71 changed files with 1626 additions and 1306 deletions
|
|
@ -21,5 +21,9 @@ pub mod xdg_positioner;
|
|||
pub mod xdg_wm_base;
|
||||
pub mod zwp_linux_buffer_params_v1;
|
||||
pub mod zwp_linux_dmabuf_v1;
|
||||
pub mod zwp_primary_selection_device_manager_v1;
|
||||
pub mod zwp_primary_selection_device_v1;
|
||||
pub mod zwp_primary_selection_offer_v1;
|
||||
pub mod zwp_primary_selection_source_v1;
|
||||
pub mod zxdg_decoration_manager_v1;
|
||||
pub mod zxdg_toplevel_decoration_v1;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -61,33 +61,19 @@ impl OrgKdeKwinServerDecoration {
|
|||
self.client.event(self.mode(mode));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), OrgKdeKwinServerDecorationError> {
|
||||
match request {
|
||||
RELEASE => self.release(parser)?,
|
||||
REQUEST_MODE => self.request_mode(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(OrgKdeKwinServerDecoration);
|
||||
object_base! {
|
||||
OrgKdeKwinServerDecoration, OrgKdeKwinServerDecorationError;
|
||||
|
||||
RELEASE => release,
|
||||
REQUEST_MODE => request_mode,
|
||||
}
|
||||
|
||||
impl Object for OrgKdeKwinServerDecoration {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::OrgKdeKwinServerDecoration
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
REQUEST_MODE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(OrgKdeKwinServerDecoration);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecoration;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -34,7 +34,7 @@ impl OrgKdeKwinServerDecorationManagerGlobal {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), OrgKdeKwinServerDecorationManagerError> {
|
||||
let obj = Rc::new(OrgKdeKwinServerDecorationManagerObj {
|
||||
let obj = Rc::new(OrgKdeKwinServerDecorationManager {
|
||||
id,
|
||||
client: client.clone(),
|
||||
_version: version,
|
||||
|
|
@ -65,13 +65,15 @@ impl Global for OrgKdeKwinServerDecorationManagerGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct OrgKdeKwinServerDecorationManagerObj {
|
||||
simple_add_global!(OrgKdeKwinServerDecorationManagerGlobal);
|
||||
|
||||
pub struct OrgKdeKwinServerDecorationManager {
|
||||
id: OrgKdeKwinServerDecorationManagerGlobalId,
|
||||
client: Rc<Client>,
|
||||
_version: u32,
|
||||
}
|
||||
|
||||
impl OrgKdeKwinServerDecorationManagerObj {
|
||||
impl OrgKdeKwinServerDecorationManager {
|
||||
fn default_mode(self: &Rc<Self>, mode: u32) -> DynEventFormatter {
|
||||
Box::new(DefaultMode {
|
||||
obj: self.clone(),
|
||||
|
|
@ -81,39 +83,24 @@ impl OrgKdeKwinServerDecorationManagerObj {
|
|||
|
||||
fn create(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateError> {
|
||||
let req: Create = self.client.parse(self, parser)?;
|
||||
let _ = self.client.get_surface(req.surface)?;
|
||||
let _ = self.client.lookup(req.surface)?;
|
||||
let obj = Rc::new(OrgKdeKwinServerDecoration::new(req.id, &self.client));
|
||||
self.client.add_client_obj(&obj)?;
|
||||
self.client.event(obj.mode(SERVER));
|
||||
log::info!("ayo");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), OrgKdeKwinServerDecorationManagerError> {
|
||||
match request {
|
||||
CREATE => self.create(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(OrgKdeKwinServerDecorationManagerObj);
|
||||
object_base! {
|
||||
OrgKdeKwinServerDecorationManager, OrgKdeKwinServerDecorationManagerError;
|
||||
|
||||
impl Object for OrgKdeKwinServerDecorationManagerObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::OrgKdeKwinServerDecorationManager
|
||||
}
|
||||
CREATE => create,
|
||||
}
|
||||
|
||||
impl Object for OrgKdeKwinServerDecorationManager {
|
||||
fn num_requests(&self) -> u32 {
|
||||
CREATE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(OrgKdeKwinServerDecorationManager);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecorationId;
|
||||
use crate::ifs::org_kde_kwin_server_decoration_manager::{
|
||||
OrgKdeKwinServerDecorationManagerObj, DEFAULT_MODE,
|
||||
OrgKdeKwinServerDecorationManager, DEFAULT_MODE,
|
||||
};
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::Object;
|
||||
|
|
@ -52,7 +52,7 @@ impl Debug for Create {
|
|||
}
|
||||
|
||||
pub(super) struct DefaultMode {
|
||||
pub obj: Rc<OrgKdeKwinServerDecorationManagerObj>,
|
||||
pub obj: Rc<OrgKdeKwinServerDecorationManager>,
|
||||
pub mode: u32,
|
||||
}
|
||||
impl EventFormatter for DefaultMode {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ mod types;
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::clientmem::{ClientMem, ClientMemOffset};
|
||||
use crate::format::Format;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::{Image, Texture};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
|
|
@ -122,35 +122,21 @@ impl WlBuffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlBufferError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn release(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Release { obj: self.clone() })
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlBuffer);
|
||||
object_base! {
|
||||
WlBuffer, WlBufferError;
|
||||
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for WlBuffer {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlBuffer
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(WlBuffer, WlBufferId, buffers);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{ClientError, DynEventFormatter};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::object::Object;
|
||||
use std::rc::Rc;
|
||||
use types::*;
|
||||
|
||||
|
|
@ -22,28 +21,16 @@ impl WlCallback {
|
|||
pub fn done(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Done { obj: self.clone() })
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
_request: u32,
|
||||
_parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ClientError> {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlCallback);
|
||||
object_base! {
|
||||
WlCallback, WlCallbackError;
|
||||
}
|
||||
|
||||
impl Object for WlCallback {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlCallback
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlCallback);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ use crate::object::Object;
|
|||
use crate::utils::buffd::MsgFormatter;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlCallbackError {}
|
||||
|
||||
pub(super) struct Done {
|
||||
pub obj: Rc<WlCallback>,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::client::Client;
|
|||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_region::WlRegion;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -18,7 +18,7 @@ pub struct WlCompositorGlobal {
|
|||
name: GlobalName,
|
||||
}
|
||||
|
||||
pub struct WlCompositorObj {
|
||||
pub struct WlCompositor {
|
||||
id: WlCompositorId,
|
||||
client: Rc<Client>,
|
||||
_version: u32,
|
||||
|
|
@ -35,7 +35,7 @@ impl WlCompositorGlobal {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), WlCompositorError> {
|
||||
let obj = Rc::new(WlCompositorObj {
|
||||
let obj = Rc::new(WlCompositor {
|
||||
id,
|
||||
client: client.clone(),
|
||||
_version: version,
|
||||
|
|
@ -45,7 +45,7 @@ impl WlCompositorGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
impl WlCompositorObj {
|
||||
impl WlCompositor {
|
||||
fn create_surface(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateSurfaceError> {
|
||||
let surface: CreateSurface = self.client.parse(self, parser)?;
|
||||
let surface = Rc::new(WlSurface::new(surface.id, &self.client));
|
||||
|
|
@ -59,19 +59,6 @@ impl WlCompositorObj {
|
|||
self.client.add_client_obj(®ion)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlCompositorError> {
|
||||
match request {
|
||||
CREATE_SURFACE => self.create_surface(parser)?,
|
||||
CREATE_REGION => self.create_region(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
bind!(WlCompositorGlobal);
|
||||
|
|
@ -94,18 +81,19 @@ impl Global for WlCompositorGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(WlCompositorObj);
|
||||
simple_add_global!(WlCompositorGlobal);
|
||||
|
||||
impl Object for WlCompositorObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
object_base! {
|
||||
WlCompositor, WlCompositorError;
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlCompositor
|
||||
}
|
||||
CREATE_SURFACE => create_surface,
|
||||
CREATE_REGION => create_region,
|
||||
}
|
||||
|
||||
impl Object for WlCompositor {
|
||||
fn num_requests(&self) -> u32 {
|
||||
CREATE_REGION + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlCompositor);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{DynEventFormatter};
|
||||
use crate::ifs::wl_data_device_manager::WlDataDeviceManagerObj;
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::ifs::wl_data_device_manager::WlDataDeviceManager;
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
use crate::ifs::wl_seat::{WlSeatObj};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -27,16 +27,12 @@ id!(WlDataDeviceId);
|
|||
|
||||
pub struct WlDataDevice {
|
||||
pub id: WlDataDeviceId,
|
||||
pub manager: Rc<WlDataDeviceManagerObj>,
|
||||
seat: Rc<WlSeatObj>,
|
||||
pub manager: Rc<WlDataDeviceManager>,
|
||||
seat: Rc<WlSeat>,
|
||||
}
|
||||
|
||||
impl WlDataDevice {
|
||||
pub fn new(
|
||||
id: WlDataDeviceId,
|
||||
manager: &Rc<WlDataDeviceManagerObj>,
|
||||
seat: &Rc<WlSeatObj>,
|
||||
) -> Self {
|
||||
pub fn new(id: WlDataDeviceId, manager: &Rc<WlDataDeviceManager>, seat: &Rc<WlSeat>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
manager: manager.clone(),
|
||||
|
|
@ -68,7 +64,7 @@ impl WlDataDevice {
|
|||
let src = if req.source.is_none() {
|
||||
None
|
||||
} else {
|
||||
Some(self.manager.client.get_wl_data_source(req.source)?)
|
||||
Some(self.manager.client.lookup(req.source)?)
|
||||
};
|
||||
self.seat.global.set_selection(src)?;
|
||||
Ok(())
|
||||
|
|
@ -80,33 +76,17 @@ impl WlDataDevice {
|
|||
self.manager.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDataDeviceError> {
|
||||
match request {
|
||||
START_DRAG => self.start_drag(parser)?,
|
||||
SET_SELECTION => self.set_selection(parser)?,
|
||||
RELEASE => self.release(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlDataDevice);
|
||||
object_base! {
|
||||
WlDataDevice, WlDataDeviceError;
|
||||
|
||||
START_DRAG => start_drag,
|
||||
SET_SELECTION => set_selection,
|
||||
RELEASE => release,
|
||||
}
|
||||
|
||||
impl Object for WlDataDevice {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlDataDevice
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
RELEASE + 1
|
||||
}
|
||||
|
|
@ -115,3 +95,5 @@ impl Object for WlDataDevice {
|
|||
self.seat.remove_data_device(self);
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlDataDevice);
|
||||
|
|
|
|||
|
|
@ -243,3 +243,9 @@ impl Debug for Selection {
|
|||
write!(f, "selection(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
//
|
||||
// msgs! {
|
||||
// WlDataDevice::Selection = 5 {
|
||||
// id: id(WlDataOffer),
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::client::Client;
|
|||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_source::WlDataSource;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -27,7 +27,7 @@ pub struct WlDataDeviceManagerGlobal {
|
|||
name: GlobalName,
|
||||
}
|
||||
|
||||
pub struct WlDataDeviceManagerObj {
|
||||
pub struct WlDataDeviceManager {
|
||||
pub id: WlDataDeviceManagerId,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
|
|
@ -44,7 +44,7 @@ impl WlDataDeviceManagerGlobal {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), WlDataDeviceManagerError> {
|
||||
let obj = Rc::new(WlDataDeviceManagerObj {
|
||||
let obj = Rc::new(WlDataDeviceManager {
|
||||
id,
|
||||
client: client.clone(),
|
||||
version,
|
||||
|
|
@ -54,7 +54,7 @@ impl WlDataDeviceManagerGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
impl WlDataDeviceManagerObj {
|
||||
impl WlDataDeviceManager {
|
||||
fn create_data_source(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateDataSourceError> {
|
||||
let req: CreateDataSource = self.client.parse(self, parser)?;
|
||||
let res = Rc::new(WlDataSource::new(req.id, &self.client));
|
||||
|
|
@ -67,25 +67,12 @@ impl WlDataDeviceManagerObj {
|
|||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), GetDataDeviceError> {
|
||||
let req: GetDataDevice = self.client.parse(&**self, parser)?;
|
||||
let seat = self.client.get_wl_seat(req.seat)?;
|
||||
let seat = self.client.lookup(req.seat)?;
|
||||
let dev = Rc::new(WlDataDevice::new(req.id, self, &seat));
|
||||
seat.add_data_device(&dev);
|
||||
self.client.add_client_obj(&dev)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDataDeviceManagerError> {
|
||||
match request {
|
||||
CREATE_DATA_SOURCE => self.create_data_source(parser)?,
|
||||
GET_DATA_DEVICE => self.get_data_device(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
bind!(WlDataDeviceManagerGlobal);
|
||||
|
|
@ -108,18 +95,19 @@ impl Global for WlDataDeviceManagerGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(WlDataDeviceManagerObj);
|
||||
simple_add_global!(WlDataDeviceManagerGlobal);
|
||||
|
||||
impl Object for WlDataDeviceManagerObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
object_base! {
|
||||
WlDataDeviceManager, WlDataDeviceManagerError;
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlDataDeviceManager
|
||||
}
|
||||
CREATE_DATA_SOURCE => create_data_source,
|
||||
GET_DATA_DEVICE => get_data_device,
|
||||
}
|
||||
|
||||
impl Object for WlDataDeviceManager {
|
||||
fn num_requests(&self) -> u32 {
|
||||
GET_DATA_DEVICE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlDataDeviceManager);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::ifs::wl_data_source::{WlDataSource};
|
||||
use crate::ifs::wl_data_source::WlDataSource;
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use std::ops::Deref;
|
||||
|
|
@ -121,35 +121,19 @@ impl WlDataOffer {
|
|||
let _req: SetActions = self.client.parse(self, parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDataOfferError> {
|
||||
match request {
|
||||
ACCEPT => self.accept(parser)?,
|
||||
RECEIVE => self.receive(parser)?,
|
||||
DESTROY => self.destroy(parser)?,
|
||||
FINISH => self.finish(parser)?,
|
||||
SET_ACTIONS => self.set_actions(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlDataOffer);
|
||||
object_base! {
|
||||
WlDataOffer, WlDataOfferError;
|
||||
|
||||
ACCEPT => accept,
|
||||
RECEIVE => receive,
|
||||
DESTROY => destroy,
|
||||
FINISH => finish,
|
||||
SET_ACTIONS => set_actions,
|
||||
}
|
||||
|
||||
impl Object for WlDataOffer {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlDataOffer
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
SET_ACTIONS + 1
|
||||
}
|
||||
|
|
@ -158,3 +142,5 @@ impl Object for WlDataOffer {
|
|||
self.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlDataOffer);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::client::{ClientError, EventFormatter, RequestParser};
|
|||
use crate::ifs::wl_data_offer::{WlDataOffer, ACTION, OFFER, SOURCE_ACTIONS};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use bstr::{BStr};
|
||||
use bstr::BStr;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
|
@ -180,7 +180,7 @@ impl EventFormatter for Offer {
|
|||
}
|
||||
impl Debug for Offer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "target(mime_type: {:?})", self.mime_type)
|
||||
write!(f, "offer(mime_type: {:?})", self.mime_type)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ mod types;
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::ifs::wl_data_offer::{DataOfferRole, WlDataOffer};
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::{CloneCell, UnsafeCellCloneSafe};
|
||||
use ahash::AHashSet;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use uapi::OwnedFd;
|
||||
pub use types::*;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
const OFFER: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
|
|
@ -62,15 +62,13 @@ impl WlDataSource {
|
|||
seat: &Rc<WlSeatGlobal>,
|
||||
role: DataOfferRole,
|
||||
) -> Result<(), WlDataSourceError> {
|
||||
let old = self.attachment.set(
|
||||
Some(Attachment {
|
||||
seat: seat.clone(),
|
||||
role,
|
||||
}),
|
||||
);
|
||||
if old.is_some() {
|
||||
if self.attachment.get().is_some() {
|
||||
return Err(WlDataSourceError::AlreadyAttached);
|
||||
}
|
||||
self.attachment.set(Some(Attachment {
|
||||
seat: seat.clone(),
|
||||
role,
|
||||
}));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -103,9 +101,7 @@ impl WlDataSource {
|
|||
}
|
||||
|
||||
pub fn cancelled(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Cancelled {
|
||||
obj: self.clone(),
|
||||
})
|
||||
Box::new(Cancelled { obj: self.clone() })
|
||||
}
|
||||
|
||||
pub fn send(self: &Rc<Self>, mime_type: &str, fd: OwnedFd) -> DynEventFormatter {
|
||||
|
|
@ -138,7 +134,7 @@ impl WlDataSource {
|
|||
match attachment.role {
|
||||
DataOfferRole::Selection => {
|
||||
let _ = attachment.seat.set_selection(None);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,33 +150,17 @@ impl WlDataSource {
|
|||
let _req: SetActions = self.client.parse(self, parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDataSourceError> {
|
||||
match request {
|
||||
OFFER => self.offer(parser)?,
|
||||
DESTROY => self.destroy(parser)?,
|
||||
SET_ACTIONS => self.set_actions(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlDataSource);
|
||||
object_base! {
|
||||
WlDataSource, WlDataSourceError;
|
||||
|
||||
OFFER => offer,
|
||||
DESTROY => destroy,
|
||||
SET_ACTIONS => set_actions,
|
||||
}
|
||||
|
||||
impl Object for WlDataSource {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlDataSource
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
SET_ACTIONS + 1
|
||||
}
|
||||
|
|
@ -189,3 +169,5 @@ impl Object for WlDataSource {
|
|||
self.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(WlDataSource, WlDataSourceId, wl_data_source);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::ifs::wl_data_source::{
|
|||
};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use bstr::{BString};
|
||||
use bstr::BString;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ mod types;
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::ifs::wl_callback::WlCallback;
|
||||
use crate::ifs::wl_registry::WlRegistry;
|
||||
use crate::object::{Interface, Object, ObjectId, WL_DISPLAY_ID};
|
||||
use crate::object::{Object, ObjectId, WL_DISPLAY_ID};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -21,29 +21,18 @@ const NO_MEMORY: u32 = 2;
|
|||
const IMPLEMENTATION: u32 = 3;
|
||||
|
||||
pub struct WlDisplay {
|
||||
id: ObjectId,
|
||||
client: Rc<Client>,
|
||||
}
|
||||
|
||||
impl WlDisplay {
|
||||
pub fn new(client: &Rc<Client>) -> Self {
|
||||
Self {
|
||||
id: WL_DISPLAY_ID,
|
||||
client: client.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDisplayError> {
|
||||
match request {
|
||||
SYNC => self.sync(parser)?,
|
||||
GET_REGISTRY => self.get_registry(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sync(&self, parser: MsgParser<'_, '_>) -> Result<(), SyncError> {
|
||||
let sync: Sync = self.client.parse(self, parser)?;
|
||||
let cb = Rc::new(WlCallback::new(sync.callback));
|
||||
|
|
@ -106,17 +95,14 @@ impl WlDisplay {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(WlDisplay);
|
||||
object_base! {
|
||||
WlDisplay, WlDisplayError;
|
||||
|
||||
SYNC => sync,
|
||||
GET_REGISTRY => get_registry,
|
||||
}
|
||||
|
||||
impl Object for WlDisplay {
|
||||
fn id(&self) -> ObjectId {
|
||||
WL_DISPLAY_ID
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlDisplay
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
GET_REGISTRY + 1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::globals::GlobalError;
|
||||
use crate::globals::GlobalsError;
|
||||
use crate::ifs::wl_callback::WlCallbackId;
|
||||
use crate::ifs::wl_display::{WlDisplay, DELETE_ID, ERROR};
|
||||
use crate::ifs::wl_registry::WlRegistryId;
|
||||
|
|
@ -27,11 +27,11 @@ pub enum GetRegistryError {
|
|||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("An error occurred while processing globals")]
|
||||
GlobalError(#[source] Box<GlobalError>),
|
||||
GlobalsError(#[source] Box<GlobalsError>),
|
||||
}
|
||||
|
||||
efrom!(GetRegistryError, ParseFailed, MsgParserError);
|
||||
efrom!(GetRegistryError, GlobalError);
|
||||
efrom!(GetRegistryError, GlobalsError);
|
||||
efrom!(GetRegistryError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::ffi::CString;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -36,7 +36,7 @@ impl WlDrmGlobal {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), WlDrmError> {
|
||||
let obj = Rc::new(WlDrmObj {
|
||||
let obj = Rc::new(WlDrm {
|
||||
id,
|
||||
client: client.clone(),
|
||||
_version: version,
|
||||
|
|
@ -70,13 +70,15 @@ impl Global for WlDrmGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct WlDrmObj {
|
||||
simple_add_global!(WlDrmGlobal);
|
||||
|
||||
pub struct WlDrm {
|
||||
id: WlDrmId,
|
||||
pub client: Rc<Client>,
|
||||
_version: u32,
|
||||
}
|
||||
|
||||
impl WlDrmObj {
|
||||
impl WlDrm {
|
||||
fn device(self: &Rc<Self>, device: &Rc<CString>) -> DynEventFormatter {
|
||||
Box::new(Device {
|
||||
obj: self.clone(),
|
||||
|
|
@ -113,34 +115,20 @@ impl WlDrmObj {
|
|||
let _req: CreatePlanarBuffer = self.client.parse(&**self, parser)?;
|
||||
Err(CreatePlanarBufferError::Unsupported)
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDrmError> {
|
||||
match request {
|
||||
AUTHENTICATE => self.authenticate(parser)?,
|
||||
CREATE_BUFFER => self.create_buffer(parser)?,
|
||||
CREATE_PLANAR_BUFFER => self.create_planar_buffer(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlDrmObj);
|
||||
object_base! {
|
||||
WlDrm, WlDrmError;
|
||||
|
||||
impl Object for WlDrmObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlDrm
|
||||
}
|
||||
AUTHENTICATE => authenticate,
|
||||
CREATE_BUFFER => create_buffer,
|
||||
CREATE_PLANAR_BUFFER => create_planar_buffer,
|
||||
}
|
||||
|
||||
impl Object for WlDrm {
|
||||
fn num_requests(&self) -> u32 {
|
||||
CREATE_PLANAR_BUFFER + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlDrm);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_buffer::WlBufferId;
|
||||
use crate::ifs::wl_drm::{WlDrmObj, AUTHENTICATED, CAPABILITIES, DEVICE, FORMAT};
|
||||
use crate::ifs::wl_drm::{WlDrm, AUTHENTICATED, CAPABILITIES, DEVICE, FORMAT};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::ffi::CString;
|
||||
|
|
@ -139,7 +139,7 @@ impl Debug for CreatePlanarBuffer {
|
|||
}
|
||||
|
||||
pub(super) struct Device {
|
||||
pub obj: Rc<WlDrmObj>,
|
||||
pub obj: Rc<WlDrm>,
|
||||
pub name: Rc<CString>,
|
||||
}
|
||||
impl EventFormatter for Device {
|
||||
|
|
@ -157,7 +157,7 @@ impl Debug for Device {
|
|||
}
|
||||
|
||||
pub(super) struct Format {
|
||||
pub obj: Rc<WlDrmObj>,
|
||||
pub obj: Rc<WlDrm>,
|
||||
pub format: u32,
|
||||
}
|
||||
impl EventFormatter for Format {
|
||||
|
|
@ -175,7 +175,7 @@ impl Debug for Format {
|
|||
}
|
||||
|
||||
pub(super) struct Authenticated {
|
||||
pub obj: Rc<WlDrmObj>,
|
||||
pub obj: Rc<WlDrm>,
|
||||
}
|
||||
impl EventFormatter for Authenticated {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
|
|
@ -192,7 +192,7 @@ impl Debug for Authenticated {
|
|||
}
|
||||
|
||||
pub(super) struct Capabilities {
|
||||
pub obj: Rc<WlDrmObj>,
|
||||
pub obj: Rc<WlDrm>,
|
||||
pub value: u32,
|
||||
}
|
||||
impl EventFormatter for Capabilities {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ mod types;
|
|||
use crate::backend::Output;
|
||||
use crate::client::{Client, ClientId, DynEventFormatter, WlEvent};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use ahash::AHashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
|
@ -60,7 +60,7 @@ pub struct WlOutputGlobal {
|
|||
pub y: Cell<i32>,
|
||||
width: Cell<i32>,
|
||||
height: Cell<i32>,
|
||||
pub bindings: RefCell<AHashMap<ClientId, AHashMap<WlOutputId, Rc<WlOutputObj>>>>,
|
||||
pub bindings: RefCell<AHashMap<ClientId, AHashMap<WlOutputId, Rc<WlOutput>>>>,
|
||||
}
|
||||
|
||||
impl WlOutputGlobal {
|
||||
|
|
@ -112,7 +112,7 @@ impl WlOutputGlobal {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), WlOutputError> {
|
||||
let obj = Rc::new(WlOutputObj {
|
||||
let obj = Rc::new(WlOutput {
|
||||
global: self.clone(),
|
||||
id,
|
||||
client: client.clone(),
|
||||
|
|
@ -160,14 +160,16 @@ impl Global for WlOutputGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct WlOutputObj {
|
||||
dedicated_add_global!(WlOutputGlobal, outputs);
|
||||
|
||||
pub struct WlOutput {
|
||||
global: Rc<WlOutputGlobal>,
|
||||
pub id: WlOutputId,
|
||||
client: Rc<Client>,
|
||||
version: u32,
|
||||
}
|
||||
|
||||
impl WlOutputObj {
|
||||
impl WlOutput {
|
||||
fn send_done(&self) -> bool {
|
||||
self.version >= 2
|
||||
}
|
||||
|
|
@ -226,31 +228,15 @@ impl WlOutputObj {
|
|||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlOutputError> {
|
||||
match request {
|
||||
RELEASE => self.release(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlOutputObj);
|
||||
object_base! {
|
||||
WlOutput, WlOutputError;
|
||||
|
||||
impl Object for WlOutputObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlOutput
|
||||
}
|
||||
RELEASE => release,
|
||||
}
|
||||
|
||||
impl Object for WlOutput {
|
||||
fn num_requests(&self) -> u32 {
|
||||
if self.version < 3 {
|
||||
0
|
||||
|
|
@ -263,3 +249,5 @@ impl Object for WlOutputObj {
|
|||
self.remove_binding();
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlOutput);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_output::{WlOutputObj, DONE, GEOMETRY, MODE, SCALE};
|
||||
use crate::ifs::wl_output::{WlOutput, DONE, GEOMETRY, MODE, SCALE};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
|
@ -38,7 +38,7 @@ impl Debug for Release {
|
|||
}
|
||||
|
||||
pub(super) struct Geometry {
|
||||
pub obj: Rc<WlOutputObj>,
|
||||
pub obj: Rc<WlOutput>,
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub physical_width: i32,
|
||||
|
|
@ -72,7 +72,7 @@ impl Debug for Geometry {
|
|||
}
|
||||
|
||||
pub(super) struct Mode {
|
||||
pub obj: Rc<WlOutputObj>,
|
||||
pub obj: Rc<WlOutput>,
|
||||
pub flags: u32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
|
|
@ -101,7 +101,7 @@ impl Debug for Mode {
|
|||
}
|
||||
|
||||
pub(super) struct Done {
|
||||
pub obj: Rc<WlOutputObj>,
|
||||
pub obj: Rc<WlOutput>,
|
||||
}
|
||||
impl EventFormatter for Done {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
|
|
@ -118,7 +118,7 @@ impl Debug for Done {
|
|||
}
|
||||
|
||||
pub(super) struct Scale {
|
||||
pub obj: Rc<WlOutputObj>,
|
||||
pub obj: Rc<WlOutput>,
|
||||
pub factor: i32,
|
||||
}
|
||||
impl EventFormatter for Scale {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::pixman::Region;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::cell::RefCell;
|
||||
|
|
@ -63,34 +63,20 @@ impl WlRegion {
|
|||
));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlRegionError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
ADD => self.add(parser)?,
|
||||
SUBTRACT => self.subtract(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlRegion);
|
||||
object_base! {
|
||||
WlRegion, WlRegionError;
|
||||
|
||||
DESTROY => destroy,
|
||||
ADD => add,
|
||||
SUBTRACT => subtract,
|
||||
}
|
||||
|
||||
impl Object for WlRegion {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlRegion
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
SUBTRACT + 1
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(WlRegion, WlRegionId, regions);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod types;
|
|||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -62,32 +62,18 @@ impl WlRegistry {
|
|||
global.bind(&self.client, bind.id, bind.version)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlRegistryError> {
|
||||
match request {
|
||||
BIND => self.bind(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlRegistry);
|
||||
object_base! {
|
||||
WlRegistry, WlRegistryError;
|
||||
|
||||
BIND => bind,
|
||||
}
|
||||
|
||||
impl Object for WlRegistry {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlRegistry
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
BIND + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlRegistry);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::client::{EventFormatter, RequestParser};
|
||||
use crate::globals::{Global, GlobalError, GlobalName};
|
||||
use crate::globals::{Global, GlobalsError, GlobalName};
|
||||
use crate::ifs::wl_registry::{WlRegistry, GLOBAL, GLOBAL_REMOVE};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
|
|
@ -21,7 +21,7 @@ pub enum BindError {
|
|||
#[error("Parsing failed")]
|
||||
ParseError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
GlobalError(Box<GlobalError>),
|
||||
GlobalsError(Box<GlobalsError>),
|
||||
#[error("Tried to bind to global {} of type {} using interface {}", .0.name, .0.interface.name(), .0.actual)]
|
||||
InvalidInterface(InterfaceError),
|
||||
#[error("Tried to bind to global {} of type {} and version {} using version {}", .0.name, .0.interface.name(), .0.version, .0.actual)]
|
||||
|
|
@ -44,7 +44,7 @@ pub struct VersionError {
|
|||
}
|
||||
|
||||
efrom!(BindError, ParseError, MsgParserError);
|
||||
efrom!(BindError, GlobalError);
|
||||
efrom!(BindError, GlobalsError);
|
||||
|
||||
pub(super) struct GlobalE {
|
||||
pub obj: Rc<WlRegistry>,
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@ use crate::backend::{KeyState, OutputId, ScrollAxis, SeatEvent, SeatId};
|
|||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_offer::{WlDataOfferId};
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
use crate::ifs::wl_seat::wl_keyboard::WlKeyboard;
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, POINTER_FRAME_SINCE_VERSION};
|
||||
use crate::ifs::wl_seat::{
|
||||
wl_keyboard, wl_pointer, PointerGrab, PointerGrabber, WlSeatGlobal, WlSeatObj,
|
||||
wl_keyboard, wl_pointer, PointerGrab, PointerGrabber, WlSeat, WlSeatGlobal,
|
||||
};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::ifs::wl_surface::xdg_surface::XdgSurface;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::ifs::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::tree::{FloatNode, FoundNode, Node};
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP};
|
||||
|
|
@ -257,7 +258,7 @@ impl WlSeatGlobal {
|
|||
|
||||
fn for_each_seat<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<WlSeatObj>),
|
||||
C: FnMut(&Rc<WlSeat>),
|
||||
{
|
||||
let bindings = self.bindings.borrow();
|
||||
if let Some(hm) = bindings.get(&client) {
|
||||
|
|
@ -307,6 +308,20 @@ impl WlSeatGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn for_each_primary_selection_device<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>),
|
||||
{
|
||||
let dd = self.primary_selection_devices.borrow_mut();
|
||||
if let Some(dd) = dd.get(&client) {
|
||||
for dd in dd.values() {
|
||||
if dd.manager.version >= ver {
|
||||
f(dd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn surface_pointer_frame(&self, surface: &WlSurface) {
|
||||
self.surface_pointer_event(POINTER_FRAME_SINCE_VERSION, surface, |p| p.frame());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,14 @@ use crate::ifs::wl_seat::wl_keyboard::{WlKeyboard, WlKeyboardId, REPEAT_INFO_SIN
|
|||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, WlPointerId};
|
||||
use crate::ifs::wl_seat::wl_touch::WlTouch;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::ifs::zwp_primary_selection_device_v1::{
|
||||
ZwpPrimarySelectionDeviceV1, ZwpPrimarySelectionDeviceV1Id,
|
||||
};
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{
|
||||
ZwpPrimarySelectionSourceV1, ZwpPrimarySelectionSourceV1Error,
|
||||
};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::tree::{FloatNode, FoundNode, Node};
|
||||
use crate::utils::asyncevent::AsyncEvent;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
|
|
@ -88,8 +95,14 @@ pub struct WlSeatGlobal {
|
|||
toplevel_focus_history: LinkedList<Rc<XdgToplevel>>,
|
||||
keyboard_node: CloneCell<Rc<dyn Node>>,
|
||||
pressed_keys: RefCell<AHashSet<u32>>,
|
||||
bindings: RefCell<AHashMap<ClientId, AHashMap<WlSeatId, Rc<WlSeatObj>>>>,
|
||||
bindings: RefCell<AHashMap<ClientId, AHashMap<WlSeatId, Rc<WlSeat>>>>,
|
||||
data_devices: RefCell<AHashMap<ClientId, AHashMap<WlDataDeviceId, Rc<WlDataDevice>>>>,
|
||||
primary_selection_devices: RefCell<
|
||||
AHashMap<
|
||||
ClientId,
|
||||
AHashMap<ZwpPrimarySelectionDeviceV1Id, Rc<ZwpPrimarySelectionDeviceV1>>,
|
||||
>,
|
||||
>,
|
||||
kb_state: RefCell<XkbState>,
|
||||
layout: Rc<OwnedFd>,
|
||||
layout_size: u32,
|
||||
|
|
@ -98,6 +111,7 @@ pub struct WlSeatGlobal {
|
|||
grabber: RefCell<Option<PointerGrabber>>,
|
||||
tree_changed: Rc<AsyncEvent>,
|
||||
selection: CloneCell<Option<Rc<WlDataSource>>>,
|
||||
primary_selection: CloneCell<Option<Rc<ZwpPrimarySelectionSourceV1>>>,
|
||||
}
|
||||
|
||||
impl WlSeatGlobal {
|
||||
|
|
@ -140,6 +154,7 @@ impl WlSeatGlobal {
|
|||
pressed_keys: RefCell::new(Default::default()),
|
||||
bindings: Default::default(),
|
||||
data_devices: RefCell::new(Default::default()),
|
||||
primary_selection_devices: RefCell::new(Default::default()),
|
||||
kb_state: RefCell::new(kb_state),
|
||||
layout,
|
||||
layout_size,
|
||||
|
|
@ -148,10 +163,14 @@ impl WlSeatGlobal {
|
|||
grabber: RefCell::new(None),
|
||||
tree_changed: tree_changed.clone(),
|
||||
selection: Default::default(),
|
||||
primary_selection: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_selection(self: &Rc<Self>, selection: Option<Rc<WlDataSource>>) -> Result<(), WlDataSourceError> {
|
||||
pub fn set_selection(
|
||||
self: &Rc<Self>,
|
||||
selection: Option<Rc<WlDataSource>>,
|
||||
) -> Result<(), WlDataSourceError> {
|
||||
if let Some(new) = &selection {
|
||||
new.attach(self, DataOfferRole::Selection)?;
|
||||
}
|
||||
|
|
@ -169,6 +188,33 @@ impl WlSeatGlobal {
|
|||
});
|
||||
}
|
||||
}
|
||||
client.flush();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_primary_selection(
|
||||
self: &Rc<Self>,
|
||||
selection: Option<Rc<ZwpPrimarySelectionSourceV1>>,
|
||||
) -> Result<(), ZwpPrimarySelectionSourceV1Error> {
|
||||
if let Some(new) = &selection {
|
||||
new.attach(self)?;
|
||||
}
|
||||
if let Some(old) = self.primary_selection.set(selection.clone()) {
|
||||
old.detach();
|
||||
}
|
||||
if let Some(client) = self.keyboard_node.get().client() {
|
||||
match selection {
|
||||
Some(sel) => {
|
||||
sel.create_offer(&client);
|
||||
}
|
||||
_ => {
|
||||
self.for_each_primary_selection_device(0, client.id, |device| {
|
||||
client.event(device.selection(ZwpPrimarySelectionOfferV1Id::NONE));
|
||||
});
|
||||
}
|
||||
}
|
||||
client.flush();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -219,7 +265,7 @@ impl WlSeatGlobal {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), WlSeatError> {
|
||||
let obj = Rc::new(WlSeatObj {
|
||||
let obj = Rc::new(WlSeat {
|
||||
global: self.clone(),
|
||||
id,
|
||||
client: client.clone(),
|
||||
|
|
@ -265,7 +311,9 @@ impl Global for WlSeatGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct WlSeatObj {
|
||||
dedicated_add_global!(WlSeatGlobal, seats);
|
||||
|
||||
pub struct WlSeat {
|
||||
pub global: Rc<WlSeatGlobal>,
|
||||
id: WlSeatId,
|
||||
client: Rc<Client>,
|
||||
|
|
@ -274,7 +322,7 @@ pub struct WlSeatObj {
|
|||
version: u32,
|
||||
}
|
||||
|
||||
impl WlSeatObj {
|
||||
impl WlSeat {
|
||||
fn capabilities(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Capabilities {
|
||||
obj: self.clone(),
|
||||
|
|
@ -306,6 +354,23 @@ impl WlSeatObj {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn add_primary_selection_device(&self, device: &Rc<ZwpPrimarySelectionDeviceV1>) {
|
||||
let mut dd = self.global.primary_selection_devices.borrow_mut();
|
||||
dd.entry(self.client.id)
|
||||
.or_default()
|
||||
.insert(device.id, device.clone());
|
||||
}
|
||||
|
||||
pub fn remove_primary_selection_device(&self, device: &ZwpPrimarySelectionDeviceV1) {
|
||||
let mut dd = self.global.primary_selection_devices.borrow_mut();
|
||||
if let Entry::Occupied(mut e) = dd.entry(self.client.id) {
|
||||
e.get_mut().remove(&device.id);
|
||||
if e.get().is_empty() {
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn move_(&self, node: &Rc<FloatNode>) {
|
||||
self.global.move_(node);
|
||||
}
|
||||
|
|
@ -349,34 +414,18 @@ impl WlSeatObj {
|
|||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlSeatError> {
|
||||
match request {
|
||||
GET_POINTER => self.get_pointer(parser)?,
|
||||
GET_KEYBOARD => self.get_keyboard(parser)?,
|
||||
GET_TOUCH => self.get_touch(parser)?,
|
||||
RELEASE => self.release(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlSeatObj);
|
||||
object_base! {
|
||||
WlSeat, WlSeatError;
|
||||
|
||||
impl Object for WlSeatObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlSeat
|
||||
}
|
||||
GET_POINTER => get_pointer,
|
||||
GET_KEYBOARD => get_keyboard,
|
||||
GET_TOUCH => get_touch,
|
||||
RELEASE => release,
|
||||
}
|
||||
|
||||
impl Object for WlSeat {
|
||||
fn num_requests(&self) -> u32 {
|
||||
if self.version < 5 {
|
||||
GET_TOUCH + 1
|
||||
|
|
@ -396,3 +445,5 @@ impl Object for WlSeatObj {
|
|||
self.keyboards.clear();
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(WlSeat, WlSeatId, seats);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::client::{ClientError, EventFormatter, RequestParser};
|
|||
use crate::ifs::wl_seat::wl_keyboard::{WlKeyboardError, WlKeyboardId};
|
||||
use crate::ifs::wl_seat::wl_pointer::WlPointerId;
|
||||
use crate::ifs::wl_seat::wl_touch::WlTouchId;
|
||||
use crate::ifs::wl_seat::{WlSeatObj, CAPABILITIES, NAME};
|
||||
use crate::ifs::wl_seat::{WlSeat, CAPABILITIES, NAME};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
|
@ -128,7 +128,7 @@ impl Debug for Release {
|
|||
}
|
||||
|
||||
pub(super) struct Capabilities {
|
||||
pub obj: Rc<WlSeatObj>,
|
||||
pub obj: Rc<WlSeat>,
|
||||
pub capabilities: u32,
|
||||
}
|
||||
impl EventFormatter for Capabilities {
|
||||
|
|
@ -147,7 +147,7 @@ impl Debug for Capabilities {
|
|||
}
|
||||
|
||||
pub(super) struct Name {
|
||||
pub obj: Rc<WlSeatObj>,
|
||||
pub obj: Rc<WlSeat>,
|
||||
pub name: Rc<String>,
|
||||
}
|
||||
impl EventFormatter for Name {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::ifs::wl_seat::WlSeatObj;
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -33,11 +33,11 @@ id!(WlKeyboardId);
|
|||
|
||||
pub struct WlKeyboard {
|
||||
id: WlKeyboardId,
|
||||
seat: Rc<WlSeatObj>,
|
||||
seat: Rc<WlSeat>,
|
||||
}
|
||||
|
||||
impl WlKeyboard {
|
||||
pub fn new(id: WlKeyboardId, seat: &Rc<WlSeatObj>) -> Self {
|
||||
pub fn new(id: WlKeyboardId, seat: &Rc<WlSeat>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
seat: seat.clone(),
|
||||
|
|
@ -152,32 +152,18 @@ impl WlKeyboard {
|
|||
self.seat.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlKeyboardError> {
|
||||
match request {
|
||||
RELEASE => self.release(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlKeyboard);
|
||||
object_base! {
|
||||
WlKeyboard, WlKeyboardError;
|
||||
|
||||
RELEASE => release,
|
||||
}
|
||||
|
||||
impl Object for WlKeyboard {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlKeyboard
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
RELEASE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlKeyboard);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ mod types;
|
|||
use crate::client::DynEventFormatter;
|
||||
use crate::cursor::Cursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::WlSeatObj;
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -47,11 +47,11 @@ id!(WlPointerId);
|
|||
|
||||
pub struct WlPointer {
|
||||
id: WlPointerId,
|
||||
seat: Rc<WlSeatObj>,
|
||||
seat: Rc<WlSeat>,
|
||||
}
|
||||
|
||||
impl WlPointer {
|
||||
pub fn new(id: WlPointerId, seat: &Rc<WlSeatObj>) -> Self {
|
||||
pub fn new(id: WlPointerId, seat: &Rc<WlSeat>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
seat: seat.clone(),
|
||||
|
|
@ -151,7 +151,7 @@ impl WlPointer {
|
|||
let req: SetCursor = self.seat.client.parse(self, parser)?;
|
||||
let mut cursor_opt = None;
|
||||
if req.surface.is_some() {
|
||||
let surface = self.seat.client.get_surface(req.surface)?;
|
||||
let surface = self.seat.client.lookup(req.surface)?;
|
||||
let cursor = surface.get_cursor(&self.seat.global)?;
|
||||
cursor.set_hotspot(req.hotspot_x, req.hotspot_y);
|
||||
cursor_opt = Some(cursor as Rc<dyn Cursor>);
|
||||
|
|
@ -176,33 +176,19 @@ impl WlPointer {
|
|||
self.seat.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlPointerError> {
|
||||
match request {
|
||||
SET_CURSOR => self.set_cursor(parser)?,
|
||||
RELEASE => self.release(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlPointer);
|
||||
object_base! {
|
||||
WlPointer, WlPointerError;
|
||||
|
||||
SET_CURSOR => set_cursor,
|
||||
RELEASE => release,
|
||||
}
|
||||
|
||||
impl Object for WlPointer {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlPointer
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
RELEASE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlPointer);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
mod types;
|
||||
|
||||
use crate::ifs::wl_seat::WlSeatObj;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -27,11 +27,11 @@ id!(WlTouchId);
|
|||
|
||||
pub struct WlTouch {
|
||||
id: WlTouchId,
|
||||
seat: Rc<WlSeatObj>,
|
||||
seat: Rc<WlSeat>,
|
||||
}
|
||||
|
||||
impl WlTouch {
|
||||
pub fn new(id: WlTouchId, seat: &Rc<WlSeatObj>) -> Self {
|
||||
pub fn new(id: WlTouchId, seat: &Rc<WlSeat>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
seat: seat.clone(),
|
||||
|
|
@ -43,28 +43,18 @@ impl WlTouch {
|
|||
self.seat.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(&self, request: u32, parser: MsgParser<'_, '_>) -> Result<(), WlTouchError> {
|
||||
match request {
|
||||
RELEASE => self.release(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlTouch);
|
||||
object_base! {
|
||||
WlTouch, WlTouchError;
|
||||
|
||||
RELEASE => release,
|
||||
}
|
||||
|
||||
impl Object for WlTouch {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlTouch
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
RELEASE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlTouch);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::client::Client;
|
|||
use crate::format::FORMATS;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_shm_pool::WlShmPool;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -19,7 +19,7 @@ pub struct WlShmGlobal {
|
|||
name: GlobalName,
|
||||
}
|
||||
|
||||
pub struct WlShmObj {
|
||||
pub struct WlShm {
|
||||
_global: Rc<WlShmGlobal>,
|
||||
id: WlShmId,
|
||||
client: Rc<Client>,
|
||||
|
|
@ -36,7 +36,7 @@ impl WlShmGlobal {
|
|||
client: &Rc<Client>,
|
||||
_version: u32,
|
||||
) -> Result<(), WlShmError> {
|
||||
let obj = Rc::new(WlShmObj {
|
||||
let obj = Rc::new(WlShm {
|
||||
_global: self,
|
||||
id,
|
||||
client: client.clone(),
|
||||
|
|
@ -52,7 +52,7 @@ impl WlShmGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
impl WlShmObj {
|
||||
impl WlShm {
|
||||
fn create_pool(&self, parser: MsgParser<'_, '_>) -> Result<(), CreatePoolError> {
|
||||
let create: CreatePool = self.client.parse(self, parser)?;
|
||||
if create.size < 0 {
|
||||
|
|
@ -67,14 +67,6 @@ impl WlShmObj {
|
|||
self.client.add_client_obj(&pool)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(&self, request: u32, parser: MsgParser<'_, '_>) -> Result<(), WlShmError> {
|
||||
match request {
|
||||
CREATE_POOL => self.create_pool(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
bind!(WlShmGlobal);
|
||||
|
|
@ -97,18 +89,18 @@ impl Global for WlShmGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(WlShmObj);
|
||||
simple_add_global!(WlShmGlobal);
|
||||
|
||||
impl Object for WlShmObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
object_base! {
|
||||
WlShm, WlShmError;
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlShm
|
||||
}
|
||||
CREATE_POOL => create_pool,
|
||||
}
|
||||
|
||||
impl Object for WlShm {
|
||||
fn num_requests(&self) -> u32 {
|
||||
CREATE_POOL + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlShm);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::format::Format;
|
||||
use crate::ifs::wl_shm::{WlShmObj, FORMAT};
|
||||
use crate::ifs::wl_shm::{WlShm, FORMAT};
|
||||
use crate::ifs::wl_shm_pool::{WlShmPoolError, WlShmPoolId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
|
|
@ -60,7 +60,7 @@ impl Debug for CreatePool {
|
|||
}
|
||||
|
||||
pub(super) struct FormatE {
|
||||
pub obj: Rc<WlShmObj>,
|
||||
pub obj: Rc<WlShm>,
|
||||
pub format: &'static Format,
|
||||
}
|
||||
impl EventFormatter for FormatE {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::client::Client;
|
|||
use crate::clientmem::ClientMem;
|
||||
use crate::format::{formats, map_wayland_format_id};
|
||||
use crate::ifs::wl_buffer::WlBuffer;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -81,34 +81,20 @@ impl WlShmPool {
|
|||
.set(Rc::new(ClientMem::new(self.fd.raw(), req.size as usize)?));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlShmPoolError> {
|
||||
match request {
|
||||
CREATE_BUFFER => self.create_buffer(parser)?,
|
||||
DESTROY => self.destroy(parser)?,
|
||||
RESIZE => self.resize(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlShmPool);
|
||||
object_base! {
|
||||
WlShmPool, WlShmPoolError;
|
||||
|
||||
CREATE_BUFFER => create_buffer,
|
||||
DESTROY => destroy,
|
||||
RESIZE => resize,
|
||||
}
|
||||
|
||||
impl Object for WlShmPool {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlShmPool
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
RESIZE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlShmPool);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ mod types;
|
|||
use crate::client::Client;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_surface::wl_subsurface::WlSubsurface;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -20,7 +20,7 @@ pub struct WlSubcompositorGlobal {
|
|||
name: GlobalName,
|
||||
}
|
||||
|
||||
pub struct WlSubcompositorObj {
|
||||
pub struct WlSubcompositor {
|
||||
id: WlSubcompositorId,
|
||||
client: Rc<Client>,
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ impl WlSubcompositorGlobal {
|
|||
client: &Rc<Client>,
|
||||
_version: u32,
|
||||
) -> Result<(), WlSubcompositorError> {
|
||||
let obj = Rc::new(WlSubcompositorObj {
|
||||
let obj = Rc::new(WlSubcompositor {
|
||||
id,
|
||||
client: client.clone(),
|
||||
});
|
||||
|
|
@ -45,7 +45,7 @@ impl WlSubcompositorGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
impl WlSubcompositorObj {
|
||||
impl WlSubcompositor {
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
|
|
@ -54,26 +54,13 @@ impl WlSubcompositorObj {
|
|||
|
||||
fn get_subsurface(&self, parser: MsgParser<'_, '_>) -> Result<(), GetSubsurfaceError> {
|
||||
let req: GetSubsurface = self.client.parse(self, parser)?;
|
||||
let surface = self.client.get_surface(req.surface)?;
|
||||
let parent = self.client.get_surface(req.parent)?;
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let parent = self.client.lookup(req.parent)?;
|
||||
let subsurface = Rc::new(WlSubsurface::new(req.id, &surface, &parent));
|
||||
self.client.add_client_obj(&subsurface)?;
|
||||
subsurface.install()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlSubcompositorError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
GET_SUBSURFACE => self.get_subsurface(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
bind!(WlSubcompositorGlobal);
|
||||
|
|
@ -96,18 +83,19 @@ impl Global for WlSubcompositorGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(WlSubcompositorObj);
|
||||
simple_add_global!(WlSubcompositorGlobal);
|
||||
|
||||
impl Object for WlSubcompositorObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
object_base! {
|
||||
WlSubcompositor, WlSubcompositorError;
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlSubcompositor
|
||||
}
|
||||
DESTROY => destroy,
|
||||
GET_SUBSURFACE => get_subsurface,
|
||||
}
|
||||
|
||||
impl Object for WlSubcompositor {
|
||||
fn num_requests(&self) -> u32 {
|
||||
GET_SUBSURFACE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlSubcompositor);
|
||||
|
|
|
|||
|
|
@ -13,13 +13,11 @@ use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
|||
use crate::ifs::wl_surface::cursor::CursorSurface;
|
||||
use crate::ifs::wl_surface::wl_subsurface::WlSubsurface;
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceRole};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::pixman::Region;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::{
|
||||
Node, NodeId,
|
||||
};
|
||||
use crate::tree::{Node, NodeId};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
|
|
@ -351,7 +349,7 @@ impl WlSurface {
|
|||
fn attach(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), AttachError> {
|
||||
let req: Attach = self.parse(parser)?;
|
||||
let buf = if req.buffer.is_some() {
|
||||
Some((req.x, req.y, self.client.get_buffer(req.buffer)?))
|
||||
Some((req.x, req.y, self.client.lookup(req.buffer)?))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -375,7 +373,7 @@ impl WlSurface {
|
|||
fn set_opaque_region(&self, parser: MsgParser<'_, '_>) -> Result<(), SetOpaqueRegionError> {
|
||||
let region: SetOpaqueRegion = self.parse(parser)?;
|
||||
let region = if region.region.is_some() {
|
||||
Some(self.client.get_region(region.region)?.region())
|
||||
Some(self.client.lookup(region.region)?.region())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -386,7 +384,7 @@ impl WlSurface {
|
|||
fn set_input_region(&self, parser: MsgParser<'_, '_>) -> Result<(), SetInputRegionError> {
|
||||
let req: SetInputRegion = self.parse(parser)?;
|
||||
let region = if req.region.is_some() {
|
||||
Some(self.client.get_region(req.region)?.region())
|
||||
Some(self.client.lookup(req.region)?.region())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -491,27 +489,6 @@ impl WlSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlSurfaceError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
ATTACH => self.attach(parser)?,
|
||||
DAMAGE => self.damage(parser)?,
|
||||
FRAME => self.frame(parser)?,
|
||||
SET_OPAQUE_REGION => self.set_opaque_region(parser)?,
|
||||
SET_INPUT_REGION => self.set_input_region(parser)?,
|
||||
COMMIT => self.commit(parser)?,
|
||||
SET_BUFFER_TRANSFORM => self.set_buffer_transform(parser)?,
|
||||
SET_BUFFER_SCALE => self.set_buffer_scale(parser)?,
|
||||
DAMAGE_BUFFER => self.damage_buffer(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn find_surface_at(self: &Rc<Self>, x: i32, y: i32) -> Option<(Rc<Self>, i32, i32)> {
|
||||
let buffer = match self.buffer.get() {
|
||||
Some(b) => b,
|
||||
|
|
@ -556,17 +533,22 @@ impl WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(WlSurface);
|
||||
object_base! {
|
||||
WlSurface, WlSurfaceError;
|
||||
|
||||
DESTROY => destroy,
|
||||
ATTACH => attach,
|
||||
DAMAGE => damage,
|
||||
FRAME => frame,
|
||||
SET_OPAQUE_REGION => set_opaque_region,
|
||||
SET_INPUT_REGION => set_input_region,
|
||||
COMMIT => commit,
|
||||
SET_BUFFER_TRANSFORM => set_buffer_transform,
|
||||
SET_BUFFER_SCALE => set_buffer_scale,
|
||||
DAMAGE_BUFFER => damage_buffer,
|
||||
}
|
||||
|
||||
impl Object for WlSurface {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlSurface
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
DAMAGE_BUFFER + 1
|
||||
}
|
||||
|
|
@ -582,6 +564,8 @@ impl Object for WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(WlSurface, WlSurfaceId, surfaces);
|
||||
|
||||
tree_id!(SurfaceNodeId);
|
||||
impl Node for WlSurface {
|
||||
fn id(&self) -> NodeId {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::ifs::wl_surface::{
|
|||
CommitAction, CommitContext, StackElement, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
WlSurfaceId,
|
||||
};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::linkedlist::LinkedNode;
|
||||
|
|
@ -237,41 +237,27 @@ impl WlSubsurface {
|
|||
self.update_sync(false);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlSubsurfaceError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
SET_POSITION => self.set_position(parser)?,
|
||||
PLACE_ABOVE => self.place_above(parser)?,
|
||||
PLACE_BELOW => self.place_below(parser)?,
|
||||
SET_SYNC => self.set_sync(parser)?,
|
||||
SET_DESYNC => self.set_desync(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(WlSubsurface);
|
||||
object_base! {
|
||||
WlSubsurface, WlSubsurfaceError;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_POSITION => set_position,
|
||||
PLACE_ABOVE => place_above,
|
||||
PLACE_BELOW => place_below,
|
||||
SET_SYNC => set_sync,
|
||||
SET_DESYNC => set_desync,
|
||||
}
|
||||
|
||||
impl Object for WlSubsurface {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::WlSubsurface
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
SET_DESYNC + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WlSubsurface);
|
||||
|
||||
impl SurfaceExt for WlSubsurface {
|
||||
fn pre_commit(self: Rc<Self>, ctx: CommitContext) -> Result<CommitAction, WlSurfaceError> {
|
||||
if ctx == CommitContext::RootCommit && self.sync() {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
|||
use crate::ifs::wl_surface::{
|
||||
CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
};
|
||||
use crate::ifs::xdg_wm_base::XdgWmBaseObj;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::ifs::xdg_wm_base::XdgWmBase;
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::tree::{FindTreeResult, FoundNode, Node, WorkspaceNode};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
|
|
@ -58,7 +58,7 @@ id!(XdgSurfaceId);
|
|||
|
||||
pub struct XdgSurface {
|
||||
id: XdgSurfaceId,
|
||||
base: Rc<XdgWmBaseObj>,
|
||||
base: Rc<XdgWmBase>,
|
||||
role: Cell<XdgSurfaceRole>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
requested_serial: NumCell<u32>,
|
||||
|
|
@ -102,7 +102,7 @@ trait XdgSurfaceExt {
|
|||
}
|
||||
|
||||
impl XdgSurface {
|
||||
pub fn new(wm_base: &Rc<XdgWmBaseObj>, id: XdgSurfaceId, surface: &Rc<WlSurface>) -> Self {
|
||||
pub fn new(wm_base: &Rc<XdgWmBase>, id: XdgSurfaceId, surface: &Rc<WlSurface>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
base: wm_base.clone(),
|
||||
|
|
@ -254,9 +254,9 @@ impl XdgSurface {
|
|||
self.set_role(XdgSurfaceRole::XdgPopup)?;
|
||||
let mut parent = None;
|
||||
if req.parent.is_some() {
|
||||
parent = Some(self.surface.client.get_xdg_surface(req.parent)?);
|
||||
parent = Some(self.surface.client.lookup(req.parent)?);
|
||||
}
|
||||
let positioner = self.surface.client.get_xdg_positioner(req.positioner)?;
|
||||
let positioner = self.surface.client.lookup(req.positioner)?;
|
||||
if self.ext.get().is_some() {
|
||||
self.surface.client.protocol_error(
|
||||
&**self,
|
||||
|
|
@ -295,22 +295,6 @@ impl XdgSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgSurfaceError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
GET_TOPLEVEL => self.get_toplevel(parser)?,
|
||||
GET_POPUP => self.get_popup(parser)?,
|
||||
SET_WINDOW_GEOMETRY => self.set_window_geometry(parser)?,
|
||||
ACK_CONFIGURE => self.ack_configure(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_extents(&self) {
|
||||
let old_extents = self.extents.get();
|
||||
let mut new_extents = self.surface.extents.get();
|
||||
|
|
@ -348,17 +332,17 @@ impl XdgSurface {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(XdgSurface);
|
||||
object_base! {
|
||||
XdgSurface, XdgSurfaceError;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_TOPLEVEL => get_toplevel,
|
||||
GET_POPUP => get_popup,
|
||||
SET_WINDOW_GEOMETRY => set_window_geometry,
|
||||
ACK_CONFIGURE => ack_configure,
|
||||
}
|
||||
|
||||
impl Object for XdgSurface {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::XdgSurface
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
ACK_CONFIGURE + 1
|
||||
}
|
||||
|
|
@ -368,6 +352,8 @@ impl Object for XdgSurface {
|
|||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(XdgSurface, XdgSurfaceId, xdg_surfaces);
|
||||
|
||||
impl SurfaceExt for XdgSurface {
|
||||
fn pre_commit(self: Rc<Self>, _ctx: CommitContext) -> Result<CommitAction, WlSurfaceError> {
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::fixed::Fixed;
|
|||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt};
|
||||
use crate::ifs::xdg_positioner::{XdgPositioned, XdgPositioner, CA};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
|
||||
|
|
@ -208,12 +208,7 @@ impl XdgPopup {
|
|||
|
||||
fn reposition(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), RepositionError> {
|
||||
let req: Reposition = self.xdg.surface.client.parse(&**self, parser)?;
|
||||
*self.pos.borrow_mut() = self
|
||||
.xdg
|
||||
.surface
|
||||
.client
|
||||
.get_xdg_positioner(req.positioner)?
|
||||
.value();
|
||||
*self.pos.borrow_mut() = self.xdg.surface.client.lookup(req.positioner)?.value();
|
||||
if let Some(parent) = self.parent.get() {
|
||||
self.update_position(&parent)?;
|
||||
let rel = self.relative_position.get();
|
||||
|
|
@ -234,7 +229,7 @@ impl XdgPopup {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request! {
|
||||
object_base! {
|
||||
XdgPopup, XdgPopupError;
|
||||
|
||||
DESTROY => destroy,
|
||||
|
|
@ -243,14 +238,6 @@ handle_request! {
|
|||
}
|
||||
|
||||
impl Object for XdgPopup {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::XdgPopup
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
let last_req = match self.xdg.base.version {
|
||||
0..=2 => GRAB,
|
||||
|
|
@ -267,6 +254,8 @@ impl Object for XdgPopup {
|
|||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(XdgPopup);
|
||||
|
||||
impl Node for XdgPopup {
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::cursor::KnownCursor;
|
|||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::{ContainerNode, FindTreeResult};
|
||||
|
|
@ -200,7 +200,7 @@ impl XdgToplevel {
|
|||
let req: SetParent = self.xdg.surface.client.parse(self, parser)?;
|
||||
let mut parent = None;
|
||||
if req.parent.is_some() {
|
||||
parent = Some(self.xdg.surface.client.get_xdg_toplevel(req.parent)?);
|
||||
parent = Some(self.xdg.surface.client.lookup(req.parent)?);
|
||||
}
|
||||
self.parent.set(parent);
|
||||
Ok(())
|
||||
|
|
@ -226,7 +226,7 @@ impl XdgToplevel {
|
|||
|
||||
fn move_(&self, parser: MsgParser<'_, '_>) -> Result<(), MoveError> {
|
||||
let req: Move = self.xdg.surface.client.parse(self, parser)?;
|
||||
let seat = self.xdg.surface.client.get_wl_seat(req.seat)?;
|
||||
let seat = self.xdg.surface.client.lookup(req.seat)?;
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if let Some(float) = parent.into_float() {
|
||||
seat.move_(&float);
|
||||
|
|
@ -301,31 +301,6 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgToplevelError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
SET_PARENT => self.set_parent(parser)?,
|
||||
SET_TITLE => self.set_title(parser)?,
|
||||
SET_APP_ID => self.set_app_id(parser)?,
|
||||
SHOW_WINDOW_MENU => self.show_window_menu(parser)?,
|
||||
MOVE => self.move_(parser)?,
|
||||
RESIZE => self.resize(parser)?,
|
||||
SET_MAX_SIZE => self.set_max_size(parser)?,
|
||||
SET_MIN_SIZE => self.set_min_size(parser)?,
|
||||
SET_MAXIMIZED => self.set_maximized(parser)?,
|
||||
UNSET_MAXIMIZED => self.unset_maximized(parser)?,
|
||||
SET_FULLSCREEN => self.set_fullscreen(parser)?,
|
||||
UNSET_FULLSCREEN => self.unset_fullscreen(parser)?,
|
||||
SET_MINIMIZED => self.set_minimized(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn map_child(self: &Rc<Self>, parent: &XdgToplevel) {
|
||||
let workspace = match parent.xdg.workspace.get() {
|
||||
Some(w) => w,
|
||||
|
|
@ -412,17 +387,26 @@ impl XdgToplevel {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(XdgToplevel);
|
||||
object_base! {
|
||||
XdgToplevel, XdgToplevelError;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_PARENT => set_parent,
|
||||
SET_TITLE => set_title,
|
||||
SET_APP_ID => set_app_id,
|
||||
SHOW_WINDOW_MENU => show_window_menu,
|
||||
MOVE => move_,
|
||||
RESIZE => resize,
|
||||
SET_MAX_SIZE => set_max_size,
|
||||
SET_MIN_SIZE => set_min_size,
|
||||
SET_MAXIMIZED => set_maximized,
|
||||
UNSET_MAXIMIZED => unset_maximized,
|
||||
SET_FULLSCREEN => set_fullscreen,
|
||||
UNSET_FULLSCREEN => unset_fullscreen,
|
||||
SET_MINIMIZED => set_minimized,
|
||||
}
|
||||
|
||||
impl Object for XdgToplevel {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::XdgToplevel
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
SET_MINIMIZED + 1
|
||||
}
|
||||
|
|
@ -437,6 +421,8 @@ impl Object for XdgToplevel {
|
|||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(XdgToplevel, XdgToplevelId, xdg_toplevel);
|
||||
|
||||
impl Node for XdgToplevel {
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::ifs::xdg_wm_base::XdgWmBaseObj;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::ifs::xdg_wm_base::XdgWmBase;
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use bitflags::bitflags;
|
||||
|
|
@ -78,7 +78,7 @@ id!(XdgPositionerId);
|
|||
|
||||
pub struct XdgPositioner {
|
||||
id: XdgPositionerId,
|
||||
base: Rc<XdgWmBaseObj>,
|
||||
base: Rc<XdgWmBase>,
|
||||
client: Rc<Client>,
|
||||
position: RefCell<XdgPositioned>,
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ impl XdgPositioned {
|
|||
}
|
||||
|
||||
impl XdgPositioner {
|
||||
pub fn new(base: &Rc<XdgWmBaseObj>, id: XdgPositionerId, client: &Rc<Client>) -> Self {
|
||||
pub fn new(base: &Rc<XdgWmBase>, id: XdgPositionerId, client: &Rc<Client>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
client: client.clone(),
|
||||
|
|
@ -277,40 +277,24 @@ impl XdgPositioner {
|
|||
self.position.borrow_mut().parent_serial = req.serial;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
&self,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgPositionerError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
SET_SIZE => self.set_size(parser)?,
|
||||
SET_ANCHOR_RECT => self.set_anchor_rect(parser)?,
|
||||
SET_ANCHOR => self.set_anchor(parser)?,
|
||||
SET_GRAVITY => self.set_gravity(parser)?,
|
||||
SET_CONSTRAINT_ADJUSTMENT => self.set_constraint_adjustment(parser)?,
|
||||
SET_OFFSET => self.set_offset(parser)?,
|
||||
SET_REACTIVE => self.set_reactive(parser)?,
|
||||
SET_PARENT_SIZE => self.set_parent_size(parser)?,
|
||||
SET_PARENT_CONFIGURE => self.set_parent_configure(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(XdgPositioner);
|
||||
object_base! {
|
||||
XdgPositioner, XdgPositionerError;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_SIZE => set_size,
|
||||
SET_ANCHOR_RECT => set_anchor_rect,
|
||||
SET_ANCHOR => set_anchor,
|
||||
SET_GRAVITY => set_gravity,
|
||||
SET_CONSTRAINT_ADJUSTMENT => set_constraint_adjustment,
|
||||
SET_OFFSET => set_offset,
|
||||
SET_REACTIVE => set_reactive,
|
||||
SET_PARENT_SIZE => set_parent_size,
|
||||
SET_PARENT_CONFIGURE => set_parent_configure,
|
||||
}
|
||||
|
||||
impl Object for XdgPositioner {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::XdgPositioner
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
if self.base.version < 3 {
|
||||
SET_OFFSET + 1
|
||||
|
|
@ -319,3 +303,5 @@ impl Object for XdgPositioner {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(XdgPositioner, XdgPositionerId, xdg_positioners);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::client::Client;
|
|||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceId};
|
||||
use crate::ifs::xdg_positioner::XdgPositioner;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::copyhashmap::CopyHashMap;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -35,7 +35,7 @@ pub struct XdgWmBaseGlobal {
|
|||
name: GlobalName,
|
||||
}
|
||||
|
||||
pub struct XdgWmBaseObj {
|
||||
pub struct XdgWmBase {
|
||||
id: XdgWmBaseId,
|
||||
client: Rc<Client>,
|
||||
pub version: u32,
|
||||
|
|
@ -53,7 +53,7 @@ impl XdgWmBaseGlobal {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), XdgWmBaseError> {
|
||||
let obj = Rc::new(XdgWmBaseObj {
|
||||
let obj = Rc::new(XdgWmBase {
|
||||
id,
|
||||
client: client.clone(),
|
||||
version,
|
||||
|
|
@ -64,7 +64,7 @@ impl XdgWmBaseGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
impl XdgWmBaseObj {
|
||||
impl XdgWmBase {
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
if !self.surfaces.is_empty() {
|
||||
|
|
@ -97,7 +97,7 @@ impl XdgWmBaseObj {
|
|||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), GetXdgSurfaceError> {
|
||||
let req: GetXdgSurface = self.client.parse(&**self, parser)?;
|
||||
let surface = self.client.get_surface(req.surface)?;
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let xdg_surface = Rc::new(XdgSurface::new(self, req.id, &surface));
|
||||
self.client.add_client_obj(&xdg_surface)?;
|
||||
xdg_surface.install()?;
|
||||
|
|
@ -109,21 +109,6 @@ impl XdgWmBaseObj {
|
|||
let _req: Pong = self.client.parse(self, parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgWmBaseError> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
CREATE_POSITIONER => self.create_positioner(parser)?,
|
||||
GET_XDG_SURFACE => self.get_xdg_surface(parser)?,
|
||||
PONG => self.pong(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
bind!(XdgWmBaseGlobal);
|
||||
|
|
@ -146,17 +131,20 @@ impl Global for XdgWmBaseGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
handle_request!(XdgWmBaseObj);
|
||||
simple_add_global!(XdgWmBaseGlobal);
|
||||
|
||||
impl Object for XdgWmBaseObj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
object_base! {
|
||||
XdgWmBase, XdgWmBaseError;
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::XdgWmBase
|
||||
}
|
||||
DESTROY => destroy,
|
||||
CREATE_POSITIONER => create_positioner,
|
||||
GET_XDG_SURFACE => get_xdg_surface,
|
||||
PONG => pong,
|
||||
}
|
||||
|
||||
dedicated_add_obj!(XdgWmBase, XdgWmBaseId, xdg_wm_bases);
|
||||
|
||||
impl Object for XdgWmBase {
|
||||
fn num_requests(&self) -> u32 {
|
||||
PONG + 1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::client::{ClientError, EventFormatter, RequestParser};
|
|||
use crate::ifs::wl_surface::xdg_surface::{XdgSurfaceError, XdgSurfaceId};
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
use crate::ifs::xdg_positioner::XdgPositionerId;
|
||||
use crate::ifs::xdg_wm_base::{XdgWmBaseObj, PING};
|
||||
use crate::ifs::xdg_wm_base::{XdgWmBase, PING};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
|
@ -133,7 +133,7 @@ impl Debug for Pong {
|
|||
}
|
||||
|
||||
pub(super) struct Ping {
|
||||
pub obj: Rc<XdgWmBaseObj>,
|
||||
pub obj: Rc<XdgWmBase>,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl EventFormatter for Ping {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use crate::client::DynEventFormatter;
|
|||
use crate::drm::dma::{DmaBuf, DmaBufPlane};
|
||||
use crate::drm::INVALID_MODIFIER;
|
||||
use crate::ifs::wl_buffer::{WlBuffer, WlBufferId};
|
||||
use crate::ifs::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1Obj;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::ifs::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::ErrorFmt;
|
||||
use ahash::AHashMap;
|
||||
|
|
@ -34,13 +34,13 @@ const MAX_PLANE: u32 = 3;
|
|||
|
||||
pub struct ZwpLinuxBufferParamsV1 {
|
||||
id: ZwpLinuxBufferParamsV1Id,
|
||||
parent: Rc<ZwpLinuxDmabufV1Obj>,
|
||||
parent: Rc<ZwpLinuxDmabufV1>,
|
||||
planes: RefCell<AHashMap<u32, Add>>,
|
||||
used: Cell<bool>,
|
||||
}
|
||||
|
||||
impl ZwpLinuxBufferParamsV1 {
|
||||
pub fn new(id: ZwpLinuxBufferParamsV1Id, parent: &Rc<ZwpLinuxDmabufV1Obj>) -> Self {
|
||||
pub fn new(id: ZwpLinuxBufferParamsV1Id, parent: &Rc<ZwpLinuxDmabufV1>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
parent: parent.clone(),
|
||||
|
|
@ -168,35 +168,21 @@ impl ZwpLinuxBufferParamsV1 {
|
|||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpLinuxBufferParamsV1Error> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
ADD => self.add(parser)?,
|
||||
CREATE => self.create(parser)?,
|
||||
CREATE_IMMED => self.create_immed(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(ZwpLinuxBufferParamsV1);
|
||||
object_base! {
|
||||
ZwpLinuxBufferParamsV1, ZwpLinuxBufferParamsV1Error;
|
||||
|
||||
DESTROY => destroy,
|
||||
ADD => add,
|
||||
CREATE => create,
|
||||
CREATE_IMMED => create_immed,
|
||||
}
|
||||
|
||||
impl Object for ZwpLinuxBufferParamsV1 {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::ZwpLinuxBufferParamsV1
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
CREATE_IMMED + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpLinuxBufferParamsV1);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::client::{Client, DynEventFormatter};
|
|||
use crate::drm::INVALID_MODIFIER;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -32,7 +32,7 @@ impl ZwpLinuxDmabufV1Global {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), ZwpLinuxDmabufV1Error> {
|
||||
let obj = Rc::new(ZwpLinuxDmabufV1Obj {
|
||||
let obj = Rc::new(ZwpLinuxDmabufV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
_version: version,
|
||||
|
|
@ -73,13 +73,15 @@ impl Global for ZwpLinuxDmabufV1Global {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct ZwpLinuxDmabufV1Obj {
|
||||
simple_add_global!(ZwpLinuxDmabufV1Global);
|
||||
|
||||
pub struct ZwpLinuxDmabufV1 {
|
||||
id: ZwpLinuxDmabufV1Id,
|
||||
pub client: Rc<Client>,
|
||||
_version: u32,
|
||||
}
|
||||
|
||||
impl ZwpLinuxDmabufV1Obj {
|
||||
impl ZwpLinuxDmabufV1 {
|
||||
fn format(self: &Rc<Self>, format: u32) -> DynEventFormatter {
|
||||
Box::new(Format {
|
||||
obj: self.clone(),
|
||||
|
|
@ -107,33 +109,19 @@ impl ZwpLinuxDmabufV1Obj {
|
|||
self.client.add_client_obj(¶ms)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpLinuxDmabufV1Error> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
CREATE_PARAMS => self.create_params(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(ZwpLinuxDmabufV1Obj);
|
||||
object_base! {
|
||||
ZwpLinuxDmabufV1, ZwpLinuxDmabufV1Error;
|
||||
|
||||
impl Object for ZwpLinuxDmabufV1Obj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::ZwpLinuxDmabufV1
|
||||
}
|
||||
DESTROY => destroy,
|
||||
CREATE_PARAMS => create_params,
|
||||
}
|
||||
|
||||
impl Object for ZwpLinuxDmabufV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
CREATE_PARAMS + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpLinuxDmabufV1);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1Id;
|
||||
use crate::ifs::zwp_linux_dmabuf_v1::{ZwpLinuxDmabufV1Obj, FORMAT, MODIFIER};
|
||||
use crate::ifs::zwp_linux_dmabuf_v1::{ZwpLinuxDmabufV1, FORMAT, MODIFIER};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
|
@ -67,7 +67,7 @@ impl Debug for CreateParams {
|
|||
}
|
||||
|
||||
pub(super) struct Format {
|
||||
pub obj: Rc<ZwpLinuxDmabufV1Obj>,
|
||||
pub obj: Rc<ZwpLinuxDmabufV1>,
|
||||
pub format: u32,
|
||||
}
|
||||
impl EventFormatter for Format {
|
||||
|
|
@ -85,7 +85,7 @@ impl Debug for Format {
|
|||
}
|
||||
|
||||
pub(super) struct Modifier {
|
||||
pub obj: Rc<ZwpLinuxDmabufV1Obj>,
|
||||
pub obj: Rc<ZwpLinuxDmabufV1>,
|
||||
pub format: u32,
|
||||
pub modifier: u64,
|
||||
}
|
||||
|
|
|
|||
109
src/ifs/zwp_primary_selection_device_manager_v1/mod.rs
Normal file
109
src/ifs/zwp_primary_selection_device_manager_v1/mod.rs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1;
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const CREATE_SOURCE: u32 = 0;
|
||||
const GET_DEVICE: u32 = 1;
|
||||
const DESTROY: u32 = 2;
|
||||
|
||||
id!(ZwpPrimarySelectionDeviceManagerV1Id);
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceManagerV1Global {
|
||||
name: GlobalName,
|
||||
}
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceManagerV1 {
|
||||
pub id: ZwpPrimarySelectionDeviceManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionDeviceManagerV1Global {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: ZwpPrimarySelectionDeviceManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let obj = Rc::new(ZwpPrimarySelectionDeviceManagerV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
version,
|
||||
});
|
||||
client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionDeviceManagerV1 {
|
||||
fn create_source(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateSourceError> {
|
||||
let req: CreateSource = self.client.parse(self, parser)?;
|
||||
let res = Rc::new(ZwpPrimarySelectionSourceV1::new(req.id, &self.client));
|
||||
self.client.add_client_obj(&res)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_data_device(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), GetDeviceError> {
|
||||
let req: GetDevice = self.client.parse(&**self, parser)?;
|
||||
let seat = self.client.lookup(req.seat)?;
|
||||
let dev = Rc::new(ZwpPrimarySelectionDeviceV1::new(req.id, self, &seat));
|
||||
seat.add_primary_selection_device(&dev);
|
||||
self.client.add_client_obj(&dev)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
bind!(ZwpPrimarySelectionDeviceManagerV1Global);
|
||||
|
||||
impl Global for ZwpPrimarySelectionDeviceManagerV1Global {
|
||||
fn name(&self) -> GlobalName {
|
||||
self.name
|
||||
}
|
||||
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::ZwpPrimarySelectionDeviceManagerV1
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(ZwpPrimarySelectionDeviceManagerV1Global);
|
||||
|
||||
object_base! {
|
||||
ZwpPrimarySelectionDeviceManagerV1, ZwpPrimarySelectionDeviceManagerV1Error;
|
||||
|
||||
CREATE_SOURCE => create_source,
|
||||
GET_DEVICE => get_data_device,
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionDeviceManagerV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpPrimarySelectionDeviceManagerV1);
|
||||
96
src/ifs/zwp_primary_selection_device_manager_v1/types.rs
Normal file
96
src/ifs/zwp_primary_selection_device_manager_v1/types.rs
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
use crate::client::{ClientError, RequestParser};
|
||||
use crate::ifs::wl_seat::WlSeatId;
|
||||
use crate::ifs::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1Id;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1Id;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionDeviceManagerV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("Could not process `create_source` request")]
|
||||
CreateSourceError(#[from] CreateSourceError),
|
||||
#[error("Could not process `get_device` request")]
|
||||
GetDeviceError(#[from] GetDeviceError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceManagerV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CreateSourceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(CreateSourceError, ParseFailed, MsgParserError);
|
||||
efrom!(CreateSourceError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GetDeviceError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(GetDeviceError, ParseFailed, MsgParserError);
|
||||
efrom!(GetDeviceError, ClientError);
|
||||
|
||||
pub(super) struct CreateSource {
|
||||
pub id: ZwpPrimarySelectionSourceV1Id,
|
||||
}
|
||||
impl RequestParser<'_> for CreateSource {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for CreateSource {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "create_source(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct GetDevice {
|
||||
pub id: ZwpPrimarySelectionDeviceV1Id,
|
||||
pub seat: WlSeatId,
|
||||
}
|
||||
impl RequestParser<'_> for GetDevice {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
id: parser.object()?,
|
||||
seat: parser.object()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for GetDevice {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "get_device(id: {}, seat: {})", self.id, self.seat,)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
89
src/ifs/zwp_primary_selection_device_v1/mod.rs
Normal file
89
src/ifs/zwp_primary_selection_device_v1/mod.rs
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::ifs::wl_seat::WlSeat;
|
||||
use crate::ifs::zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1;
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const SET_SELECTION: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
|
||||
const DATA_OFFER: u32 = 0;
|
||||
const SELECTION: u32 = 1;
|
||||
|
||||
id!(ZwpPrimarySelectionDeviceV1Id);
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceV1 {
|
||||
pub id: ZwpPrimarySelectionDeviceV1Id,
|
||||
pub manager: Rc<ZwpPrimarySelectionDeviceManagerV1>,
|
||||
seat: Rc<WlSeat>,
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionDeviceV1 {
|
||||
pub fn new(
|
||||
id: ZwpPrimarySelectionDeviceV1Id,
|
||||
manager: &Rc<ZwpPrimarySelectionDeviceManagerV1>,
|
||||
seat: &Rc<WlSeat>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
manager: manager.clone(),
|
||||
seat: seat.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data_offer(self: &Rc<Self>, id: ZwpPrimarySelectionOfferV1Id) -> DynEventFormatter {
|
||||
Box::new(DataOffer {
|
||||
obj: self.clone(),
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn selection(self: &Rc<Self>, id: ZwpPrimarySelectionOfferV1Id) -> DynEventFormatter {
|
||||
Box::new(Selection {
|
||||
obj: self.clone(),
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
||||
fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), SetSelectionError> {
|
||||
let req: SetSelection = self.manager.client.parse(self, parser)?;
|
||||
let src = if req.source.is_none() {
|
||||
None
|
||||
} else {
|
||||
Some(self.manager.client.lookup(req.source)?)
|
||||
};
|
||||
self.seat.global.set_primary_selection(src)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.manager.client.parse(self, parser)?;
|
||||
self.seat.remove_primary_selection_device(self);
|
||||
self.manager.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
ZwpPrimarySelectionDeviceV1, ZwpPrimarySelectionDeviceV1Error;
|
||||
|
||||
SET_SELECTION => set_selection,
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionDeviceV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.seat.remove_primary_selection_device(self);
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpPrimarySelectionDeviceV1);
|
||||
117
src/ifs/zwp_primary_selection_device_v1/types.rs
Normal file
117
src/ifs/zwp_primary_selection_device_v1/types.rs
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_primary_selection_device_v1::{
|
||||
ZwpPrimarySelectionDeviceV1, DATA_OFFER, SELECTION,
|
||||
};
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1Id;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{
|
||||
ZwpPrimarySelectionSourceV1Error, ZwpPrimarySelectionSourceV1Id,
|
||||
};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionDeviceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `set_selection` request")]
|
||||
SetSelectionError(#[from] SetSelectionError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSelectionError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
ZwpPrimarySelectionSourceV1Error(Box<ZwpPrimarySelectionSourceV1Error>),
|
||||
}
|
||||
efrom!(SetSelectionError, ParseFailed, MsgParserError);
|
||||
efrom!(SetSelectionError, ClientError);
|
||||
efrom!(SetSelectionError, ZwpPrimarySelectionSourceV1Error);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
pub(super) struct SetSelection {
|
||||
pub source: ZwpPrimarySelectionSourceV1Id,
|
||||
pub serial: u32,
|
||||
}
|
||||
impl RequestParser<'_> for SetSelection {
|
||||
fn parse(parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
source: parser.object()?,
|
||||
serial: parser.uint()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for SetSelection {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"set_selection(source: {}, serial: {})",
|
||||
self.source, self.serial,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct DataOffer {
|
||||
pub obj: Rc<ZwpPrimarySelectionDeviceV1>,
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
}
|
||||
impl EventFormatter for DataOffer {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, DATA_OFFER).object(self.id);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for DataOffer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "data_offer(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Selection {
|
||||
pub obj: Rc<ZwpPrimarySelectionDeviceV1>,
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
}
|
||||
impl EventFormatter for Selection {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, SELECTION).object(self.id);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Selection {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "selection(id: {})", self.id)
|
||||
}
|
||||
}
|
||||
103
src/ifs/zwp_primary_selection_offer_v1/mod.rs
Normal file
103
src/ifs/zwp_primary_selection_offer_v1/mod.rs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::ifs::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
||||
const RECEIVE: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
|
||||
const OFFER: u32 = 0;
|
||||
|
||||
id!(ZwpPrimarySelectionOfferV1Id);
|
||||
|
||||
pub struct ZwpPrimarySelectionOfferV1 {
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub source: CloneCell<Option<Rc<ZwpPrimarySelectionSourceV1>>>,
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionOfferV1 {
|
||||
pub fn create(
|
||||
client: &Rc<Client>,
|
||||
src: &Rc<ZwpPrimarySelectionSourceV1>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
) -> Option<Rc<Self>> {
|
||||
let id = match client.new_id() {
|
||||
Ok(id) => id,
|
||||
Err(e) => {
|
||||
client.error(e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let slf = Rc::new(Self {
|
||||
id,
|
||||
client: client.clone(),
|
||||
source: CloneCell::new(Some(src.clone())),
|
||||
});
|
||||
let mt = src.mime_types.borrow_mut();
|
||||
seat.for_each_primary_selection_device(0, client.id, |device| {
|
||||
client.event(device.data_offer(slf.id));
|
||||
for mt in mt.deref() {
|
||||
client.event(slf.offer(mt));
|
||||
}
|
||||
client.event(device.selection(id));
|
||||
});
|
||||
client.add_server_obj(&slf);
|
||||
Some(slf)
|
||||
}
|
||||
|
||||
pub fn offer(self: &Rc<Self>, mime_type: &str) -> DynEventFormatter {
|
||||
Box::new(Offer {
|
||||
obj: self.clone(),
|
||||
mime_type: mime_type.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ReceiveError> {
|
||||
let req: Receive = self.client.parse(self, parser)?;
|
||||
if let Some(src) = self.source.get() {
|
||||
src.client.event(src.send(req.mime_type, req.fd));
|
||||
src.client.flush();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn disconnect(&self) {
|
||||
if let Some(src) = self.source.set(None) {
|
||||
src.clear_offer();
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.disconnect();
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
ZwpPrimarySelectionOfferV1, ZwpPrimarySelectionOfferV1Error;
|
||||
|
||||
RECEIVE => receive,
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionOfferV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpPrimarySelectionOfferV1);
|
||||
92
src/ifs/zwp_primary_selection_offer_v1/types.rs
Normal file
92
src/ifs/zwp_primary_selection_offer_v1/types.rs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::{ZwpPrimarySelectionOfferV1, OFFER};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionOfferV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `receive` request")]
|
||||
ReceiveError(#[from] ReceiveError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionOfferV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReceiveError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ReceiveError, ParseFailed, MsgParserError);
|
||||
efrom!(ReceiveError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
pub(super) struct Receive<'a> {
|
||||
pub mime_type: &'a str,
|
||||
pub fd: OwnedFd,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for Receive<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
mime_type: parser.str()?,
|
||||
fd: parser.fd()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Receive<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"receive(mime_type: {:?}, fd: {})",
|
||||
self.mime_type,
|
||||
self.fd.raw()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Offer {
|
||||
pub obj: Rc<ZwpPrimarySelectionOfferV1>,
|
||||
pub mime_type: String,
|
||||
}
|
||||
impl EventFormatter for Offer {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, OFFER).string(&self.mime_type);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Offer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "offer(mime_type: {:?})", self.mime_type)
|
||||
}
|
||||
}
|
||||
142
src/ifs/zwp_primary_selection_source_v1/mod.rs
Normal file
142
src/ifs/zwp_primary_selection_source_v1/mod.rs
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::ifs::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use ahash::AHashSet;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
const OFFER: u32 = 0;
|
||||
const DESTROY: u32 = 1;
|
||||
|
||||
const SEND: u32 = 0;
|
||||
const CANCELLED: u32 = 1;
|
||||
|
||||
id!(ZwpPrimarySelectionSourceV1Id);
|
||||
|
||||
pub struct ZwpPrimarySelectionSourceV1 {
|
||||
pub id: ZwpPrimarySelectionSourceV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub mime_types: RefCell<AHashSet<String>>,
|
||||
seat: CloneCell<Option<Rc<WlSeatGlobal>>>,
|
||||
offer: CloneCell<Option<Rc<ZwpPrimarySelectionOfferV1>>>,
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionSourceV1 {
|
||||
pub fn new(id: ZwpPrimarySelectionSourceV1Id, client: &Rc<Client>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
client: client.clone(),
|
||||
mime_types: RefCell::new(Default::default()),
|
||||
seat: Default::default(),
|
||||
offer: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn attach(&self, seat: &Rc<WlSeatGlobal>) -> Result<(), ZwpPrimarySelectionSourceV1Error> {
|
||||
if self.seat.get().is_some() {
|
||||
return Err(ZwpPrimarySelectionSourceV1Error::AlreadyAttached);
|
||||
}
|
||||
self.seat.set(Some(seat.clone()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn detach(self: &Rc<Self>) {
|
||||
self.seat.set(None);
|
||||
if let Some(offer) = self.offer.set(None) {
|
||||
offer.source.set(None);
|
||||
}
|
||||
self.client.event(self.cancelled());
|
||||
self.client.flush();
|
||||
}
|
||||
|
||||
pub fn create_offer(self: &Rc<Self>, client: &Rc<Client>) {
|
||||
let seat = match self.seat.get() {
|
||||
Some(a) => a,
|
||||
_ => {
|
||||
log::error!("Trying to create an offer from a unattached data source");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let offer = ZwpPrimarySelectionOfferV1::create(client, self, &seat);
|
||||
let old = self.offer.set(offer);
|
||||
if let Some(offer) = old {
|
||||
offer.source.set(None);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_offer(&self) {
|
||||
self.offer.take();
|
||||
}
|
||||
|
||||
pub fn cancelled(self: &Rc<Self>) -> DynEventFormatter {
|
||||
Box::new(Cancelled { obj: self.clone() })
|
||||
}
|
||||
|
||||
pub fn send(self: &Rc<Self>, mime_type: &str, fd: OwnedFd) -> DynEventFormatter {
|
||||
Box::new(Send {
|
||||
obj: self.clone(),
|
||||
mime_type: mime_type.to_string(),
|
||||
fd: Rc::new(fd),
|
||||
})
|
||||
}
|
||||
|
||||
fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), OfferError> {
|
||||
let req: Offer = self.client.parse(self, parser)?;
|
||||
if self
|
||||
.mime_types
|
||||
.borrow_mut()
|
||||
.insert(req.mime_type.to_string())
|
||||
{
|
||||
if let Some(offer) = self.offer.get() {
|
||||
offer.client.event(offer.offer(req.mime_type));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn disconnect(&self) {
|
||||
if let Some(offer) = self.offer.take() {
|
||||
offer.source.set(None);
|
||||
}
|
||||
if let Some(seat) = self.seat.get() {
|
||||
let _ = seat.set_primary_selection(None);
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.disconnect();
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
ZwpPrimarySelectionSourceV1, ZwpPrimarySelectionSourceV1Error;
|
||||
|
||||
OFFER => offer,
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionSourceV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(
|
||||
ZwpPrimarySelectionSourceV1,
|
||||
ZwpPrimarySelectionSourceV1Id,
|
||||
zwp_primary_selection_source
|
||||
);
|
||||
112
src/ifs/zwp_primary_selection_source_v1/types.rs
Normal file
112
src/ifs/zwp_primary_selection_source_v1/types.rs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::zwp_primary_selection_source_v1::{ZwpPrimarySelectionSourceV1, CANCELLED, SEND};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionSourceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Could not process `offer` request")]
|
||||
OfferError(#[from] OfferError),
|
||||
#[error("Could not process `destroy` request")]
|
||||
DestroyError(#[from] DestroyError),
|
||||
#[error("The data source is already attached")]
|
||||
AlreadyAttached,
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionSourceV1Error, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OfferError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(OfferError, ParseFailed, MsgParserError);
|
||||
efrom!(OfferError, ClientError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DestroyError {
|
||||
#[error("Parsing failed")]
|
||||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(DestroyError, ParseFailed, MsgParserError);
|
||||
efrom!(DestroyError, ClientError);
|
||||
|
||||
pub(super) struct Offer<'a> {
|
||||
pub mime_type: &'a str,
|
||||
}
|
||||
impl<'a> RequestParser<'a> for Offer<'a> {
|
||||
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self {
|
||||
mime_type: parser.str()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Debug for Offer<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "offer(mime_type: {:?})", self.mime_type)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Destroy;
|
||||
impl RequestParser<'_> for Destroy {
|
||||
fn parse(_parser: &mut MsgParser<'_, '_>) -> Result<Self, MsgParserError> {
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
impl Debug for Destroy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "destroy()",)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Send {
|
||||
pub obj: Rc<ZwpPrimarySelectionSourceV1>,
|
||||
pub mime_type: String,
|
||||
pub fd: Rc<OwnedFd>,
|
||||
}
|
||||
impl EventFormatter for Send {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, SEND)
|
||||
.string(&self.mime_type)
|
||||
.fd(self.fd);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Send {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"send(mime_type: {:?}, fd: {})",
|
||||
self.mime_type,
|
||||
self.fd.raw()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Cancelled {
|
||||
pub obj: Rc<ZwpPrimarySelectionSourceV1>,
|
||||
}
|
||||
impl EventFormatter for Cancelled {
|
||||
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
|
||||
fmt.header(self.obj.id, CANCELLED);
|
||||
}
|
||||
fn obj(&self) -> &dyn Object {
|
||||
&*self.obj
|
||||
}
|
||||
}
|
||||
impl Debug for Cancelled {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "cancelled()")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::client::Client;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1;
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::{Interface, Object};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -27,7 +27,7 @@ impl ZxdgDecorationManagerV1Global {
|
|||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), ZxdgDecorationManagerV1Error> {
|
||||
let obj = Rc::new(ZxdgDecorationManagerV1Obj {
|
||||
let obj = Rc::new(ZxdgDecorationManagerV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
_version: version,
|
||||
|
|
@ -57,13 +57,15 @@ impl Global for ZxdgDecorationManagerV1Global {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct ZxdgDecorationManagerV1Obj {
|
||||
simple_add_global!(ZxdgDecorationManagerV1Global);
|
||||
|
||||
pub struct ZxdgDecorationManagerV1 {
|
||||
id: ZxdgDecorationManagerV1Id,
|
||||
client: Rc<Client>,
|
||||
_version: u32,
|
||||
}
|
||||
|
||||
impl ZxdgDecorationManagerV1Obj {
|
||||
impl ZxdgDecorationManagerV1 {
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
|
|
@ -75,39 +77,25 @@ impl ZxdgDecorationManagerV1Obj {
|
|||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), GetToplevelDecorationError> {
|
||||
let req: GetToplevelDecoration = self.client.parse(self, parser)?;
|
||||
let tl = self.client.get_xdg_toplevel(req.toplevel)?;
|
||||
let tl = self.client.lookup(req.toplevel)?;
|
||||
let obj = Rc::new(ZxdgToplevelDecorationV1::new(req.id, &self.client, &tl));
|
||||
self.client.add_client_obj(&obj)?;
|
||||
obj.send_configure();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZxdgDecorationManagerV1Error> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
GET_TOPLEVEL_DECORATION => self.get_toplevel_decoration(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(ZxdgDecorationManagerV1Obj);
|
||||
object_base! {
|
||||
ZxdgDecorationManagerV1, ZxdgDecorationManagerV1Error;
|
||||
|
||||
impl Object for ZxdgDecorationManagerV1Obj {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::ZxdgDecorationManagerV1
|
||||
}
|
||||
DESTROY => destroy,
|
||||
GET_TOPLEVEL_DECORATION => get_toplevel_decoration,
|
||||
}
|
||||
|
||||
impl Object for ZxdgDecorationManagerV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
GET_TOPLEVEL_DECORATION + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZxdgDecorationManagerV1);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod types;
|
|||
|
||||
use crate::client::{Client, DynEventFormatter};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::{Decoration, XdgToplevel};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
|
|
@ -70,34 +70,20 @@ impl ZxdgToplevelDecorationV1 {
|
|||
self.send_configure();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_request_(
|
||||
self: &Rc<Self>,
|
||||
request: u32,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZxdgToplevelDecorationV1Error> {
|
||||
match request {
|
||||
DESTROY => self.destroy(parser)?,
|
||||
SET_MODE => self.set_mode(parser)?,
|
||||
UNSET_MODE => self.unset_mode(parser)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
handle_request!(ZxdgToplevelDecorationV1);
|
||||
object_base! {
|
||||
ZxdgToplevelDecorationV1, ZxdgToplevelDecorationV1Error;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_MODE => set_mode,
|
||||
UNSET_MODE => unset_mode,
|
||||
}
|
||||
|
||||
impl Object for ZxdgToplevelDecorationV1 {
|
||||
fn id(&self) -> ObjectId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn interface(&self) -> Interface {
|
||||
Interface::ZxdgToplevelDecorationV1
|
||||
}
|
||||
|
||||
fn num_requests(&self) -> u32 {
|
||||
UNSET_MODE + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZxdgToplevelDecorationV1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue