1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{Win32Surface, HWND};

use glib::object::IsA;
use glib::translate::*;

impl Win32Surface {
    /// ## `display`
    /// a [`gdk::Display`][crate::gdk::Display]
    /// ## `anid`
    /// a HWND window handle
    ///
    /// # Returns
    ///
    /// the [`gdk::Surface`][crate::gdk::Surface] associated with the given @anid, or [`None`].
    #[doc(alias = "gdk_win32_surface_lookup_for_display")]
    pub fn lookup_for_display(
        display: &impl IsA<gdk::Display>,
        anid: HWND,
    ) -> Option<gdk::Surface> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::gdk_win32_surface_lookup_for_display(
                display.as_ref().to_glib_none().0,
                anid.0,
            ))
        }
    }

    /// Returns the HWND handle belonging to @self.
    ///
    /// # Returns
    ///
    /// the associated HWND handle.
    #[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) })
    }

    ///
    /// # Deprecated since 4.8
    ///
    /// Use gdk_win32_surface_get_handle() instead.
    /// ## `surface`
    /// a [`gdk::Surface`][crate::gdk::Surface]
    ///
    /// # Returns
    ///
    /// the associated @surface HWND handle.
    #[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) })
    }
}