Skip to content

Commit

Permalink
gdk4-win32: Fix isize / *mut c_void mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Aug 27, 2024
1 parent fd28460 commit 276c2c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions gdk4-win32/src/win32_hcursor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::ptr::NonNull;
use std::{ffi::c_void, ptr::NonNull};

use glib::{translate::*, types::Pointee};

Expand All @@ -17,14 +17,14 @@ impl Win32HCursor {
unsafe {
from_glib_full(ffi::gdk_win32_hcursor_new(
display.as_ref().to_glib_none().0,
handle.0,
handle.0 as isize,
destroyable.into_glib(),
))
}
}

pub fn handle(&self) -> HCURSOR {
let ptr: NonNull<Pointee> = ObjectExt::property(self, "handle");
HCURSOR(ptr.as_ptr() as _)
HCURSOR(ptr.as_ptr() as *mut c_void)

Check warning on line 28 in gdk4-win32/src/win32_hcursor.rs

View workflow job for this annotation

GitHub Actions / Windows MSVC

casting raw pointers to the same type and constness is unnecessary (`*mut libc::c_void` -> `*mut libc::c_void`)
}
}
11 changes: 8 additions & 3 deletions gdk4-win32/src/win32_surface.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::ffi::c_void;

use glib::translate::*;

use crate::{ffi, prelude::*, Win32Surface, HWND};
Expand All @@ -14,22 +16,25 @@ impl Win32Surface {
unsafe {
from_glib_none(ffi::gdk_win32_surface_lookup_for_display(
display.as_ref().to_glib_none().0,
anid.0,
anid.0 as isize,
))
}
}

#[doc(alias = "gdk_win32_surface_get_handle")]
#[doc(alias = "get_handle")]
pub fn handle(&self) -> HWND {
HWND(unsafe { ffi::gdk_win32_surface_get_handle(self.to_glib_none().0) })
HWND(unsafe { ffi::gdk_win32_surface_get_handle(self.to_glib_none().0) } as *mut c_void)
}

#[cfg_attr(feature = "v4_8", deprecated = "Since 4.8")]
#[doc(alias = "gdk_win32_surface_get_impl_hwnd")]
#[doc(alias = "get_impl_hwnd")]
pub fn impl_hwnd(surface: &impl IsA<gdk::Surface>) -> HWND {
assert_initialized_main_thread!();
HWND(unsafe { ffi::gdk_win32_surface_get_impl_hwnd(surface.as_ref().to_glib_none().0) })
HWND(
unsafe { ffi::gdk_win32_surface_get_impl_hwnd(surface.as_ref().to_glib_none().0) }
as *mut c_void,
)
}
}

0 comments on commit 276c2c0

Please sign in to comment.