autocommit 2022-02-09 17:26:50 CET
This commit is contained in:
parent
4190b910f8
commit
8faab3fe53
25 changed files with 1081 additions and 316 deletions
|
|
@ -1,14 +1,16 @@
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
use ahash::AHashSet;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::client::{Client, ClientId, WaylandObject};
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::object::ObjectId;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use ahash::AHashSet;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::ops::{Deref};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::NumCell;
|
||||
use crate::utils::bitflags::BitflagsExt;
|
||||
|
||||
pub mod wl_data_device;
|
||||
pub mod wl_data_device_manager;
|
||||
|
|
@ -27,112 +29,179 @@ pub enum Role {
|
|||
|
||||
pub trait Vtable: Sized {
|
||||
type DeviceId: Eq + Copy;
|
||||
type OfferId: Copy + From<ObjectId>;
|
||||
type OfferId: Eq + Copy + From<ObjectId>;
|
||||
|
||||
type Device;
|
||||
type Source;
|
||||
type Offer: WaylandObject;
|
||||
|
||||
fn device_id(dd: &Self::Device) -> Self::DeviceId;
|
||||
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self>;
|
||||
fn get_offer_data(offer: &Self::Offer) -> &OfferData<Self>;
|
||||
fn get_source_data(src: &Self::Source) -> &SourceData<Self>;
|
||||
fn for_each_device<C>(seat: &WlSeatGlobal, client: ClientId, f: C)
|
||||
where C: FnMut(&Rc<Self::Device>);
|
||||
fn create_offer(client: &Rc<Client>, data: OfferData<Self>, id: ObjectId) -> Self::Offer;
|
||||
where
|
||||
C: FnMut(&Rc<Self::Device>);
|
||||
fn create_offer(
|
||||
client: &Rc<Client>,
|
||||
dd: &Rc<Self::Device>,
|
||||
data: OfferData<Self>,
|
||||
id: ObjectId,
|
||||
) -> Self::Offer;
|
||||
fn send_selection(dd: &Self::Device, offer: Self::OfferId);
|
||||
fn send_cancelled(source: &Self::Source);
|
||||
fn get_offer_id(offer: &Self::Offer) -> Self::OfferId;
|
||||
fn send_offer(dd: &Self::Device, offer: &Self::Offer);
|
||||
fn send_mime_type(offer: &Self::Offer, mime_type: &str);
|
||||
fn unset(seat: &Rc<WlSeatGlobal>);
|
||||
fn unset(seat: &Rc<WlSeatGlobal>, role: Role);
|
||||
fn send_send(src: &Self::Source, mime_type: &str, fd: Rc<OwnedFd>);
|
||||
}
|
||||
|
||||
pub struct OfferData<T: Vtable> {
|
||||
device_id: T::DeviceId,
|
||||
source: CloneCell<Option<Rc<T::Source>>>,
|
||||
client: Rc<Client>,
|
||||
pub struct DeviceData<T: Vtable> {
|
||||
selection: CloneCell<Option<Rc<T::Offer>>>,
|
||||
dnd: CloneCell<Option<Rc<T::Offer>>>,
|
||||
}
|
||||
|
||||
struct Attachment<T: Vtable> {
|
||||
seat: Rc<WlSeatGlobal>,
|
||||
role: Role,
|
||||
offers: SmallMap<T::DeviceId, Rc<T::Offer>, 1>,
|
||||
}
|
||||
|
||||
impl<T: Vtable> Attachment<T> {
|
||||
fn detach_offers(&self) {
|
||||
while let Some((_, offer)) = self.offers.pop() {
|
||||
T::get_offer_data(&offer).source.set(None);
|
||||
impl<T: Vtable> Default for DeviceData<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
selection: Default::default(),
|
||||
dnd: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OfferData<T: Vtable> {
|
||||
device: CloneCell<Option<Rc<T::Device>>>,
|
||||
source: CloneCell<Option<Rc<T::Source>>>,
|
||||
client: Rc<Client>,
|
||||
shared: Rc<SharedState>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum IpcError {
|
||||
#[error("The data source is already attached")]
|
||||
AlreadyAttached,
|
||||
#[error("The data source does not have drag-and-drop actions set")]
|
||||
ActionsNotSet,
|
||||
#[error("The data source has drag-and-drop actions set")]
|
||||
ActionsSet,
|
||||
}
|
||||
|
||||
const OFFER_STATE_ACCEPTED: u32 = 1 << 0;
|
||||
const OFFER_STATE_FINISHED: u32 = 1 << 1;
|
||||
const OFFER_STATE_DROPPED: u32 = 1 << 2;
|
||||
|
||||
const SOURCE_STATE_USED: u32 = 1 << 1;
|
||||
const SOURCE_STATE_FINISHED: u32 = 1 << 2;
|
||||
|
||||
pub struct SourceData<T: Vtable> {
|
||||
attachment: RefCell<Option<Attachment<T>>>,
|
||||
disconnecting: Cell<bool>,
|
||||
seat: CloneCell<Option<Rc<WlSeatGlobal>>>,
|
||||
offers: SmallMap<T::OfferId, Rc<T::Offer>, 1>,
|
||||
offer_client: Cell<ClientId>,
|
||||
mime_types: RefCell<AHashSet<String>>,
|
||||
client: Rc<Client>
|
||||
client: Rc<Client>,
|
||||
state: NumCell<u32>,
|
||||
actions: Cell<Option<u32>>,
|
||||
role: Cell<Role>,
|
||||
shared: CloneCell<Rc<SharedState>>,
|
||||
}
|
||||
|
||||
struct SharedState {
|
||||
state: NumCell<u32>,
|
||||
role: Cell<Role>,
|
||||
receiver_actions: Cell<u32>,
|
||||
receiver_preferred_action: Cell<u32>,
|
||||
selected_action: Cell<u32>,
|
||||
}
|
||||
|
||||
impl Default for SharedState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
state: NumCell::new(0),
|
||||
role: Cell::new(Role::Selection),
|
||||
receiver_actions: Cell::new(0),
|
||||
receiver_preferred_action: Cell::new(0),
|
||||
selected_action: Cell::new(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Vtable> SourceData<T> {
|
||||
fn new(client: &Rc<Client>) -> Self {
|
||||
Self {
|
||||
attachment: Default::default(),
|
||||
disconnecting: Cell::new(false),
|
||||
seat: Default::default(),
|
||||
offers: Default::default(),
|
||||
offer_client: Cell::new(client.id),
|
||||
mime_types: Default::default(),
|
||||
client: client.clone(),
|
||||
state: NumCell::new(0),
|
||||
actions: Cell::new(None),
|
||||
role: Cell::new(Role::Selection),
|
||||
shared: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn attach_source<T: Vtable>(
|
||||
pub fn attach_seat<T: Vtable>(
|
||||
src: &T::Source,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
role: Role,
|
||||
) -> Result<(), IpcError> {
|
||||
let src = T::get_source_data(src);
|
||||
let mut attachment = src.attachment.borrow_mut();
|
||||
if attachment.is_some() {
|
||||
let data = T::get_source_data(src);
|
||||
let mut state = data.state.get();
|
||||
if state.contains(SOURCE_STATE_USED) {
|
||||
return Err(IpcError::AlreadyAttached);
|
||||
}
|
||||
*attachment = Some(Attachment {
|
||||
seat: seat.clone(),
|
||||
role,
|
||||
offers: Default::default(),
|
||||
});
|
||||
state |= SOURCE_STATE_USED;
|
||||
if role == Role::Dnd {
|
||||
if data.actions.get().is_none() {
|
||||
return Err(IpcError::ActionsNotSet);
|
||||
}
|
||||
} else {
|
||||
if data.actions.get().is_some() {
|
||||
return Err(IpcError::ActionsSet);
|
||||
}
|
||||
}
|
||||
data.state.set(state);
|
||||
data.role.set(role);
|
||||
data.seat.set(Some(seat.clone()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn detach_source<T: Vtable>(src: &T::Source) {
|
||||
pub fn cancel_offers<T: Vtable>(src: &T::Source) {
|
||||
let data = T::get_source_data(src);
|
||||
if data.disconnecting.get() {
|
||||
return;
|
||||
while let Some((_, offer)) = data.offers.pop() {
|
||||
let data = T::get_offer_data(&offer);
|
||||
log::error!("cancel_offers");
|
||||
data.source.take();
|
||||
destroy_offer::<T>(&offer);
|
||||
}
|
||||
if let Some(attachment) = data.attachment.borrow_mut().take() {
|
||||
attachment.detach_offers();
|
||||
}
|
||||
|
||||
pub fn detach_seat<T: Vtable>(src: &T::Source) {
|
||||
let data = T::get_source_data(src);
|
||||
data.seat.set(None);
|
||||
cancel_offers::<T>(src);
|
||||
if !data.state.get().contains(SOURCE_STATE_FINISHED) {
|
||||
T::send_cancelled(src);
|
||||
}
|
||||
T::send_cancelled(src);
|
||||
}
|
||||
|
||||
pub fn offer_source_to<T: Vtable>(src: &Rc<T::Source>, client: &Rc<Client>) {
|
||||
let data = T::get_source_data(src);
|
||||
let mut attachment = data.attachment.borrow_mut();
|
||||
let attachment = match attachment.deref_mut() {
|
||||
let seat = match data.seat.get() {
|
||||
Some(a) => a,
|
||||
_ => {
|
||||
log::error!("Trying to create an offer from a unattached data source");
|
||||
return;
|
||||
}
|
||||
};
|
||||
attachment.detach_offers();
|
||||
T::for_each_device(&attachment.seat, client.id, |dd| {
|
||||
cancel_offers::<T>(src);
|
||||
data.offer_client.set(client.id);
|
||||
let shared = data.shared.get();
|
||||
shared.role.set(data.role.get());
|
||||
T::for_each_device(&seat, client.id, |dd| {
|
||||
let id = match client.new_id() {
|
||||
Ok(id) => id,
|
||||
Err(e) => {
|
||||
|
|
@ -140,60 +209,105 @@ pub fn offer_source_to<T: Vtable>(src: &Rc<T::Source>, client: &Rc<Client>) {
|
|||
return;
|
||||
}
|
||||
};
|
||||
let device_data = T::get_device_data(dd);
|
||||
let offer_data = OfferData {
|
||||
device_id: T::device_id(dd),
|
||||
device: CloneCell::new(Some(dd.clone())),
|
||||
source: CloneCell::new(Some(src.clone())),
|
||||
client: client.clone(),
|
||||
shared: shared.clone(),
|
||||
};
|
||||
let offer = Rc::new(T::create_offer(client, offer_data, id));
|
||||
attachment.offers.insert(T::device_id(dd), offer.clone());
|
||||
let offer = Rc::new(T::create_offer(client, dd, offer_data, id));
|
||||
data.offers.insert(id.into(), offer.clone());
|
||||
let mt = data.mime_types.borrow_mut();
|
||||
T::send_offer(dd, &offer);
|
||||
for mt in mt.deref() {
|
||||
T::send_mime_type(&offer, mt);
|
||||
}
|
||||
if attachment.role == Role::Selection {
|
||||
T::send_selection(dd, T::get_offer_id(&offer));
|
||||
match data.role.get() {
|
||||
Role::Selection => {
|
||||
T::send_selection(dd, T::get_offer_id(&offer));
|
||||
device_data.selection.set(Some(offer.clone()));
|
||||
}
|
||||
Role::Dnd => {
|
||||
device_data.dnd.set(Some(offer.clone()));
|
||||
}
|
||||
}
|
||||
client.add_server_obj(&offer);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
fn add_mime_type<T: Vtable>(src: &T::Source, mime_type: &str) {
|
||||
let data = T::get_source_data(src);
|
||||
if data
|
||||
.mime_types
|
||||
.borrow_mut()
|
||||
.insert(mime_type.to_string())
|
||||
{
|
||||
if let Some(attachment) = data.attachment.borrow_mut().deref_mut() {
|
||||
for (_, offer) in &attachment.offers {
|
||||
T::send_mime_type(&offer, mime_type);
|
||||
let data = T::get_offer_data(&offer);
|
||||
data.client.flush();
|
||||
if data.mime_types.borrow_mut().insert(mime_type.to_string()) {
|
||||
for (_, offer) in &data.offers {
|
||||
T::send_mime_type(&offer, mime_type);
|
||||
let data = T::get_offer_data(&offer);
|
||||
data.client.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy_source<T: Vtable>(src: &T::Source) {
|
||||
let data = T::get_source_data(src);
|
||||
if let Some(seat) = data.seat.take() {
|
||||
T::unset(&seat, data.role.get());
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy_offer<T: Vtable>(offer: &T::Offer) {
|
||||
let data = T::get_offer_data(offer);
|
||||
if let Some(device) = data.device.take() {
|
||||
let device_data = T::get_device_data(&device);
|
||||
match data.shared.role.get() {
|
||||
Role::Selection => {
|
||||
T::send_selection(&device, ObjectId::NONE.into());
|
||||
device_data.selection.take();
|
||||
}
|
||||
Role::Dnd => {
|
||||
device_data.dnd.take();
|
||||
}
|
||||
}
|
||||
}
|
||||
log::error!("destroy_offer");
|
||||
if let Some(src) = data.source.take() {
|
||||
let src_data = T::get_source_data(&src);
|
||||
src_data.offers.remove(&T::get_offer_id(offer));
|
||||
if src_data.offers.is_empty() && src_data.role.get() == Role::Dnd && data.shared.state.get().contains(OFFER_STATE_DROPPED) {
|
||||
if let Some(seat) = src_data.seat.take() {
|
||||
T::unset(&seat, data.shared.role.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn disconnect_source<T: Vtable>(src: &T::Source) {
|
||||
let data = T::get_source_data(src);
|
||||
data.disconnecting.set(true);
|
||||
if let Some(attachment) = data.attachment.borrow_mut().take() {
|
||||
attachment.detach_offers();
|
||||
T::unset(&attachment.seat);
|
||||
fn destroy_device<T: Vtable>(dd: &T::Device) {
|
||||
let data = T::get_device_data(dd);
|
||||
let offers = [data.selection.take(), data.dnd.take()];
|
||||
for offer in offers.into_iter().flat_map(|o| o.into_iter()) {
|
||||
T::get_offer_data(&offer).device.take();
|
||||
destroy_offer::<T>(&offer);
|
||||
}
|
||||
}
|
||||
|
||||
fn disconnect_offer<T: Vtable>(offer: &T::Offer) {
|
||||
let data = T::get_offer_data(offer);
|
||||
if let Some(src) = data.source.set(None) {
|
||||
let src_data = T::get_source_data(&src);
|
||||
if let Some(attachment) = src_data.attachment.borrow_mut().deref_mut() {
|
||||
attachment.offers.remove(&data.device_id);
|
||||
}
|
||||
fn break_source_loops<T: Vtable>(src: &T::Source) {
|
||||
let data = T::get_source_data(src);
|
||||
if data.offer_client.get() == data.client.id {
|
||||
data.offers.take();
|
||||
}
|
||||
destroy_source::<T>(src);
|
||||
}
|
||||
|
||||
fn break_offer_loops<T: Vtable>(offer: &T::Offer) {
|
||||
let data = T::get_offer_data(offer);
|
||||
data.device.set(None);
|
||||
destroy_offer::<T>(offer);
|
||||
}
|
||||
|
||||
fn break_device_loops<T: Vtable>(dd: &T::Device) {
|
||||
let data = T::get_device_data(dd);
|
||||
data.selection.take();
|
||||
data.dnd.take();
|
||||
destroy_device::<T>(dd);
|
||||
}
|
||||
|
||||
fn receive<T: Vtable>(offer: &T::Offer, mime_type: &str, fd: Rc<OwnedFd>) {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
use crate::client::{Client, ClientError, ClientId};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::ipc::wl_data_device_manager::WlDataDeviceManager;
|
||||
use crate::ifs::ipc::wl_data_source::{WlDataSource};
|
||||
use crate::ifs::ipc::wl_data_offer::WlDataOffer;
|
||||
use crate::ifs::ipc::wl_data_source::WlDataSource;
|
||||
use crate::ifs::ipc::{
|
||||
break_device_loops, destroy_device, DeviceData, OfferData, Role, SourceData, Vtable,
|
||||
};
|
||||
use crate::ifs::wl_seat::{WlSeat, WlSeatError, WlSeatGlobal};
|
||||
use crate::object::{Object, ObjectId};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::wl_data_device::*;
|
||||
use crate::wire::{WlDataDeviceId, WlDataOfferId};
|
||||
use crate::wire::{WlDataDeviceId, WlDataOfferId, WlSurfaceId};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::ifs::ipc::{OfferData, SourceData, Vtable};
|
||||
use crate::ifs::ipc::wl_data_offer::WlDataOffer;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const ROLE: u32 = 0;
|
||||
|
|
@ -20,6 +23,7 @@ pub struct WlDataDevice {
|
|||
pub id: WlDataDeviceId,
|
||||
pub manager: Rc<WlDataDeviceManager>,
|
||||
pub seat: Rc<WlSeat>,
|
||||
pub data: DeviceData<WlDataDevice>,
|
||||
}
|
||||
|
||||
impl WlDataDevice {
|
||||
|
|
@ -28,6 +32,7 @@ impl WlDataDevice {
|
|||
id,
|
||||
manager: manager.clone(),
|
||||
seat: seat.clone(),
|
||||
data: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +50,43 @@ impl WlDataDevice {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn send_leave(&self) {
|
||||
self.manager.client.event(Leave { self_id: self.id })
|
||||
}
|
||||
|
||||
pub fn send_enter(&self, surface: WlSurfaceId, x: Fixed, y: Fixed, offer: WlDataOfferId) {
|
||||
self.manager.client.event(Enter {
|
||||
self_id: self.id,
|
||||
serial: 0,
|
||||
surface,
|
||||
x,
|
||||
y,
|
||||
id: offer,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_motion(&self, x: Fixed, y: Fixed) {
|
||||
self.manager.client.event(Motion {
|
||||
self_id: self.id,
|
||||
time: 0,
|
||||
x,
|
||||
y,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_drop(&self) {
|
||||
self.manager.client.event(Drop { self_id: self.id })
|
||||
}
|
||||
|
||||
fn start_drag(&self, parser: MsgParser<'_, '_>) -> Result<(), StartDragError> {
|
||||
let _req: StartDrag = self.manager.client.parse(self, parser)?;
|
||||
let req: StartDrag = self.manager.client.parse(self, parser)?;
|
||||
let origin = self.manager.client.lookup(req.origin)?;
|
||||
let source = if req.source.is_some() {
|
||||
Some(self.manager.client.lookup(req.source)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.seat.global.start_drag(&origin, source)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +103,7 @@ impl WlDataDevice {
|
|||
|
||||
fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> {
|
||||
let _req: Release = self.manager.client.parse(self, parser)?;
|
||||
destroy_device::<Self>(self);
|
||||
self.seat.remove_data_device(self);
|
||||
self.manager.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
@ -80,23 +121,36 @@ impl Vtable for WlDataDevice {
|
|||
dd.id
|
||||
}
|
||||
|
||||
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self> {
|
||||
&dd.data
|
||||
}
|
||||
|
||||
fn get_offer_data(offer: &Self::Offer) -> &OfferData<Self> {
|
||||
&offer.offer_data
|
||||
&offer.data
|
||||
}
|
||||
|
||||
fn get_source_data(src: &Self::Source) -> &SourceData<Self> {
|
||||
&src.data
|
||||
}
|
||||
|
||||
fn for_each_device<C>(seat: &WlSeatGlobal, client: ClientId, f: C) where C: FnMut(&Rc<Self::Device>) {
|
||||
fn for_each_device<C>(seat: &WlSeatGlobal, client: ClientId, f: C)
|
||||
where
|
||||
C: FnMut(&Rc<Self::Device>),
|
||||
{
|
||||
seat.for_each_data_device(0, client, f);
|
||||
}
|
||||
|
||||
fn create_offer(client: &Rc<Client>, offer_data: OfferData<Self>, id: ObjectId) -> Self::Offer {
|
||||
fn create_offer(
|
||||
client: &Rc<Client>,
|
||||
device: &Rc<WlDataDevice>,
|
||||
offer_data: OfferData<Self>,
|
||||
id: ObjectId,
|
||||
) -> Self::Offer {
|
||||
WlDataOffer {
|
||||
id: id.into(),
|
||||
client: client.clone(),
|
||||
offer_data,
|
||||
device: device.clone(),
|
||||
data: offer_data,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -120,8 +174,11 @@ impl Vtable for WlDataDevice {
|
|||
offer.send_offer(mime_type);
|
||||
}
|
||||
|
||||
fn unset(seat: &Rc<WlSeatGlobal>) {
|
||||
seat.unset_selection();
|
||||
fn unset(seat: &Rc<WlSeatGlobal>, role: Role) {
|
||||
match role {
|
||||
Role::Selection => seat.unset_selection(),
|
||||
Role::Dnd => seat.cancel_dnd(),
|
||||
}
|
||||
}
|
||||
|
||||
fn send_send(src: &Self::Source, mime_type: &str, fd: Rc<OwnedFd>) {
|
||||
|
|
@ -143,6 +200,7 @@ impl Object for WlDataDevice {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
break_device_loops::<Self>(self);
|
||||
self.seat.remove_data_device(self);
|
||||
}
|
||||
}
|
||||
|
|
@ -168,9 +226,12 @@ pub enum StartDragError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WlSeatError(Box<WlSeatError>),
|
||||
}
|
||||
efrom!(StartDragError, ParseFailed, MsgParserError);
|
||||
efrom!(StartDragError, ClientError);
|
||||
efrom!(StartDragError, WlSeatError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetSelectionError {
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ use crate::wire::WlDataDeviceManagerId;
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
pub(super) const DND_NONE: u32 = 0;
|
||||
#[allow(dead_code)]
|
||||
const DND_NONE: u32 = 0;
|
||||
pub(super) const DND_COPY: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const DND_COPY: u32 = 1;
|
||||
pub(super) const DND_MOVE: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const DND_MOVE: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const DND_ASK: u32 = 4;
|
||||
pub(super) const DND_ASK: u32 = 4;
|
||||
pub(super) const DND_ALL: u32 = 7;
|
||||
|
||||
pub struct WlDataDeviceManagerGlobal {
|
||||
name: GlobalName,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::ifs::ipc::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::ipc::{break_offer_loops, destroy_offer, receive, OfferData, Role, OFFER_STATE_FINISHED, OFFER_STATE_DROPPED, OFFER_STATE_ACCEPTED, SOURCE_STATE_FINISHED};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::wl_data_offer::*;
|
||||
use crate::wire::{WlDataOfferId};
|
||||
use crate::wire::WlDataOfferId;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::ipc::{disconnect_offer, OfferData, receive};
|
||||
use crate::ifs::ipc::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::ipc::wl_data_device_manager::{DND_ALL};
|
||||
use crate::utils::bitflags::BitflagsExt;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_FINISH: u32 = 0;
|
||||
|
|
@ -18,11 +20,11 @@ const INVALID_ACTION: u32 = 2;
|
|||
#[allow(dead_code)]
|
||||
const INVALID_OFFER: u32 = 3;
|
||||
|
||||
|
||||
pub struct WlDataOffer {
|
||||
pub id: WlDataOfferId,
|
||||
pub client: Rc<Client>,
|
||||
pub offer_data: OfferData<WlDataDevice>,
|
||||
pub device: Rc<WlDataDevice>,
|
||||
pub data: OfferData<WlDataDevice>,
|
||||
}
|
||||
|
||||
impl WlDataOffer {
|
||||
|
|
@ -33,31 +35,101 @@ impl WlDataOffer {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn send_source_actions(&self) {
|
||||
if let Some(src) = self.data.source.get() {
|
||||
if let Some(source_actions) = src.data.actions.get() {
|
||||
self.client.event(SourceActions {
|
||||
self_id: self.id,
|
||||
source_actions,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_action(&self, dnd_action: u32) {
|
||||
self.client.event(Action {
|
||||
self_id: self.id,
|
||||
dnd_action,
|
||||
})
|
||||
}
|
||||
|
||||
fn accept(&self, parser: MsgParser<'_, '_>) -> Result<(), AcceptError> {
|
||||
let _req: Accept = self.client.parse(self, parser)?;
|
||||
let req: Accept = self.client.parse(self, parser)?;
|
||||
let mut state = self.data.shared.state.get();
|
||||
if state.contains(OFFER_STATE_FINISHED) {
|
||||
return Err(AcceptError::AlreadyFinished);
|
||||
}
|
||||
if req.mime_type.is_some() {
|
||||
state |= OFFER_STATE_ACCEPTED;
|
||||
} else {
|
||||
state &= !OFFER_STATE_ACCEPTED;
|
||||
}
|
||||
self.data.shared.state.set(state);
|
||||
if let Some(src) = self.data.source.get() {
|
||||
src.send_target(req.mime_type);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ReceiveError> {
|
||||
let req: Receive = self.client.parse(self, parser)?;
|
||||
if self.data.shared.state.get().contains(OFFER_STATE_FINISHED) {
|
||||
return Err(ReceiveError::AlreadyFinished);
|
||||
}
|
||||
receive::<WlDataDevice>(self, req.mime_type, req.fd);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
disconnect_offer::<WlDataDevice>(self);
|
||||
destroy_offer::<WlDataDevice>(self);
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn finish(&self, parser: MsgParser<'_, '_>) -> Result<(), FinishError> {
|
||||
let _req: Finish = self.client.parse(self, parser)?;
|
||||
if self.data.shared.role.get() != Role::Dnd {
|
||||
return Err(FinishError::NotDnd);
|
||||
}
|
||||
let mut state = self.data.shared.state.get();
|
||||
if state.contains(OFFER_STATE_FINISHED) {
|
||||
return Err(FinishError::AlreadyFinished);
|
||||
}
|
||||
if !state.contains(OFFER_STATE_DROPPED) {
|
||||
return Err(FinishError::StillDragging);
|
||||
}
|
||||
if !state.contains(OFFER_STATE_ACCEPTED) {
|
||||
return Err(FinishError::NoMimeTypeAccepted);
|
||||
}
|
||||
state |= OFFER_STATE_FINISHED;
|
||||
if let Some(src) = self.data.source.get() {
|
||||
src.data.state.or_assign(SOURCE_STATE_FINISHED);
|
||||
src.send_dnd_finished();
|
||||
} else {
|
||||
log::error!("no source");
|
||||
}
|
||||
self.data.shared.state.set(state);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), SetActionsError> {
|
||||
let _req: SetActions = self.client.parse(self, parser)?;
|
||||
let req: SetActions = self.client.parse(self, parser)?;
|
||||
let state = self.data.shared.state.get();
|
||||
if state.contains(OFFER_STATE_FINISHED) {
|
||||
return Err(SetActionsError::AlreadyFinished);
|
||||
}
|
||||
if (req.dnd_actions & !DND_ALL, req.preferred_action & !DND_ALL) != (0, 0) {
|
||||
return Err(SetActionsError::InvalidActions);
|
||||
}
|
||||
if req.preferred_action.count_ones() > 1 {
|
||||
return Err(SetActionsError::MultiplePreferred);
|
||||
}
|
||||
self.data.shared.receiver_actions.set(req.dnd_actions);
|
||||
self.data.shared.receiver_preferred_action.set(req.preferred_action);
|
||||
if let Some(src) = self.data.source.get() {
|
||||
src.update_selected_action();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -78,7 +150,7 @@ impl Object for WlDataOffer {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
disconnect_offer::<WlDataDevice>(self);
|
||||
break_offer_loops::<WlDataDevice>(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +179,8 @@ pub enum AcceptError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("`finish` was already called")]
|
||||
AlreadyFinished,
|
||||
}
|
||||
efrom!(AcceptError, ParseFailed, MsgParserError);
|
||||
efrom!(AcceptError, ClientError);
|
||||
|
|
@ -117,6 +191,8 @@ pub enum ReceiveError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("`finish` was already called")]
|
||||
AlreadyFinished,
|
||||
}
|
||||
efrom!(ReceiveError, ParseFailed, MsgParserError);
|
||||
efrom!(ReceiveError, ClientError);
|
||||
|
|
@ -137,6 +213,14 @@ pub enum FinishError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("`finish` was already called")]
|
||||
AlreadyFinished,
|
||||
#[error("The drag operation is still ongoing")]
|
||||
StillDragging,
|
||||
#[error("Client did not accept a mime type")]
|
||||
NoMimeTypeAccepted,
|
||||
#[error("This is not a drag-and-drop offer")]
|
||||
NotDnd,
|
||||
}
|
||||
efrom!(FinishError, ParseFailed, MsgParserError);
|
||||
efrom!(FinishError, ClientError);
|
||||
|
|
@ -147,6 +231,12 @@ pub enum SetActionsError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("`finish` was already called")]
|
||||
AlreadyFinished,
|
||||
#[error("The set of actions is invalid")]
|
||||
InvalidActions,
|
||||
#[error("Multiple preferred actions were specified")]
|
||||
MultiplePreferred,
|
||||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, ClientError);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::ifs::ipc::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::ipc::wl_data_offer::WlDataOffer;
|
||||
use crate::ifs::ipc::{add_mime_type, break_source_loops, cancel_offers, destroy_source, OFFER_STATE_ACCEPTED, OFFER_STATE_DROPPED, SharedState, SourceData};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::wl_data_source::*;
|
||||
use crate::wire::{WlDataSourceId};
|
||||
use crate::wire::WlDataSourceId;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::ifs::ipc::{add_mime_type, disconnect_source, SourceData};
|
||||
use crate::ifs::ipc::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::ipc::wl_data_device_manager::{DND_ALL, DND_NONE};
|
||||
use crate::utils::bitflags::BitflagsExt;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_ACTION_MASK: u32 = 0;
|
||||
|
|
@ -28,6 +31,61 @@ impl WlDataSource {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_leave(&self) {
|
||||
if self.data.shared.get().state.get().contains(OFFER_STATE_DROPPED) {
|
||||
return;
|
||||
}
|
||||
self.data.shared.set(Rc::new(SharedState::default()));
|
||||
self.send_target(None);
|
||||
self.send_action(DND_NONE);
|
||||
cancel_offers::<WlDataDevice>(self);
|
||||
}
|
||||
|
||||
pub fn update_selected_action(&self) {
|
||||
let shared = self.data.shared.get();
|
||||
let server_actions = match self.data.actions.get() {
|
||||
Some(n) => n,
|
||||
_ => {
|
||||
log::error!("Server actions not set");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let actions = server_actions & shared.receiver_actions.get();
|
||||
let action = if actions.contains(shared.receiver_preferred_action.get()) {
|
||||
shared.receiver_preferred_action.get()
|
||||
} else if actions != 0 {
|
||||
1 << actions.trailing_zeros()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
log::info!("sa = {}, ra = {}, action = {}", server_actions, shared.receiver_actions.get(), action);
|
||||
if shared.selected_action.replace(action) != action {
|
||||
for (_, offer) in &self.data.offers {
|
||||
offer.send_action(action);
|
||||
offer.client.flush();
|
||||
}
|
||||
self.send_action(action);
|
||||
self.data.client.flush();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn for_each_data_offer<C: FnMut(&WlDataOffer)>(&self, mut f: C) {
|
||||
for (_, offer) in &self.data.offers {
|
||||
f(&offer);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_drop(&self) -> bool {
|
||||
let shared = self.data.shared.get();
|
||||
shared.selected_action.get() != 0 && shared.state.get().contains(OFFER_STATE_ACCEPTED)
|
||||
}
|
||||
|
||||
pub fn on_drop(&self) {
|
||||
self.send_dnd_drop_performed();
|
||||
let shared = self.data.shared.get();
|
||||
shared.state.or_assign(OFFER_STATE_DROPPED);
|
||||
}
|
||||
|
||||
pub fn send_cancelled(&self) {
|
||||
self.data.client.event(Cancelled { self_id: self.id })
|
||||
}
|
||||
|
|
@ -40,6 +98,25 @@ impl WlDataSource {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn send_target(&self, mime_type: Option<&str>) {
|
||||
self.data.client.event(Target {
|
||||
self_id: self.id,
|
||||
mime_type,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_dnd_finished(&self) {
|
||||
self.data.client.event(DndFinished { self_id: self.id })
|
||||
}
|
||||
|
||||
pub fn send_action(&self, dnd_action: u32) {
|
||||
self.data.client.event(Action { self_id: self.id, dnd_action, })
|
||||
}
|
||||
|
||||
pub fn send_dnd_drop_performed(&self) {
|
||||
self.data.client.event(DndDropPerformed { self_id: self.id })
|
||||
}
|
||||
|
||||
fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), OfferError> {
|
||||
let req: Offer = self.data.client.parse(self, parser)?;
|
||||
add_mime_type::<WlDataDevice>(self, req.mime_type);
|
||||
|
|
@ -48,13 +125,20 @@ impl WlDataSource {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.data.client.parse(self, parser)?;
|
||||
disconnect_source::<WlDataDevice>(self);
|
||||
destroy_source::<WlDataDevice>(self);
|
||||
self.data.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), SetActionsError> {
|
||||
let _req: SetActions = self.data.client.parse(self, parser)?;
|
||||
let req: SetActions = self.data.client.parse(self, parser)?;
|
||||
if self.data.actions.get().is_some() {
|
||||
return Err(SetActionsError::AlreadySet);
|
||||
}
|
||||
if req.dnd_actions & !DND_ALL != 0 {
|
||||
return Err(SetActionsError::InvalidActions);
|
||||
}
|
||||
self.data.actions.set(Some(req.dnd_actions));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +157,7 @@ impl Object for WlDataSource {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
disconnect_source::<WlDataDevice>(self);
|
||||
break_source_loops::<WlDataDevice>(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +202,10 @@ pub enum SetActionsError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The set of actions is invalid")]
|
||||
InvalidActions,
|
||||
#[error("The actions have already been set")]
|
||||
AlreadySet,
|
||||
}
|
||||
efrom!(SetActionsError, ParseFailed, MsgParserError);
|
||||
efrom!(SetActionsError, ClientError);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::ipc::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1;
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
|
|
@ -7,8 +9,6 @@ use crate::wire::zwp_primary_selection_device_manager_v1::*;
|
|||
use crate::wire::ZwpPrimarySelectionDeviceManagerV1Id;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::ipc::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1;
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceManagerV1Global {
|
||||
name: GlobalName,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
use crate::client::{Client, ClientError, ClientId};
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1;
|
||||
use crate::ifs::ipc::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1;
|
||||
use crate::ifs::ipc::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1;
|
||||
use crate::ifs::ipc::{
|
||||
break_device_loops, destroy_device, DeviceData, OfferData, Role, SourceData, Vtable,
|
||||
};
|
||||
use crate::ifs::wl_seat::{WlSeat, WlSeatError, WlSeatGlobal};
|
||||
use crate::object::{Object, ObjectId};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
|
|
@ -7,15 +13,12 @@ use crate::wire::{ZwpPrimarySelectionDeviceV1Id, ZwpPrimarySelectionOfferV1Id};
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::ifs::ipc::{OfferData, SourceData, Vtable};
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1;
|
||||
use crate::ifs::ipc::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1;
|
||||
use crate::ifs::ipc::zwp_primary_selection_source_v1::{ZwpPrimarySelectionSourceV1};
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceV1 {
|
||||
pub id: ZwpPrimarySelectionDeviceV1Id,
|
||||
pub manager: Rc<ZwpPrimarySelectionDeviceManagerV1>,
|
||||
seat: Rc<WlSeat>,
|
||||
data: DeviceData<Self>,
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionDeviceV1 {
|
||||
|
|
@ -28,6 +31,7 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
id,
|
||||
manager: manager.clone(),
|
||||
seat: seat.clone(),
|
||||
data: DeviceData::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +62,7 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.manager.client.parse(self, parser)?;
|
||||
destroy_device::<Self>(self);
|
||||
self.seat.remove_primary_selection_device(self);
|
||||
self.manager.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
@ -75,6 +80,10 @@ impl Vtable for ZwpPrimarySelectionDeviceV1 {
|
|||
dd.id
|
||||
}
|
||||
|
||||
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self> {
|
||||
&dd.data
|
||||
}
|
||||
|
||||
fn get_offer_data(offer: &Self::Offer) -> &OfferData<Self> {
|
||||
&offer.offer_data
|
||||
}
|
||||
|
|
@ -83,11 +92,19 @@ impl Vtable for ZwpPrimarySelectionDeviceV1 {
|
|||
&src.data
|
||||
}
|
||||
|
||||
fn for_each_device<C>(seat: &WlSeatGlobal, client: ClientId, f: C) where C: FnMut(&Rc<Self::Device>) {
|
||||
fn for_each_device<C>(seat: &WlSeatGlobal, client: ClientId, f: C)
|
||||
where
|
||||
C: FnMut(&Rc<Self::Device>),
|
||||
{
|
||||
seat.for_each_primary_selection_device(0, client, f)
|
||||
}
|
||||
|
||||
fn create_offer(client: &Rc<Client>, offer_data: OfferData<Self>, id: ObjectId) -> Self::Offer {
|
||||
fn create_offer(
|
||||
client: &Rc<Client>,
|
||||
_device: &Rc<ZwpPrimarySelectionDeviceV1>,
|
||||
offer_data: OfferData<Self>,
|
||||
id: ObjectId,
|
||||
) -> Self::Offer {
|
||||
ZwpPrimarySelectionOfferV1 {
|
||||
id: id.into(),
|
||||
client: client.clone(),
|
||||
|
|
@ -115,7 +132,7 @@ impl Vtable for ZwpPrimarySelectionDeviceV1 {
|
|||
offer.send_offer(mime_type);
|
||||
}
|
||||
|
||||
fn unset(seat: &Rc<WlSeatGlobal>) {
|
||||
fn unset(seat: &Rc<WlSeatGlobal>, _role: Role) {
|
||||
seat.unset_primary_selection();
|
||||
}
|
||||
|
||||
|
|
@ -137,6 +154,7 @@ impl Object for ZwpPrimarySelectionDeviceV1 {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
break_device_loops::<Self>(self);
|
||||
self.seat.remove_primary_selection_device(self);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::ipc::{break_offer_loops, destroy_offer, receive, OfferData};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::wire::zwp_primary_selection_offer_v1::*;
|
||||
use crate::wire::ZwpPrimarySelectionOfferV1Id;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::ipc::{disconnect_offer, OfferData, receive};
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
|
||||
pub struct ZwpPrimarySelectionOfferV1 {
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
|
|
@ -30,7 +30,7 @@ impl ZwpPrimarySelectionOfferV1 {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
disconnect_offer::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
destroy_offer::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ impl Object for ZwpPrimarySelectionOfferV1 {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
disconnect_offer::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
break_offer_loops::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::ipc::{add_mime_type, break_source_loops, destroy_source, SourceData};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::wire::zwp_primary_selection_source_v1::*;
|
||||
|
|
@ -6,8 +8,6 @@ use crate::wire::ZwpPrimarySelectionSourceV1Id;
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::OwnedFd;
|
||||
use crate::ifs::ipc::{add_mime_type, disconnect_source, SourceData};
|
||||
use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
|
||||
pub struct ZwpPrimarySelectionSourceV1 {
|
||||
pub id: ZwpPrimarySelectionSourceV1Id,
|
||||
|
|
@ -42,7 +42,7 @@ impl ZwpPrimarySelectionSourceV1 {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.data.client.parse(self, parser)?;
|
||||
disconnect_source::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
destroy_source::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
self.data.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ impl Object for ZwpPrimarySelectionSourceV1 {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
disconnect_source::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
break_source_loops::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue