Skip to content

Commit

Permalink
Update clipboard-win to v5 and replace winapi with windows-sys (#123)
Browse files Browse the repository at this point in the history
* Refactor Windows code to be more idiomatic
  • Loading branch information
rhysd committed Dec 4, 2023
1 parent 1b8df75 commit a100f2d
Show file tree
Hide file tree
Showing 4 changed files with 387 additions and 371 deletions.
22 changes: 5 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rust-version = "1.61"

[features]
default = ["image-data"]
image-data = ["core-graphics", "image", "winapi/minwindef", "winapi/wingdi", "winapi/winnt"]
image-data = ["core-graphics", "image", "windows-sys"]
wayland-data-control = ["wl-clipboard-rs"]

[dependencies]
Expand All @@ -22,12 +22,14 @@ thiserror = "1.0"
env_logger = "0.9.0"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", optional = true, features = [
"basetsd",
"winuser",
"winbase",
windows-sys = { version = "0.48.0", optional = true, features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_System_DataExchange",
"Win32_System_Memory",
"Win32_System_Ole",
]}
clipboard-win = "4.4.2"
clipboard-win = "5.0.0"
log = "0.4"

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
7 changes: 7 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ impl std::fmt::Debug for Error {
}
}

impl Error {
#[cfg(windows)]
pub(crate) fn unknown<M: Into<String>>(message: M) -> Self {
Error::Unknown { description: message.into() }
}
}

/// Stores pixel data of an image.
///
/// Each element in `bytes` stores the value of a channel of a single pixel.
Expand Down

0 comments on commit a100f2d

Please sign in to comment.