gdk4_win32/win32_surface.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::ffi::c_void;
4
5use glib::translate::*;
6
7use crate::{ffi, prelude::*, Win32Surface, HWND};
8
9impl Win32Surface {
10 /// ## `display`
11 /// a [`gdk::Display`][crate::gdk::Display]
12 /// ## `anid`
13 /// a HWND window handle
14 ///
15 /// # Returns
16 ///
17 /// the [`gdk::Surface`][crate::gdk::Surface] associated with the given @anid, or [`None`].
18 #[doc(alias = "gdk_win32_surface_lookup_for_display")]
19 pub fn lookup_for_display(
20 display: &impl IsA<gdk::Display>,
21 anid: HWND,
22 ) -> Option<gdk::Surface> {
23 assert_initialized_main_thread!();
24 unsafe {
25 from_glib_none(ffi::gdk_win32_surface_lookup_for_display(
26 display.as_ref().to_glib_none().0,
27 anid.0 as isize,
28 ))
29 }
30 }
31
32 /// Returns the HWND handle belonging to @self.
33 ///
34 /// # Returns
35 ///
36 /// the associated HWND handle.
37 #[doc(alias = "gdk_win32_surface_get_handle")]
38 #[doc(alias = "get_handle")]
39 pub fn handle(&self) -> HWND {
40 HWND(unsafe { ffi::gdk_win32_surface_get_handle(self.to_glib_none().0) } as *mut c_void)
41 }
42
43 ///
44 /// # Deprecated since 4.8
45 ///
46 /// Use gdk_win32_surface_get_handle() instead.
47 /// ## `surface`
48 /// a [`gdk::Surface`][crate::gdk::Surface]
49 ///
50 /// # Returns
51 ///
52 /// the associated @surface HWND handle.
53 #[cfg_attr(feature = "v4_8", deprecated = "Since 4.8")]
54 #[doc(alias = "gdk_win32_surface_get_impl_hwnd")]
55 #[doc(alias = "get_impl_hwnd")]
56 pub fn impl_hwnd(surface: &impl IsA<gdk::Surface>) -> HWND {
57 assert_initialized_main_thread!();
58 HWND(
59 unsafe { ffi::gdk_win32_surface_get_impl_hwnd(surface.as_ref().to_glib_none().0) }
60 as *mut c_void,
61 )
62 }
63}