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

View File

@ -78,6 +78,6 @@ inherits = 'release'
debug = 1 debug = 1
[patch.crates-io] [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" } winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics" } vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics" }

View File

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

View File

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

View File

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

View File

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

View File

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