From d7f506cf71ee1f07539a587a86fc4903971c73ed Mon Sep 17 00:00:00 2001 From: Imbris Date: Tue, 1 Dec 2020 19:35:32 -0500 Subject: [PATCH] Don't drop wayland clipboard --- .gitlab/CI/recompile.yml | 2 ++ Cargo.toml | 2 +- voxygen/src/lib.rs | 1 + voxygen/src/main.rs | 3 +++ voxygen/src/menu/char_selection/ui/mod.rs | 1 + voxygen/src/menu/main/ui/mod.rs | 1 + voxygen/src/ui/ice/mod.rs | 8 +++++--- 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitlab/CI/recompile.yml b/.gitlab/CI/recompile.yml index 1fab4acba1..63b8e0ef7a 100644 --- a/.gitlab/CI/recompile.yml +++ b/.gitlab/CI/recompile.yml @@ -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" diff --git a/Cargo.toml b/Cargo.toml index 2c2721a2f2..24ce89fc7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/voxygen/src/lib.rs b/voxygen/src/lib.rs index aba949ac98..6675f4781f 100644 --- a/voxygen/src/lib.rs +++ b/voxygen/src/lib.rs @@ -53,6 +53,7 @@ pub struct GlobalState { pub singleplayer: Option, // TODO: redo this so that the watcher doesn't have to exist for reloading to occur pub localization_watcher: watch::ReloadIndicator, + pub clipboard: Option, } impl GlobalState { diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 58e8d63078..1181d4ed87 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -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); diff --git a/voxygen/src/menu/char_selection/ui/mod.rs b/voxygen/src/menu/char_selection/ui/mod.rs index a66011cde1..614d0cc9b1 100644 --- a/voxygen/src/menu/char_selection/ui/mod.rs +++ b/voxygen/src/menu/char_selection/ui/mod.rs @@ -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 { diff --git a/voxygen/src/menu/main/ui/mod.rs b/voxygen/src/menu/main/ui/mod.rs index dcd42ddd73..6852b1f210 100644 --- a/voxygen/src/menu/main/ui/mod.rs +++ b/voxygen/src/menu/main/ui/mod.rs @@ -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| { diff --git a/voxygen/src/ui/ice/mod.rs b/voxygen/src/ui/ice/mod.rs index b7f20b05e6..6cc78329a6 100644 --- a/voxygen/src/ui/ice/mod.rs +++ b/voxygen/src/ui/ice/mod.rs @@ -26,7 +26,6 @@ pub struct IcedUi { renderer: IcedRenderer, cache: Option, events: Vec, - clipboard: Clipboard, cursor_position: Vec2, // 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, 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);