Reconnect Clipboard on window close

Fixes #2564
This commit is contained in:
Héctor Ramón Jiménez 2024-09-03 11:23:54 +02:00
parent 9957481d41
commit 9628dc20d5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 46 additions and 22 deletions

View file

@ -2,7 +2,7 @@
use crate::core::clipboard::Kind;
use std::sync::Arc;
use winit::window::Window;
use winit::window::{Window, WindowId};
/// A buffer for short-term storage and transfer within and between
/// applications.
@ -83,6 +83,14 @@ impl Clipboard {
State::Unavailable => {}
}
}
/// Returns the identifier of the window used to create the [`Clipboard`], if any.
pub fn window_id(&self) -> Option<WindowId> {
match &self.state {
State::Connected { window, .. } => Some(window.id()),
State::Unavailable => None,
}
}
}
impl crate::core::Clipboard for Clipboard {