Update smithay for DnD updates
This commit is contained in:
parent
3ddc9421e4
commit
77d3605fb9
12 changed files with 340 additions and 99 deletions
|
|
@ -5,15 +5,14 @@ use smithay::{
|
|||
delegate_data_device,
|
||||
input::{
|
||||
Seat,
|
||||
pointer::{CursorImageStatus, CursorImageSurfaceData},
|
||||
dnd::{DnDGrab, DndGrabHandler, DndTarget, GrabType},
|
||||
pointer::{CursorImageStatus, CursorImageSurfaceData, Focus},
|
||||
},
|
||||
reexports::wayland_server::protocol::{wl_data_source::WlDataSource, wl_surface::WlSurface},
|
||||
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||
utils::{IsAlive, Logical, Point},
|
||||
wayland::{
|
||||
compositor::{self, SurfaceAttributes},
|
||||
selection::data_device::{
|
||||
ClientDndGrabHandler, DataDeviceHandler, DataDeviceState, ServerDndGrabHandler,
|
||||
},
|
||||
selection::data_device::{DataDeviceHandler, DataDeviceState, WaylandDndGrabHandler},
|
||||
},
|
||||
};
|
||||
use std::sync::Mutex;
|
||||
|
|
@ -60,12 +59,14 @@ pub fn on_commit(surface: &WlSurface, seat: &Seat<State>) {
|
|||
}
|
||||
}
|
||||
|
||||
impl ClientDndGrabHandler for State {
|
||||
fn started(
|
||||
impl WaylandDndGrabHandler for State {
|
||||
fn dnd_requested<S: smithay::input::dnd::Source>(
|
||||
&mut self,
|
||||
_source: Option<WlDataSource>,
|
||||
source: S,
|
||||
icon: Option<WlSurface>,
|
||||
seat: Seat<Self>,
|
||||
serial: smithay::utils::Serial,
|
||||
type_: GrabType,
|
||||
) {
|
||||
let user_data = seat.user_data();
|
||||
user_data.insert_if_missing_threadsafe::<Mutex<Option<DnDIcon>>, _>(Default::default);
|
||||
|
|
@ -89,19 +90,46 @@ impl ClientDndGrabHandler for State {
|
|||
.get::<Mutex<Option<DnDIcon>>>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap() = icon.map(|surface| DnDIcon { surface, offset })
|
||||
}
|
||||
.unwrap() = icon.map(|surface| DnDIcon { surface, offset });
|
||||
|
||||
fn dropped(&mut self, _target: Option<WlSurface>, _validated: bool, seat: Seat<Self>) {
|
||||
seat.user_data()
|
||||
.get::<Mutex<Option<DnDIcon>>>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.take();
|
||||
match type_ {
|
||||
GrabType::Pointer => {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let start_data = pointer.grab_start_data().unwrap();
|
||||
pointer.set_grab(
|
||||
self,
|
||||
DnDGrab::new_pointer(&self.common.display_handle, start_data, source, seat),
|
||||
serial,
|
||||
Focus::Keep,
|
||||
);
|
||||
}
|
||||
GrabType::Touch => {
|
||||
let touch = seat.get_touch().unwrap();
|
||||
let start_data = touch.grab_start_data().unwrap();
|
||||
touch.set_grab(
|
||||
self,
|
||||
DnDGrab::new_touch(&self.common.display_handle, start_data, source, seat),
|
||||
serial,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ServerDndGrabHandler for State {}
|
||||
|
||||
impl DndGrabHandler for State {
|
||||
fn dropped(
|
||||
&mut self,
|
||||
_target: Option<DndTarget<'_, Self>>,
|
||||
_validated: bool,
|
||||
seat: Seat<Self>,
|
||||
_location: Point<f64, Logical>,
|
||||
) {
|
||||
if let Some(icon) = seat.user_data().get::<Mutex<Option<DnDIcon>>>() {
|
||||
icon.lock().unwrap().take();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DataDeviceHandler for State {
|
||||
fn data_device_state(&mut self) -> &mut DataDeviceState {
|
||||
&mut self.common.data_device_state
|
||||
|
|
|
|||
|
|
@ -71,9 +71,7 @@ impl SelectionHandler for State {
|
|||
.as_mut()
|
||||
.and_then(|xstate| xstate.xwm.as_mut())
|
||||
{
|
||||
if let Err(err) =
|
||||
xwm.send_selection(target, mime_type, fd, self.common.event_loop_handle.clone())
|
||||
{
|
||||
if let Err(err) = xwm.send_selection(target, mime_type, fd) {
|
||||
warn!(?err, "Failed to send selection (X11 -> Wayland).");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue