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