Skip to content

Commit 1276fd6

Browse files
committed
Move from unmaintained winapi crate to windows-sys
windows-sys / windows is also used by the gdk4-win32 crate.
1 parent 855d3ad commit 1276fd6

File tree

6 files changed

+114
-49
lines changed

6 files changed

+114
-49
lines changed

Cargo.lock

Lines changed: 82 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cairo/src/win32_surface.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
pub use ffi::winapi;
5+
pub use ffi::windows;
66
#[cfg(feature = "use_glib")]
77
use glib::translate::*;
88

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

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

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

4040
#[doc(alias = "cairo_win32_surface_create_with_ddb")]
4141
pub fn create_with_ddb(
42-
hdc: winapi::HDC,
42+
hdc: windows::HDC,
4343
format: Format,
4444
width: i32,
4545
height: i32,
@@ -55,7 +55,7 @@ impl Win32Surface {
5555
}
5656

5757
#[doc(alias = "cairo_win32_printing_surface_create")]
58-
pub fn printing_surface_create(hdc: winapi::HDC) -> Result<Win32Surface, Error> {
58+
pub fn printing_surface_create(hdc: windows::HDC) -> Result<Win32Surface, Error> {
5959
unsafe { Self::from_raw_full(ffi::cairo_win32_printing_surface_create(hdc)) }
6060
}
6161
}

cairo/sys/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ freetype = []
4747
script = []
4848
xcb = []
4949
use_glib = ["glib"]
50-
win32-surface = ["winapi"]
50+
win32-surface = ["windows-sys"]
5151

5252
[dependencies]
5353
libc = "0.2"
@@ -63,7 +63,7 @@ version = "2.16"
6363
features = ["xlib"]
6464

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

6868
[build-dependencies]
6969
system-deps = "6"

cairo/sys/src/lib.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,18 @@
66
#![allow(clippy::upper_case_acronyms)]
77
#![cfg_attr(docsrs, feature(doc_cfg))]
88

9-
extern crate libc;
10-
11-
#[cfg(feature = "xlib")]
12-
extern crate x11;
13-
14-
#[cfg(all(windows, feature = "win32-surface"))]
15-
extern crate winapi as winapi_orig;
16-
179
#[cfg(all(windows, feature = "win32-surface"))]
1810
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
19-
pub mod winapi {
20-
pub use winapi_orig::shared::windef::HDC;
11+
pub mod windows {
12+
pub use windows_sys::Win32::Graphics::Gdi::HDC;
2113
}
2214

2315
#[cfg(all(docsrs, not(all(windows, feature = "win32-surface"))))]
2416
#[cfg_attr(
2517
docsrs,
2618
doc(cfg(all(docsrs, not(all(windows, feature = "win32-surface")))))
2719
)]
28-
pub mod winapi {
20+
pub mod windows {
2921
use libc::c_void;
3022

3123
#[repr(C)]
@@ -1472,11 +1464,11 @@ extern "C" {
14721464
// CAIRO WINDOWS SURFACE
14731465
#[cfg(all(windows, feature = "win32-surface"))]
14741466
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
1475-
pub fn cairo_win32_surface_create(hdc: winapi::HDC) -> *mut cairo_surface_t;
1467+
pub fn cairo_win32_surface_create(hdc: windows::HDC) -> *mut cairo_surface_t;
14761468
#[cfg(all(windows, feature = "win32-surface"))]
14771469
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
14781470
pub fn cairo_win32_surface_create_with_format(
1479-
hdc: winapi::HDC,
1471+
hdc: windows::HDC,
14801472
format: cairo_format_t,
14811473
) -> *mut cairo_surface_t;
14821474
#[cfg(all(windows, feature = "win32-surface"))]
@@ -1489,17 +1481,17 @@ extern "C" {
14891481
#[cfg(all(windows, feature = "win32-surface"))]
14901482
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
14911483
pub fn cairo_win32_surface_create_with_ddb(
1492-
hdc: winapi::HDC,
1484+
hdc: windows::HDC,
14931485
format: cairo_format_t,
14941486
width: c_int,
14951487
height: c_int,
14961488
) -> *mut cairo_surface_t;
14971489
#[cfg(all(windows, feature = "win32-surface"))]
14981490
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
1499-
pub fn cairo_win32_printing_surface_create(hdc: winapi::HDC) -> *mut cairo_surface_t;
1491+
pub fn cairo_win32_printing_surface_create(hdc: windows::HDC) -> *mut cairo_surface_t;
15001492
#[cfg(all(windows, feature = "win32-surface"))]
15011493
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
1502-
pub fn cairo_win32_surface_get_dc(surface: *mut cairo_surface_t) -> winapi::HDC;
1494+
pub fn cairo_win32_surface_get_dc(surface: *mut cairo_surface_t) -> windows::HDC;
15031495
#[cfg(all(windows, feature = "win32-surface"))]
15041496
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "win32-surface"))))]
15051497
pub fn cairo_win32_surface_get_image(surface: *mut cairo_surface_t) -> *mut cairo_surface_t;

gio/sys/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ path = "../../glib/sys"
1212
package = "gobject-sys"
1313
path = "../../glib/gobject-sys"
1414

15-
[target."cfg(windows)".dependencies.winapi]
16-
version = "0.3.9"
17-
features = ["ws2def", "winsock2"]
15+
[target."cfg(windows)".dependencies.windows-sys]
16+
version = "0.52"
17+
features = ["Win32_Networking_WinSock"]
1818

1919
[dev-dependencies]
2020
shell-words = "1.0.0"

gio/sys/src/manual.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@ pub type GSocketMsgFlags = libc::c_int;
1010

1111
#[cfg(target_family = "windows")]
1212
mod windows_constants {
13-
pub const G_SOCKET_FAMILY_INVALID: super::GSocketFamily = winapi::shared::ws2def::AF_UNSPEC;
14-
pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily = winapi::shared::ws2def::AF_UNIX;
15-
pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily = winapi::shared::ws2def::AF_INET;
16-
pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily = winapi::shared::ws2def::AF_INET6;
13+
pub const G_SOCKET_FAMILY_INVALID: super::GSocketFamily =
14+
windows_sys::Win32::Networking::WinSock::AF_UNSPEC as super::GSocketFamily;
15+
pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily =
16+
windows_sys::Win32::Networking::WinSock::AF_UNIX as super::GSocketFamily;
17+
pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily =
18+
windows_sys::Win32::Networking::WinSock::AF_INET as super::GSocketFamily;
19+
pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily =
20+
windows_sys::Win32::Networking::WinSock::AF_INET6 as super::GSocketFamily;
1721

1822
pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0;
19-
pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = winapi::um::winsock2::MSG_OOB;
20-
pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = winapi::um::winsock2::MSG_PEEK;
21-
pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = winapi::um::winsock2::MSG_DONTROUTE;
23+
pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags =
24+
windows_sys::Win32::Networking::WinSock::MSG_OOB;
25+
pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags =
26+
windows_sys::Win32::Networking::WinSock::MSG_PEEK;
27+
pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags =
28+
windows_sys::Win32::Networking::WinSock::MSG_DONTROUTE;
2229
}
2330

2431
#[cfg(not(target_family = "windows"))]

0 commit comments

Comments
 (0)