Skip to content

Commit

Permalink
Make XcbWindowHandle use NonZeroU32
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jul 30, 2023
1 parent d7d8cc2 commit ec925f6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/unix.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::num::NonZeroU32;

Check failure on line 1 in src/unix.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/raw-window-handle/raw-window-handle/src/unix.rs
use core::ffi::{c_int, c_ulong, c_void};
use core::ptr::NonNull;

Expand Down Expand Up @@ -114,9 +115,9 @@ impl XcbDisplayHandle {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct XcbWindowHandle {
/// An X11 `xcb_window_t`.
pub window: u32, // Based on xproto.h
/// An X11 `xcb_visualid_t`, or 0 if unknown.
pub visual_id: u32,
pub window: NonZeroU32, // Based on xproto.h
/// An X11 `xcb_visualid_t`.
pub visual_id: Option<NonZeroU32>,
}

impl XcbWindowHandle {
Expand All @@ -129,15 +130,15 @@ impl XcbWindowHandle {
/// # use raw_window_handle::XcbWindowHandle;
/// #
/// let window: u32;
/// # window = 0;
/// # window = NonZeroU32::new(1).unwrap();

Check failure on line 133 in src/unix.rs

View workflow job for this annotation

GitHub Actions / Tests (1.64)

failed to resolve: use of undeclared type `NonZeroU32`
/// let mut handle = XcbWindowHandle::new(window);

Check failure on line 134 in src/unix.rs

View workflow job for this annotation

GitHub Actions / Tests (1.64)

mismatched types

Check failure on line 134 in src/unix.rs

View workflow job for this annotation

GitHub Actions / Tests (stable)

failed to resolve: use of undeclared type `NonZeroU32`

Check failure on line 134 in src/unix.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly)

failed to resolve: use of undeclared type `NonZeroU32`
/// // Optionally set the visual ID.

Check failure on line 135 in src/unix.rs

View workflow job for this annotation

GitHub Actions / Tests (stable)

mismatched types

Check failure on line 135 in src/unix.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly)

mismatched types
/// handle.visual_id = 0;
/// handle.visual_id = None;
/// ```
pub fn new(window: u32) -> Self {
pub fn new(window: NonZeroU32) -> Self {
Self {
window,
visual_id: 0,
visual_id: None,
}
}
}
Expand Down

0 comments on commit ec925f6

Please sign in to comment.