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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Win32HCursor;
use glib::{prelude::*, translate::*};
use std::{fmt, mem};

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`trait@gdk::prelude::DisplayExt`]
    #[doc(alias = "GdkWin32Display")]
    pub struct Win32Display(Object<ffi::GdkWin32Display, ffi::GdkWin32DisplayClass>) @extends gdk::Display;

    match fn {
        type_ => || ffi::gdk_win32_display_get_type(),
    }
}

impl Win32Display {
    /// Returns the Win32 HCURSOR wrapper object belonging to a [`gdk::Cursor`][crate::gdk::Cursor],
    /// potentially creating the cursor object.
    ///
    /// Be aware that the returned cursor may not be unique to @cursor.
    /// It may for example be shared with its fallback cursor.
    /// ## `cursor`
    /// a [`gdk::Cursor`][crate::gdk::Cursor]
    ///
    /// # Returns
    ///
    /// a GdkWin32HCursor
    #[doc(alias = "gdk_win32_display_get_win32hcursor")]
    #[doc(alias = "get_win32hcursor")]
    pub fn win32hcursor(&self, cursor: &gdk::Cursor) -> Win32HCursor {
        unsafe {
            from_glib_none(ffi::gdk_win32_display_get_win32hcursor(
                self.to_glib_none().0,
                cursor.to_glib_none().0,
            ))
        }
    }

    /// Sets the cursor theme from which the images for cursor
    /// should be taken.
    ///
    /// If the windowing system supports it, existing cursors created
    /// with [`gdk::Cursor::from_name()`][crate::gdk::Cursor::from_name()] are updated to reflect the theme
    /// change. Custom cursors constructed with [`gdk::Cursor::from_texture()`][crate::gdk::Cursor::from_texture()]
    /// will have to be handled by the application (GTK applications can
    /// learn about cursor theme changes by listening for change notification
    /// for the corresponding `GtkSetting`).
    /// ## `name`
    /// the name of the cursor theme to use, or [`None`]
    ///   to unset a previously set value
    /// ## `size`
    /// the cursor size to use, or 0 to keep the previous size
    #[doc(alias = "gdk_win32_display_set_cursor_theme")]
    pub fn set_cursor_theme(&self, name: Option<&str>, size: i32) {
        unsafe {
            ffi::gdk_win32_display_set_cursor_theme(
                self.to_glib_none().0,
                name.to_glib_none().0,
                size,
            );
        }
    }

    #[doc(alias = "gdk_win32_display_get_primary_monitor")]
    #[doc(alias = "get_primary_monitor")]
    pub fn primary_monitor(display: &impl IsA<gdk::Display>) -> gdk::Monitor {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::gdk_win32_display_get_primary_monitor(
                display.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Retrieves the version of the WGL implementation.
    /// ## `display`
    /// a [`gdk::Display`][crate::gdk::Display]
    ///
    /// # Returns
    ///
    /// [`true`] if WGL is available
    ///
    /// ## `major`
    /// return location for the WGL major version
    ///
    /// ## `minor`
    /// return location for the WGL minor version
    #[doc(alias = "gdk_win32_display_get_wgl_version")]
    #[doc(alias = "get_wgl_version")]
    pub fn wgl_version(display: &impl IsA<gdk::Display>) -> Option<(i32, i32)> {
        assert_initialized_main_thread!();
        unsafe {
            let mut major = mem::MaybeUninit::uninit();
            let mut minor = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gdk_win32_display_get_wgl_version(
                display.as_ref().to_glib_none().0,
                major.as_mut_ptr(),
                minor.as_mut_ptr(),
            ));
            if ret {
                Some((major.assume_init(), minor.assume_init()))
            } else {
                None
            }
        }
    }
}

impl fmt::Display for Win32Display {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Win32Display")
    }
}