1
0
Fork 0
forked from wry/wry

autocommit 2022-02-06 19:56:51 CET

This commit is contained in:
Julian Orth 2022-02-06 19:56:51 +01:00
parent 1fdff156ec
commit 3f50b0c75e
37 changed files with 452 additions and 439 deletions

View file

@ -1,5 +1,5 @@
use crate::client::{Client, ClientError, DynEventFormatter};
use std::mem;
use crate::client::{Client, ClientError};
use crate::ifs::wl_data_source::WlDataSource;
use crate::ifs::wl_seat::WlSeatGlobal;
use crate::object::Object;
@ -54,22 +54,29 @@ impl WlDataOffer {
source: CloneCell::new(Some(src.clone())),
});
let mt = src.mime_types.borrow_mut();
let mut sent_offer = false;
seat.for_each_data_device(0, client.id, |device| {
client.event(device.data_offer(slf.id));
for mt in mt.deref() {
client.event(slf.offer(mt));
if !mem::replace(&mut sent_offer, true) {
device.send_data_offer(slf.id);
}
for mt in mt.deref() {
slf.send_offer(mt);
}
match role {
DataOfferRole::Selection => device.send_selection(id),
}
let ev = match role {
DataOfferRole::Selection => device.selection(id),
};
client.event(ev);
});
client.add_server_obj(&slf);
Some(slf)
if !sent_offer {
let _ = client.remove_obj(&*slf);
None
} else {
Some(slf)
}
}
pub fn offer(self: &Rc<Self>, mime_type: &str) -> DynEventFormatter {
Box::new(OfferOut {
pub fn send_offer(self: &Rc<Self>, mime_type: &str) {
self.client.event(OfferOut {
self_id: self.id,
mime_type: mime_type.to_string(),
})
@ -83,7 +90,7 @@ impl WlDataOffer {
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ReceiveError> {
let req: ReceiveIn = self.client.parse(self, parser)?;
if let Some(src) = self.source.get() {
src.client.event(src.send(req.mime_type, req.fd));
src.send_send(req.mime_type, req.fd);
src.client.flush();
}
Ok(())