Skip to main content

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;
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    /// Sets the cursor theme from which the images for cursor
24    /// should be taken.
25    ///
26    /// If the windowing system supports it, existing cursors created
27    /// with `Gdk::Cursor::new_from_name()` are updated to reflect the theme
28    /// change. Custom cursors constructed with `Gdk::Cursor::new_from_texture()`
29    /// will have to be handled by the application (GTK applications can
30    /// learn about cursor theme changes by listening for change notification
31    /// for the corresponding `GtkSetting`).
32    /// ## `name`
33    /// the name of the cursor theme to use, or [`None`]
34    ///   to unset a previously set value
35    /// ## `size`
36    /// the cursor size to use, or 0 to keep the previous size
37    #[doc(alias = "gdk_win32_display_set_cursor_theme")]
38    pub fn set_cursor_theme(&self, name: Option<&str>, size: i32) {
39        unsafe {
40            ffi::gdk_win32_display_set_cursor_theme(
41                self.to_glib_none().0,
42                name.to_glib_none().0,
43                size,
44            );
45        }
46    }
47
48    #[doc(alias = "gdk_win32_display_get_primary_monitor")]
49    #[doc(alias = "get_primary_monitor")]
50    pub fn primary_monitor(display: &impl IsA<gdk::Display>) -> gdk::Monitor {
51        assert_initialized_main_thread!();
52        unsafe {
53            from_glib_none(ffi::gdk_win32_display_get_primary_monitor(
54                display.as_ref().to_glib_none().0,
55            ))
56        }
57    }
58
59    /// Retrieves the version of the WGL implementation.
60    /// ## `display`
61    /// a [`gdk::Display`][crate::gdk::Display]
62    ///
63    /// # Returns
64    ///
65    /// [`true`] if WGL is available
66    ///
67    /// ## `major`
68    /// return location for the WGL major version
69    ///
70    /// ## `minor`
71    /// return location for the WGL minor version
72    #[doc(alias = "gdk_win32_display_get_wgl_version")]
73    #[doc(alias = "get_wgl_version")]
74    pub fn wgl_version(display: &impl IsA<gdk::Display>) -> Option<(i32, i32)> {
75        assert_initialized_main_thread!();
76        unsafe {
77            let mut major = std::mem::MaybeUninit::uninit();
78            let mut minor = std::mem::MaybeUninit::uninit();
79            let ret = from_glib(ffi::gdk_win32_display_get_wgl_version(
80                display.as_ref().to_glib_none().0,
81                major.as_mut_ptr(),
82                minor.as_mut_ptr(),
83            ));
84            if ret {
85                Some((major.assume_init(), minor.assume_init()))
86            } else {
87                None
88            }
89        }
90    }
91}