gdk4_win32/auto/
win32_display.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Win32HCursor};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    ///
10    ///
11    /// # Implements
12    ///
13    /// [`trait@gdk::prelude::DisplayExt`]
14    #[doc(alias = "GdkWin32Display")]
15    pub struct Win32Display(Object<ffi::GdkWin32Display, ffi::GdkWin32DisplayClass>) @extends gdk::Display;
16
17    match fn {
18        type_ => || ffi::gdk_win32_display_get_type(),
19    }
20}
21
22impl Win32Display {
23    /// Returns the Win32 HCURSOR wrapper object belonging to a [`gdk::Cursor`][crate::gdk::Cursor],
24    /// potentially creating the cursor object.
25    ///
26    /// Be aware that the returned cursor may not be unique to @cursor.
27    /// It may for example be shared with its fallback cursor.
28    /// ## `cursor`
29    /// a [`gdk::Cursor`][crate::gdk::Cursor]
30    ///
31    /// # Returns
32    ///
33    /// a GdkWin32HCursor
34    #[doc(alias = "gdk_win32_display_get_win32hcursor")]
35    #[doc(alias = "get_win32hcursor")]
36    pub fn win32hcursor(&self, cursor: &gdk::Cursor) -> Win32HCursor {
37        unsafe {
38            from_glib_none(ffi::gdk_win32_display_get_win32hcursor(
39                self.to_glib_none().0,
40                cursor.to_glib_none().0,
41            ))
42        }
43    }
44
45    /// Sets the cursor theme from which the images for cursor
46    /// should be taken.
47    ///
48    /// If the windowing system supports it, existing cursors created
49    /// with [`gdk::Cursor::from_name()`][crate::gdk::Cursor::from_name()] are updated to reflect the theme
50    /// change. Custom cursors constructed with [`gdk::Cursor::from_texture()`][crate::gdk::Cursor::from_texture()]
51    /// will have to be handled by the application (GTK applications can
52    /// learn about cursor theme changes by listening for change notification
53    /// for the corresponding `GtkSetting`).
54    /// ## `name`
55    /// the name of the cursor theme to use, or [`None`]
56    ///   to unset a previously set value
57    /// ## `size`
58    /// the cursor size to use, or 0 to keep the previous size
59    #[doc(alias = "gdk_win32_display_set_cursor_theme")]
60    pub fn set_cursor_theme(&self, name: Option<&str>, size: i32) {
61        unsafe {
62            ffi::gdk_win32_display_set_cursor_theme(
63                self.to_glib_none().0,
64                name.to_glib_none().0,
65                size,
66            );
67        }
68    }
69
70    #[doc(alias = "gdk_win32_display_get_primary_monitor")]
71    #[doc(alias = "get_primary_monitor")]
72    pub fn primary_monitor(display: &impl IsA<gdk::Display>) -> gdk::Monitor {
73        assert_initialized_main_thread!();
74        unsafe {
75            from_glib_none(ffi::gdk_win32_display_get_primary_monitor(
76                display.as_ref().to_glib_none().0,
77            ))
78        }
79    }
80
81    /// Retrieves the version of the WGL implementation.
82    /// ## `display`
83    /// a [`gdk::Display`][crate::gdk::Display]
84    ///
85    /// # Returns
86    ///
87    /// [`true`] if WGL is available
88    ///
89    /// ## `major`
90    /// return location for the WGL major version
91    ///
92    /// ## `minor`
93    /// return location for the WGL minor version
94    #[doc(alias = "gdk_win32_display_get_wgl_version")]
95    #[doc(alias = "get_wgl_version")]
96    pub fn wgl_version(display: &impl IsA<gdk::Display>) -> Option<(i32, i32)> {
97        assert_initialized_main_thread!();
98        unsafe {
99            let mut major = std::mem::MaybeUninit::uninit();
100            let mut minor = std::mem::MaybeUninit::uninit();
101            let ret = from_glib(ffi::gdk_win32_display_get_wgl_version(
102                display.as_ref().to_glib_none().0,
103                major.as_mut_ptr(),
104                minor.as_mut_ptr(),
105            ));
106            if ret {
107                Some((major.assume_init(), minor.assume_init()))
108            } else {
109                None
110            }
111        }
112    }
113}