Skip to main content

gdk4/auto/
toplevel_layout.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::{Monitor, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// Contains information that is necessary to present a sovereign
10    /// window on screen.
11    ///
12    /// The [`ToplevelLayout`][crate::ToplevelLayout] struct is necessary for using
13    /// [`ToplevelExt::present()`][crate::prelude::ToplevelExt::present()].
14    ///
15    /// Toplevel surfaces are sovereign windows that can be presented
16    /// to the user in various states (maximized, on all workspaces,
17    /// etc).
18    #[derive(Debug, PartialOrd, Ord, Hash)]
19    pub struct ToplevelLayout(Shared<ffi::GdkToplevelLayout>);
20
21    match fn {
22        ref => |ptr| ffi::gdk_toplevel_layout_ref(ptr),
23        unref => |ptr| ffi::gdk_toplevel_layout_unref(ptr),
24        type_ => || ffi::gdk_toplevel_layout_get_type(),
25    }
26}
27
28impl ToplevelLayout {
29    ///  (see [`SurfaceExt::scale()`][crate::prelude::SurfaceExt::scale()]).
30    ///
31    /// # Returns
32    ///
33    /// newly created instance of [`ToplevelLayout`][crate::ToplevelLayout]
34    #[doc(alias = "gdk_toplevel_layout_new")]
35    pub fn new() -> ToplevelLayout {
36        assert_initialized_main_thread!();
37        unsafe { from_glib_full(ffi::gdk_toplevel_layout_new()) }
38    }
39
40    #[doc(alias = "gdk_toplevel_layout_copy")]
41    #[must_use]
42    pub fn copy(&self) -> ToplevelLayout {
43        unsafe { from_glib_full(ffi::gdk_toplevel_layout_copy(self.to_glib_none().0)) }
44    }
45
46    #[doc(alias = "gdk_toplevel_layout_equal")]
47    fn equal(&self, other: &ToplevelLayout) -> bool {
48        unsafe {
49            from_glib(ffi::gdk_toplevel_layout_equal(
50                self.to_glib_none().0,
51                other.to_glib_none().0,
52            ))
53        }
54    }
55
56    /// If the layout specifies whether to the toplevel should go fullscreen,
57    /// the value pointed to by @fullscreen is set to true if it should go
58    /// fullscreen, or false, if it should go unfullscreen.
59    ///
60    /// # Returns
61    ///
62    /// whether the @self specifies the fullscreen state for the toplevel
63    ///
64    /// ## `fullscreen`
65    /// location to store whether the toplevel should be fullscreen
66    #[doc(alias = "gdk_toplevel_layout_get_fullscreen")]
67    #[doc(alias = "get_fullscreen")]
68    pub fn fullscreen(&self) -> Option<bool> {
69        unsafe {
70            let mut fullscreen = std::mem::MaybeUninit::uninit();
71            let ret = from_glib(ffi::gdk_toplevel_layout_get_fullscreen(
72                self.to_glib_none().0,
73                fullscreen.as_mut_ptr(),
74            ));
75            if ret {
76                Some(from_glib(fullscreen.assume_init()))
77            } else {
78                None
79            }
80        }
81    }
82
83    /// Returns the monitor that the layout is fullscreening
84    /// the surface on.
85    ///
86    /// # Returns
87    ///
88    /// the monitor on which @self fullscreens
89    #[doc(alias = "gdk_toplevel_layout_get_fullscreen_monitor")]
90    #[doc(alias = "get_fullscreen_monitor")]
91    pub fn fullscreen_monitor(&self) -> Option<Monitor> {
92        unsafe {
93            from_glib_none(ffi::gdk_toplevel_layout_get_fullscreen_monitor(
94                self.to_glib_none().0,
95            ))
96        }
97    }
98
99    /// If the layout specifies whether to the toplevel should go maximized,
100    /// the value pointed to by @maximized is set to true if it should go
101    /// maximized, or false, if it should go unmaximized.
102    ///
103    /// # Returns
104    ///
105    /// whether the @self specifies the maximized state for the toplevel
106    ///
107    /// ## `maximized`
108    /// set to true if the toplevel should be maximized
109    #[doc(alias = "gdk_toplevel_layout_get_maximized")]
110    #[doc(alias = "get_maximized")]
111    pub fn maximized(&self) -> Option<bool> {
112        unsafe {
113            let mut maximized = std::mem::MaybeUninit::uninit();
114            let ret = from_glib(ffi::gdk_toplevel_layout_get_maximized(
115                self.to_glib_none().0,
116                maximized.as_mut_ptr(),
117            ));
118            if ret {
119                Some(from_glib(maximized.assume_init()))
120            } else {
121                None
122            }
123        }
124    }
125
126    /// Returns whether the layout should allow the user
127    /// to resize the surface.
128    ///
129    /// # Returns
130    ///
131    /// true if the layout is resizable
132    #[doc(alias = "gdk_toplevel_layout_get_resizable")]
133    #[doc(alias = "get_resizable")]
134    pub fn is_resizable(&self) -> bool {
135        unsafe {
136            from_glib(ffi::gdk_toplevel_layout_get_resizable(
137                self.to_glib_none().0,
138            ))
139        }
140    }
141
142    /// Sets whether the layout should cause the surface
143    /// to be fullscreen when presented.
144    /// ## `fullscreen`
145    /// true to fullscreen the surface
146    /// ## `monitor`
147    /// the monitor to fullscreen on
148    #[doc(alias = "gdk_toplevel_layout_set_fullscreen")]
149    pub fn set_fullscreen(&self, fullscreen: bool, monitor: Option<&impl IsA<Monitor>>) {
150        unsafe {
151            ffi::gdk_toplevel_layout_set_fullscreen(
152                self.to_glib_none().0,
153                fullscreen.into_glib(),
154                monitor.map(|p| p.as_ref()).to_glib_none().0,
155            );
156        }
157    }
158
159    /// Sets whether the layout should cause the surface
160    /// to be maximized when presented.
161    /// ## `maximized`
162    /// true to maximize
163    #[doc(alias = "gdk_toplevel_layout_set_maximized")]
164    pub fn set_maximized(&self, maximized: bool) {
165        unsafe {
166            ffi::gdk_toplevel_layout_set_maximized(self.to_glib_none().0, maximized.into_glib());
167        }
168    }
169
170    /// Sets whether the layout should allow the user
171    /// to resize the surface after it has been presented.
172    /// ## `resizable`
173    /// true to allow resizing
174    #[doc(alias = "gdk_toplevel_layout_set_resizable")]
175    pub fn set_resizable(&self, resizable: bool) {
176        unsafe {
177            ffi::gdk_toplevel_layout_set_resizable(self.to_glib_none().0, resizable.into_glib());
178        }
179    }
180}
181
182impl Default for ToplevelLayout {
183    fn default() -> Self {
184        Self::new()
185    }
186}
187
188impl PartialEq for ToplevelLayout {
189    #[inline]
190    fn eq(&self, other: &Self) -> bool {
191        self.equal(other)
192    }
193}
194
195impl Eq for ToplevelLayout {}