mirror of
https://github.com/wez/wezterm.git
synced 2024-10-26 15:52:29 +03:00
Fix drag/selection offer retrieval
This commit is contained in:
parent
8ed444cffc
commit
ba18d0590c
@ -2,9 +2,7 @@ use std::os::fd::{FromRawFd, IntoRawFd};
|
||||
|
||||
use filedescriptor::FileDescriptor;
|
||||
use smithay_client_toolkit::data_device_manager::data_device::DataDeviceHandler;
|
||||
use smithay_client_toolkit::data_device_manager::data_offer::{
|
||||
DataOfferHandler, DragOffer, SelectionOffer,
|
||||
};
|
||||
use smithay_client_toolkit::data_device_manager::data_offer::DataOfferHandler;
|
||||
use smithay_client_toolkit::data_device_manager::data_source::DataSourceHandler;
|
||||
use smithay_client_toolkit::data_device_manager::WritePipe;
|
||||
use smithay_client_toolkit::reexports::client::protocol::wl_data_device::WlDataDevice;
|
||||
@ -29,20 +27,27 @@ impl DataDeviceHandler for WaylandState {
|
||||
_qh: &wayland_client::QueueHandle<Self>,
|
||||
data_device: &WlDataDevice,
|
||||
) {
|
||||
let mut drag_offer = data_device.data::<DragOffer>().unwrap();
|
||||
drag_offer.with_mime_types(|mime_types| {
|
||||
let offer = self
|
||||
.data_device
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.data()
|
||||
.drag_offer()
|
||||
.unwrap();
|
||||
|
||||
offer.with_mime_types(|mime_types| {
|
||||
log::trace!(
|
||||
"Data offer entered: {:?}, mime_types: {:?}",
|
||||
drag_offer,
|
||||
offer,
|
||||
mime_types
|
||||
);
|
||||
|
||||
if let Some(mime) = mime_types.iter().find(|s| *s == URI_MIME_TYPE) {
|
||||
drag_offer.accept_mime_type(*self.last_serial.borrow(), Some(mime.clone()));
|
||||
offer.accept_mime_type(*self.last_serial.borrow(), Some(mime.clone()));
|
||||
}
|
||||
});
|
||||
|
||||
drag_offer.set_actions(DndAction::None | DndAction::Copy, DndAction::None);
|
||||
offer.set_actions(DndAction::None | DndAction::Copy, DndAction::None);
|
||||
|
||||
let pointer = self.pointer.as_mut().unwrap();
|
||||
let mut pstate = pointer
|
||||
@ -53,8 +58,8 @@ impl DataDeviceHandler for WaylandState {
|
||||
.lock()
|
||||
.unwrap();
|
||||
|
||||
let offer = drag_offer.inner().clone();
|
||||
let window_id = SurfaceUserData::from_wl(&drag_offer.surface).window_id;
|
||||
let window_id = SurfaceUserData::from_wl(&offer.surface).window_id;
|
||||
let offer = offer.inner().clone();
|
||||
|
||||
pstate.drag_and_drop.offer = Some(SurfaceAndOffer { window_id, offer });
|
||||
}
|
||||
@ -92,7 +97,14 @@ impl DataDeviceHandler for WaylandState {
|
||||
_qh: &wayland_client::QueueHandle<Self>,
|
||||
data_device: &WlDataDevice,
|
||||
) {
|
||||
if let Some(offer) = data_device.data::<SelectionOffer>() {
|
||||
let offer = self
|
||||
.data_device
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.data()
|
||||
.selection_offer()
|
||||
.unwrap();
|
||||
|
||||
if !offer.with_mime_types(|mime_types| mime_types.iter().any(|s| s == TEXT_MIME_TYPE)) {
|
||||
return;
|
||||
}
|
||||
@ -104,7 +116,6 @@ impl DataDeviceHandler for WaylandState {
|
||||
.confirm_selection(offer.inner().clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn drop_performed(
|
||||
&mut self,
|
||||
@ -133,22 +144,6 @@ impl DataDeviceHandler for WaylandState {
|
||||
}
|
||||
|
||||
impl DataOfferHandler for WaylandState {
|
||||
// fn offer(
|
||||
// &mut self,
|
||||
// _conn: &wayland_client::Connection,
|
||||
// _qh: &wayland_client::QueueHandle<Self>,
|
||||
// offer: &mut smithay_client_toolkit::data_device_manager::data_offer::DataDeviceOffer,
|
||||
// mime_type: String,
|
||||
// ) {
|
||||
// log::trace!("Received offer with mime type: {mime_type}");
|
||||
// if mime_type == TEXT_MIME_TYPE {
|
||||
// offer.accept_mime_type(*self.last_serial.borrow(), Some(mime_type));
|
||||
// } else {
|
||||
// // Refuse other mime types
|
||||
// offer.accept_mime_type(*self.last_serial.borrow(), None);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Ignore drag and drop events
|
||||
fn source_actions(
|
||||
&mut self,
|
||||
|
Loading…
Reference in New Issue
Block a user