server: verify selection offer is still valid when handling clipboard

Should fix #170, fix #183
This commit is contained in:
Shawn Wallace 2025-06-29 01:37:24 -04:00
parent 2e7c318ac2
commit cf1fae1eae
4 changed files with 49 additions and 14 deletions

View file

@ -695,6 +695,20 @@ impl Server {
self.display.flush_clients().unwrap();
}
#[track_caller]
pub fn empty_data_offer(&mut self) {
let Some(dev) = &self.state.data_device else {
panic!("No data device created");
};
if let Some(selection) = self.state.selection.take() {
selection.cancelled();
}
dev.selection(None);
self.display.flush_clients().unwrap();
}
#[track_caller]
pub fn move_pointer_to(&mut self, surface: SurfaceId, x: f64, y: f64) {
let pointer = self.state.pointer.as_ref().expect("No pointer created");