seat: ignore duplicate set_selection request
This works around [1] and [2]. [1]: https://gitlab.gnome.org/GNOME/gtk/-/issues/5097 [2]: https://github.com/mahkoh/jay/issues/47
This commit is contained in:
parent
a8f627f15c
commit
0fe59effe2
4 changed files with 14 additions and 0 deletions
|
|
@ -63,6 +63,7 @@ pub trait IpcVtable: Sized {
|
||||||
fn send_send(src: &Rc<Self::Source>, mime_type: &str, fd: Rc<OwnedFd>);
|
fn send_send(src: &Rc<Self::Source>, mime_type: &str, fd: Rc<OwnedFd>);
|
||||||
fn remove_from_seat(device: &Self::Device);
|
fn remove_from_seat(device: &Self::Device);
|
||||||
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal>;
|
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal>;
|
||||||
|
fn source_eq(left: &Self::Source, right: &Self::Source) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DeviceData<T: IpcVtable> {
|
pub struct DeviceData<T: IpcVtable> {
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,10 @@ impl IpcVtable for ClipboardIpc {
|
||||||
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal> {
|
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal> {
|
||||||
offer.device.seat.clone()
|
offer.device.seat.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn source_eq(left: &Self::Source, right: &Self::Source) -> bool {
|
||||||
|
left as *const _ == right as *const _
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object_base! {
|
object_base! {
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,10 @@ impl IpcVtable for PrimarySelectionIpc {
|
||||||
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal> {
|
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal> {
|
||||||
offer.seat.clone()
|
offer.seat.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn source_eq(left: &Self::Source, right: &Self::Source) -> bool {
|
||||||
|
left as *const _ == right as *const _
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object_base! {
|
object_base! {
|
||||||
|
|
|
||||||
|
|
@ -673,6 +673,11 @@ impl WlSeatGlobal {
|
||||||
field: &CloneCell<Option<Rc<T::Source>>>,
|
field: &CloneCell<Option<Rc<T::Source>>>,
|
||||||
src: Option<Rc<T::Source>>,
|
src: Option<Rc<T::Source>>,
|
||||||
) -> Result<(), WlSeatError> {
|
) -> Result<(), WlSeatError> {
|
||||||
|
if let (Some(new), Some(old)) = (&src, &field.get()) {
|
||||||
|
if T::source_eq(old, new) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(new) = &src {
|
if let Some(new) = &src {
|
||||||
ipc::attach_seat::<T>(new, self, ipc::Role::Selection)?;
|
ipc::attach_seat::<T>(new, self, ipc::Role::Selection)?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue