Don't drop wayland clipboard

This commit is contained in:
Imbris 2020-12-01 19:35:32 -05:00
parent bce6e1c6e9
commit d7f506cf71
7 changed files with 14 additions and 4 deletions

View File

@ -8,6 +8,7 @@
changes:
- "**/*.{glsl,rs,ron,toml,vox,png}"
- "rust-toolchain"
- "Cargo.lock"
- ".gitlab-ci.yml"
- "**/*.yml"
@ -19,5 +20,6 @@
- changes:
- "**/*.{glsl,rs,ron,toml,vox,png,wav}"
- "rust-toolchain"
- "Cargo.lock"
- ".gitlab-ci.yml"
- "**/*.yml"

View File

@ -78,6 +78,6 @@ inherits = 'release'
debug = 1
[patch.crates-io]
# cpal conflict fix isn't released yet
# macos CI fix isn't merged yet
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics" }

View File

@ -53,6 +53,7 @@ pub struct GlobalState {
pub singleplayer: Option<Singleplayer>,
// TODO: redo this so that the watcher doesn't have to exist for reloading to occur
pub localization_watcher: watch::ReloadIndicator,
pub clipboard: Option<iced_winit::Clipboard>,
}
impl GlobalState {

View File

@ -178,6 +178,8 @@ fn main() {
// Create window
let (window, event_loop) = Window::new(&settings).expect("Failed to create window!");
let clipboard = iced_winit::Clipboard::new(window.window());
let global_state = GlobalState {
audio,
profile,
@ -190,6 +192,7 @@ fn main() {
#[cfg(feature = "singleplayer")]
singleplayer: None,
localization_watcher,
clipboard,
};
run::run(global_state, event_loop);

View File

@ -1498,6 +1498,7 @@ impl CharSelectionUi {
let (mut messages, _) = self.ui.maintain(
self.controls.view(&global_state.settings, &client),
global_state.window.renderer_mut(),
global_state.clipboard.as_ref(),
);
if self.enter_pressed {

View File

@ -590,6 +590,7 @@ impl<'a> MainMenuUi {
let (messages, _) = self.ui.maintain(
self.controls.view(&global_state.settings, dt.as_secs_f32()),
global_state.window.renderer_mut(),
global_state.clipboard.as_ref(),
);
messages.into_iter().for_each(|message| {

View File

@ -26,7 +26,6 @@ pub struct IcedUi {
renderer: IcedRenderer,
cache: Option<Cache>,
events: Vec<Event>,
clipboard: Clipboard,
cursor_position: Vec2<f32>,
// Scaling of the ui
scale: Scale,
@ -55,7 +54,6 @@ impl IcedUi {
cache: Some(Cache::new()),
events: Vec::new(),
// TODO: handle None
clipboard: Clipboard::new(window.window()).unwrap(),
cursor_position: Vec2::zero(),
scale,
scale_changed: false,
@ -146,6 +144,7 @@ impl IcedUi {
&mut self,
root: E,
renderer: &mut Renderer,
clipboard: Option<&Clipboard>,
) -> (Vec<M>, mouse::Interaction) {
span!(_guard, "maintain", "IcedUi::maintain");
// Handle window resizing, dpi factor change, and scale mode changing
@ -188,7 +187,10 @@ impl IcedUi {
let messages = user_interface.update(
&self.events,
cursor_position,
Some(&self.clipboard),
match clipboard {
Some(c) => Some(c),
None => None,
},
&self.renderer,
);
drop(guard);