diff --git a/Cargo.toml b/Cargo.toml index 44cb224..fd77e4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ thiserror = "1.0" env_logger = "0.9.0" [target.'cfg(windows)'.dependencies] -winapi = { version = "0.3.9", features = [ +winapi = { version = "0.3.9", optional = true, features = [ "basetsd", "winuser", "winbase", diff --git a/src/platform/windows.rs b/src/platform/windows.rs index c17d2d6..60dfa1f 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -8,7 +8,7 @@ the Apache 2.0 or the MIT license at the licensee's choice. The terms and conditions of the chosen license apply to this file. */ -use std::{borrow::Cow, marker::PhantomData}; +use std::{borrow::Cow, marker::PhantomData, thread, time::Duration}; #[cfg(feature = "image-data")] use std::{convert::TryInto, mem::size_of}; @@ -400,8 +400,7 @@ impl Clipboard { } // The default value matches Chromium's implementation, but could be tweaked later. - // Safety: This is safe to call with any integer. - unsafe { winapi::um::synchapi::Sleep(5) }; + thread::sleep(Duration::from_millis(5)); } .map_err(|_| Error::ClipboardOccupied)?;