Update smithay, with cursor/selection changes
We'll probably want to add support for `cursor-shape-v1`. Not sure about `wlr-data-control-unstable-v1`. But this just updates to work with the latest smithay commit for new.
This commit is contained in:
parent
c32b8d3cb7
commit
111eb4edf4
12 changed files with 109 additions and 186 deletions
|
|
@ -6,14 +6,11 @@ use smithay::{
|
|||
input::Seat,
|
||||
reexports::wayland_server::protocol::{wl_data_source::WlDataSource, wl_surface::WlSurface},
|
||||
utils::IsAlive,
|
||||
wayland::data_device::{
|
||||
with_source_metadata, ClientDndGrabHandler, DataDeviceHandler, DataDeviceState,
|
||||
ServerDndGrabHandler,
|
||||
wayland::selection::data_device::{
|
||||
ClientDndGrabHandler, DataDeviceHandler, DataDeviceState, ServerDndGrabHandler,
|
||||
},
|
||||
xwayland::xwm::{SelectionType, XwmId},
|
||||
};
|
||||
use std::{cell::RefCell, os::unix::io::OwnedFd};
|
||||
use tracing::warn;
|
||||
use std::cell::RefCell;
|
||||
|
||||
pub struct DnDIcon {
|
||||
surface: RefCell<Option<WlSurface>>,
|
||||
|
|
@ -51,54 +48,9 @@ impl ClientDndGrabHandler for State {
|
|||
}
|
||||
impl ServerDndGrabHandler for State {}
|
||||
impl DataDeviceHandler for State {
|
||||
type SelectionUserData = XwmId;
|
||||
|
||||
fn data_device_state(&self) -> &DataDeviceState {
|
||||
&self.common.data_device_state
|
||||
}
|
||||
|
||||
fn new_selection(&mut self, source: Option<WlDataSource>, _seat: Seat<State>) {
|
||||
if let Some(state) = self.common.xwayland_state.as_mut() {
|
||||
if let Some(xwm) = state.xwm.as_mut() {
|
||||
if let Some(source) = &source {
|
||||
if let Ok(Err(err)) = with_source_metadata(source, |metadata| {
|
||||
xwm.new_selection(
|
||||
SelectionType::Clipboard,
|
||||
Some(metadata.mime_types.clone()),
|
||||
)
|
||||
}) {
|
||||
warn!(?err, "Failed to set Xwayland clipboard selection.");
|
||||
}
|
||||
} else if let Err(err) = xwm.new_selection(SelectionType::Clipboard, None) {
|
||||
warn!(?err, "Failed to clear Xwayland clipboard selection.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn send_selection(
|
||||
&mut self,
|
||||
mime_type: String,
|
||||
fd: OwnedFd,
|
||||
_seat: Seat<State>,
|
||||
_user_data: &Self::SelectionUserData,
|
||||
) {
|
||||
if let Some(xwm) = self
|
||||
.common
|
||||
.xwayland_state
|
||||
.as_mut()
|
||||
.and_then(|xstate| xstate.xwm.as_mut())
|
||||
{
|
||||
if let Err(err) = xwm.send_selection(
|
||||
SelectionType::Clipboard,
|
||||
mime_type,
|
||||
fd,
|
||||
self.common.event_loop_handle.clone(),
|
||||
) {
|
||||
warn!(?err, "Failed to send clipboard (X11 -> Wayland).");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delegate_data_device!(State);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub mod relative_pointer;
|
|||
pub mod screencopy;
|
||||
pub mod seat;
|
||||
pub mod security_context;
|
||||
pub mod selection;
|
||||
pub mod shm;
|
||||
pub mod toplevel_info;
|
||||
pub mod toplevel_management;
|
||||
|
|
|
|||
|
|
@ -3,58 +3,13 @@
|
|||
use crate::state::State;
|
||||
use smithay::{
|
||||
delegate_primary_selection,
|
||||
wayland::primary_selection::{PrimarySelectionHandler, PrimarySelectionState, with_source_metadata}, xwayland::xwm::{XwmId, SelectionType}, reexports::wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, input::Seat,
|
||||
wayland::selection::primary_selection::{PrimarySelectionHandler, PrimarySelectionState},
|
||||
};
|
||||
use tracing::warn;
|
||||
|
||||
use std::os::unix::io::OwnedFd;
|
||||
|
||||
impl PrimarySelectionHandler for State {
|
||||
type SelectionUserData = XwmId;
|
||||
|
||||
fn primary_selection_state(&self) -> &PrimarySelectionState {
|
||||
&self.common.primary_selection_state
|
||||
}
|
||||
|
||||
fn new_selection(&mut self, source: Option<ZwpPrimarySelectionSourceV1>, _seat: Seat<State>) {
|
||||
if let Some(state) = self.common.xwayland_state.as_mut() {
|
||||
if let Some(xwm) = state.xwm.as_mut() {
|
||||
if let Some(source) = &source {
|
||||
if let Ok(Err(err)) = with_source_metadata(source, |metadata| {
|
||||
xwm.new_selection(SelectionType::Primary, Some(metadata.mime_types.clone()))
|
||||
}) {
|
||||
warn!(?err, "Failed to set Xwayland primary selection");
|
||||
}
|
||||
} else if let Err(err) = xwm.new_selection(SelectionType::Primary, None) {
|
||||
warn!(?err, "Failed to clear Xwayland primary selection");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn send_selection(
|
||||
&mut self,
|
||||
mime_type: String,
|
||||
fd: OwnedFd,
|
||||
_seat: Seat<State>,
|
||||
_user_data: &Self::SelectionUserData,
|
||||
) {
|
||||
if let Some(xwm) = self
|
||||
.common
|
||||
.xwayland_state
|
||||
.as_mut()
|
||||
.and_then(|xstate| xstate.xwm.as_mut())
|
||||
{
|
||||
if let Err(err) = xwm.send_selection(
|
||||
SelectionType::Primary,
|
||||
mime_type,
|
||||
fd,
|
||||
self.common.event_loop_handle.clone(),
|
||||
) {
|
||||
warn!(?err, "Failed to send primary selection (X11 -> Wayland).");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delegate_primary_selection!(State);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use smithay::{
|
|||
input::{pointer::CursorImageStatus, SeatHandler, SeatState},
|
||||
reexports::wayland_server::Resource,
|
||||
wayland::{
|
||||
data_device::set_data_device_focus, primary_selection::set_primary_focus,
|
||||
seat::WaylandFocus,
|
||||
seat::WaylandFocus, selection::data_device::set_data_device_focus,
|
||||
selection::primary_selection::set_primary_focus,
|
||||
},
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
|
|
|
|||
58
src/wayland/handlers/selection.rs
Normal file
58
src/wayland/handlers/selection.rs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::state::State;
|
||||
use smithay::{
|
||||
input::Seat,
|
||||
wayland::selection::{SelectionHandler, SelectionSource, SelectionTarget},
|
||||
xwayland::xwm::XwmId,
|
||||
};
|
||||
use std::os::unix::io::OwnedFd;
|
||||
use tracing::warn;
|
||||
|
||||
impl SelectionHandler for State {
|
||||
type SelectionUserData = XwmId;
|
||||
|
||||
fn new_selection(
|
||||
&mut self,
|
||||
target: SelectionTarget,
|
||||
source: Option<SelectionSource>,
|
||||
_seat: Seat<State>,
|
||||
) {
|
||||
if let Some(xwm) = self
|
||||
.common
|
||||
.xwayland_state
|
||||
.as_mut()
|
||||
.and_then(|xstate| xstate.xwm.as_mut())
|
||||
{
|
||||
if let Some(source) = &source {
|
||||
if let Err(err) = xwm.new_selection(target, Some(source.mime_types())) {
|
||||
warn!(?err, "Failed to set Xwayland clipboard selection.");
|
||||
}
|
||||
} else if let Err(err) = xwm.new_selection(target, None) {
|
||||
warn!(?err, "Failed to clear Xwayland selection.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn send_selection(
|
||||
&mut self,
|
||||
target: SelectionTarget,
|
||||
mime_type: String,
|
||||
fd: OwnedFd,
|
||||
_seat: Seat<State>,
|
||||
_user_data: &Self::SelectionUserData,
|
||||
) {
|
||||
if let Some(xwm) = self
|
||||
.common
|
||||
.xwayland_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())
|
||||
{
|
||||
warn!(?err, "Failed to send selection (X11 -> Wayland).");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue