autocommit 2022-02-05 02:07:07 CET
This commit is contained in:
parent
89bfd2ffcd
commit
2d8b3a200e
21 changed files with 328 additions and 87 deletions
|
|
@ -2,7 +2,7 @@ use crate::backend::{KeyState, OutputId, ScrollAxis, SeatEvent, SeatId};
|
|||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_data_device::WlDataDevice;
|
||||
use crate::ifs::wl_data_offer::WlDataOfferId;
|
||||
use crate::ifs::wl_data_offer::{WlDataOfferId};
|
||||
use crate::ifs::wl_seat::wl_keyboard::WlKeyboard;
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, POINTER_FRAME_SINCE_VERSION};
|
||||
use crate::ifs::wl_seat::{
|
||||
|
|
@ -241,7 +241,18 @@ impl WlSeatGlobal {
|
|||
k.modifiers(serial, mods_depressed, mods_latched, mods_locked, group)
|
||||
});
|
||||
|
||||
self.surface_data_device_event(0, &surface, |dd| dd.selection(WlDataOfferId::NONE));
|
||||
if old.client_id() != Some(surface.client.id) {
|
||||
match self.selection.get() {
|
||||
None => {
|
||||
self.surface_data_device_event(0, &surface, |dd| {
|
||||
dd.selection(WlDataOfferId::NONE)
|
||||
});
|
||||
}
|
||||
Some(sel) => {
|
||||
sel.create_offer(&surface.client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn for_each_seat<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
|
|
@ -282,7 +293,7 @@ impl WlSeatGlobal {
|
|||
})
|
||||
}
|
||||
|
||||
fn for_each_data_device<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
pub fn for_each_data_device<C>(&self, ver: u32, client: ClientId, mut f: C)
|
||||
where
|
||||
C: FnMut(&Rc<WlDataDevice>),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ use crate::cursor::{Cursor, KnownCursor};
|
|||
use crate::fixed::Fixed;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceId};
|
||||
use crate::ifs::wl_data_offer::{DataOfferRole, WlDataOfferId};
|
||||
use crate::ifs::wl_data_source::{WlDataSource, WlDataSourceError};
|
||||
use crate::ifs::wl_seat::wl_keyboard::{WlKeyboard, WlKeyboardId, REPEAT_INFO_SINCE};
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, WlPointerId};
|
||||
use crate::ifs::wl_seat::wl_touch::WlTouch;
|
||||
|
|
@ -95,6 +97,7 @@ pub struct WlSeatGlobal {
|
|||
serial: NumCell<u32>,
|
||||
grabber: RefCell<Option<PointerGrabber>>,
|
||||
tree_changed: Rc<AsyncEvent>,
|
||||
selection: CloneCell<Option<Rc<WlDataSource>>>,
|
||||
}
|
||||
|
||||
impl WlSeatGlobal {
|
||||
|
|
@ -144,20 +147,31 @@ impl WlSeatGlobal {
|
|||
serial: Default::default(),
|
||||
grabber: RefCell::new(None),
|
||||
tree_changed: tree_changed.clone(),
|
||||
selection: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn grab_pointer(self: &Rc<Self>, node: Rc<dyn Node>) -> Option<PointerGrab> {
|
||||
// let mut grabber = self.grabber.borrow_mut();
|
||||
// if grabber.is_some() {
|
||||
// return None;
|
||||
// }
|
||||
// *grabber = Some(PointerGrabber {
|
||||
// node,
|
||||
// buttons: Default::default(),
|
||||
// });
|
||||
// Some(PointerGrab { seat: self.clone() })
|
||||
// }
|
||||
pub fn set_selection(self: &Rc<Self>, selection: Option<Rc<WlDataSource>>) -> Result<(), WlDataSourceError> {
|
||||
if let Some(new) = &selection {
|
||||
new.attach(self, DataOfferRole::Selection)?;
|
||||
}
|
||||
if let Some(old) = self.selection.set(selection.clone()) {
|
||||
old.detach();
|
||||
}
|
||||
if let Some(client) = self.keyboard_node.get().client() {
|
||||
match selection {
|
||||
Some(sel) => {
|
||||
sel.create_offer(&client);
|
||||
}
|
||||
_ => {
|
||||
self.for_each_data_device(0, client.id, |device| {
|
||||
client.event(device.selection(WlDataOfferId::NONE));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_known_cursor(&self, cursor: KnownCursor) {
|
||||
let cursors = match self.state.cursors.get() {
|
||||
|
|
@ -292,10 +306,6 @@ impl WlSeatObj {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn client(&self) -> &Rc<Client> {
|
||||
&self.client
|
||||
}
|
||||
|
||||
pub fn move_(&self, node: &Rc<FloatNode>) {
|
||||
self.global.move_(node);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue