Skip to content

Commit

Permalink
Merge pull request #1226 from sdroege/winapi-to-windows-sys
Browse files Browse the repository at this point in the history
Move from unmaintained winapi crate to windows-sys
  • Loading branch information
sdroege authored Nov 19, 2023
2 parents 72b073c + 76d4a59 commit 90c77c4
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 61 deletions.
122 changes: 94 additions & 28 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions cairo/src/win32_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::{convert::TryFrom, ops::Deref};

pub use ffi::winapi;
pub use ffi::windows;
#[cfg(feature = "use_glib")]
use glib::translate::*;

Expand All @@ -12,12 +12,12 @@ declare_surface!(Win32Surface, SurfaceType::Win32);

impl Win32Surface {
#[doc(alias = "cairo_win32_surface_create")]
pub fn create(hdc: winapi::HDC) -> Result<Win32Surface, Error> {
pub fn create(hdc: windows::HDC) -> Result<Win32Surface, Error> {
unsafe { Self::from_raw_full(ffi::cairo_win32_surface_create(hdc)) }
}

#[doc(alias = "cairo_win32_surface_create_with_format")]
pub fn create_with_format(hdc: winapi::HDC, format: Format) -> Result<Win32Surface, Error> {
pub fn create_with_format(hdc: windows::HDC, format: Format) -> Result<Win32Surface, Error> {
unsafe {
Self::from_raw_full(ffi::cairo_win32_surface_create_with_format(
hdc,
Expand All @@ -39,7 +39,7 @@ impl Win32Surface {

#[doc(alias = "cairo_win32_surface_create_with_ddb")]
pub fn create_with_ddb(
hdc: winapi::HDC,
hdc: windows::HDC,
format: Format,
width: i32,
height: i32,
Expand All @@ -55,7 +55,7 @@ impl Win32Surface {
}

#[doc(alias = "cairo_win32_printing_surface_create")]
pub fn printing_surface_create(hdc: winapi::HDC) -> Result<Win32Surface, Error> {
pub fn printing_surface_create(hdc: windows::HDC) -> Result<Win32Surface, Error> {
unsafe { Self::from_raw_full(ffi::cairo_win32_printing_surface_create(hdc)) }
}
}
4 changes: 2 additions & 2 deletions cairo/sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ freetype = []
script = []
xcb = []
use_glib = ["glib"]
win32-surface = ["winapi"]
win32-surface = ["windows-sys"]

[dependencies]
libc = "0.2"
Expand All @@ -63,7 +63,7 @@ version = "2.16"
features = ["xlib"]

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.2", features = ["windef"], optional = true }
windows-sys = { version = "0.52", features = ["Win32_Graphics_Gdi"], optional = true }

[build-dependencies]
system-deps = "6"
Expand Down
24 changes: 8 additions & 16 deletions cairo/sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@
#![allow(clippy::upper_case_acronyms)]
#![cfg_attr(docsrs, feature(doc_cfg))]

extern crate libc;

#[cfg(feature = "xlib")]
extern crate x11;

#[cfg(all(windows, feature = "win32-surface"))]
extern crate winapi as winapi_orig;

#[cfg(all(windows, feature = "win32-surface"))]
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
pub mod winapi {
pub use winapi_orig::shared::windef::HDC;
pub mod windows {
pub use windows_sys::Win32::Graphics::Gdi::HDC;
}

#[cfg(all(docsrs, not(all(windows, feature = "win32-surface"))))]
#[cfg_attr(
docsrs,
doc(cfg(all(docsrs, not(all(windows, feature = "win32-surface")))))
)]
pub mod winapi {
pub mod windows {
use libc::c_void;

#[repr(C)]
Expand Down Expand Up @@ -1472,11 +1464,11 @@ extern "C" {
// CAIRO WINDOWS SURFACE
#[cfg(all(windows, feature = "win32-surface"))]
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
pub fn cairo_win32_surface_create(hdc: winapi::HDC) -> *mut cairo_surface_t;
pub fn cairo_win32_surface_create(hdc: windows::HDC) -> *mut cairo_surface_t;
#[cfg(all(windows, feature = "win32-surface"))]
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
pub fn cairo_win32_surface_create_with_format(
hdc: winapi::HDC,
hdc: windows::HDC,
format: cairo_format_t,
) -> *mut cairo_surface_t;
#[cfg(all(windows, feature = "win32-surface"))]
Expand All @@ -1489,17 +1481,17 @@ extern "C" {
#[cfg(all(windows, feature = "win32-surface"))]
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
pub fn cairo_win32_surface_create_with_ddb(
hdc: winapi::HDC,
hdc: windows::HDC,
format: cairo_format_t,
width: c_int,
height: c_int,
) -> *mut cairo_surface_t;
#[cfg(all(windows, feature = "win32-surface"))]
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
pub fn cairo_win32_printing_surface_create(hdc: winapi::HDC) -> *mut cairo_surface_t;
pub fn cairo_win32_printing_surface_create(hdc: windows::HDC) -> *mut cairo_surface_t;
#[cfg(all(windows, feature = "win32-surface"))]
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
pub fn cairo_win32_surface_get_dc(surface: *mut cairo_surface_t) -> winapi::HDC;
pub fn cairo_win32_surface_get_dc(surface: *mut cairo_surface_t) -> windows::HDC;
#[cfg(all(windows, feature = "win32-surface"))]
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
pub fn cairo_win32_surface_get_image(surface: *mut cairo_surface_t) -> *mut cairo_surface_t;
Expand Down
Loading

0 comments on commit 90c77c4

Please sign in to comment.