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