gtk4_layer_shell/auto/
functions.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from ..
3// from ../gir-files
4// DO NOT EDIT
5
6use crate::{ffi,Edge,KeyboardMode,Layer};
7use glib::{prelude::*,translate::*};
8
9
10/// When auto exclusive zone is enabled, exclusive zone is automatically set to the
11/// size of the `window` + relevant margin. To disable auto exclusive zone, just set the
12/// exclusive zone to 0 or any other fixed value.
13///
14/// NOTE: you can control the auto exclusive zone by changing the margin on the non-anchored
15/// edge. This behavior is specific to gtk4-layer-shell and not part of the underlying protocol
16/// ## `window`
17/// A layer surface.
18#[doc(alias = "gtk_layer_auto_exclusive_zone_enable")]
19pub fn auto_exclusive_zone_enable(window: &impl IsA<gtk::Window>) {
20    assert_initialized_main_thread!();
21    unsafe {
22        ffi::gtk_layer_auto_exclusive_zone_enable(window.as_ref().to_glib_none().0);
23    }
24}
25
26/// ## `window`
27/// A layer surface.
28///
29/// # Returns
30///
31/// if the surface's exclusive zone is set to change based on the window's size
32#[doc(alias = "gtk_layer_auto_exclusive_zone_is_enabled")]
33pub fn auto_exclusive_zone_is_enabled(window: &impl IsA<gtk::Window>) -> bool {
34    assert_initialized_main_thread!();
35    unsafe {
36        from_glib(ffi::gtk_layer_auto_exclusive_zone_is_enabled(window.as_ref().to_glib_none().0))
37    }
38}
39
40/// ## `window`
41/// A layer surface.
42/// ## `edge`
43/// the edge to which the surface may or may not be anchored
44///
45/// # Returns
46///
47/// if this surface is anchored to the given edge.
48#[doc(alias = "gtk_layer_get_anchor")]
49#[doc(alias = "get_anchor")]
50pub fn is_anchor(window: &impl IsA<gtk::Window>, edge: Edge) -> bool {
51    assert_initialized_main_thread!();
52    unsafe {
53        from_glib(ffi::gtk_layer_get_anchor(window.as_ref().to_glib_none().0, edge.into_glib()))
54    }
55}
56
57/// ## `window`
58/// A layer surface.
59///
60/// # Returns
61///
62/// the window's exclusive zone(which may have been set manually or automatically)
63#[doc(alias = "gtk_layer_get_exclusive_zone")]
64#[doc(alias = "get_exclusive_zone")]
65pub fn exclusive_zone(window: &impl IsA<gtk::Window>) -> i32 {
66    assert_initialized_main_thread!();
67    unsafe {
68        ffi::gtk_layer_get_exclusive_zone(window.as_ref().to_glib_none().0)
69    }
70}
71
72/// ## `window`
73/// A layer surface.
74///
75/// # Returns
76///
77/// current keyboard interactivity mode for `window`.
78#[doc(alias = "gtk_layer_get_keyboard_mode")]
79#[doc(alias = "get_keyboard_mode")]
80pub fn keyboard_mode(window: &impl IsA<gtk::Window>) -> KeyboardMode {
81    assert_initialized_main_thread!();
82    unsafe {
83        from_glib(ffi::gtk_layer_get_keyboard_mode(window.as_ref().to_glib_none().0))
84    }
85}
86
87/// ## `window`
88/// A layer surface.
89///
90/// # Returns
91///
92/// the current layer.
93#[doc(alias = "gtk_layer_get_layer")]
94#[doc(alias = "get_layer")]
95pub fn layer(window: &impl IsA<gtk::Window>) -> Option<Layer> {
96    assert_initialized_main_thread!();
97    unsafe {
98        from_glib(ffi::gtk_layer_get_layer(window.as_ref().to_glib_none().0))
99    }
100}
101
102///
103/// # Returns
104///
105/// the major version number of the GTK Layer Shell library
106#[doc(alias = "gtk_layer_get_major_version")]
107#[doc(alias = "get_major_version")]
108pub fn major_version() -> u32 {
109    assert_initialized_main_thread!();
110    unsafe {
111        ffi::gtk_layer_get_major_version()
112    }
113}
114
115/// ## `window`
116/// A layer surface.
117/// ## `edge`
118/// the margin edge to get
119///
120/// # Returns
121///
122/// the size of the margin for the given edge.
123#[doc(alias = "gtk_layer_get_margin")]
124#[doc(alias = "get_margin")]
125pub fn margin(window: &impl IsA<gtk::Window>, edge: Edge) -> i32 {
126    assert_initialized_main_thread!();
127    unsafe {
128        ffi::gtk_layer_get_margin(window.as_ref().to_glib_none().0, edge.into_glib())
129    }
130}
131
132///
133/// # Returns
134///
135/// the micro/patch version number of the GTK Layer Shell library
136#[doc(alias = "gtk_layer_get_micro_version")]
137#[doc(alias = "get_micro_version")]
138pub fn micro_version() -> u32 {
139    assert_initialized_main_thread!();
140    unsafe {
141        ffi::gtk_layer_get_micro_version()
142    }
143}
144
145///
146/// # Returns
147///
148/// the minor version number of the GTK Layer Shell library
149#[doc(alias = "gtk_layer_get_minor_version")]
150#[doc(alias = "get_minor_version")]
151pub fn minor_version() -> u32 {
152    assert_initialized_main_thread!();
153    unsafe {
154        ffi::gtk_layer_get_minor_version()
155    }
156}
157
158/// NOTE: To get which monitor the surface is actually on, use
159/// `gdk_display_get_monitor_at_window()`.
160/// ## `window`
161/// A layer surface.
162///
163/// # Returns
164///
165/// the monitor this surface will/has requested to be on.
166#[doc(alias = "gtk_layer_get_monitor")]
167#[doc(alias = "get_monitor")]
168pub fn monitor(window: &impl IsA<gtk::Window>) -> Option<gdk::Monitor> {
169    assert_initialized_main_thread!();
170    unsafe {
171        from_glib_none(ffi::gtk_layer_get_monitor(window.as_ref().to_glib_none().0))
172    }
173}
174
175/// NOTE: this function does not return ownership of the string. Do not free the returned string.
176/// Future calls into the library may invalidate the returned string.
177/// ## `window`
178/// A layer surface.
179///
180/// # Returns
181///
182/// a reference to the namespace property. If namespace is unset, returns the
183/// default namespace("gtk4-layer-shell"). Never returns [`None`].
184#[doc(alias = "gtk_layer_get_namespace")]
185#[doc(alias = "get_namespace")]
186pub fn namespace(window: &impl IsA<gtk::Window>) -> Option<glib::GString> {
187    assert_initialized_main_thread!();
188    unsafe {
189        from_glib_none(ffi::gtk_layer_get_namespace(window.as_ref().to_glib_none().0))
190    }
191}
192
193/// May block for a Wayland roundtrip the first time it's called.
194///
195/// # Returns
196///
197/// version of the zwlr_layer_shell_v1 protocol supported by the
198/// compositor or 0 if the protocol is not supported.
199#[doc(alias = "gtk_layer_get_protocol_version")]
200#[doc(alias = "get_protocol_version")]
201pub fn protocol_version() -> u32 {
202    assert_initialized_main_thread!();
203    unsafe {
204        ffi::gtk_layer_get_protocol_version()
205    }
206}
207
208//#[doc(alias = "gtk_layer_get_zwlr_layer_surface_v1")]
209//#[doc(alias = "get_zwlr_layer_surface_v1")]
210//pub fn zwlr_layer_surface_v1(window: &impl IsA<gtk::Window>) -> /*Unimplemented*/Option<Basic: Pointer> {
211//    unsafe { TODO: call ffi:gtk_layer_get_zwlr_layer_surface_v1() }
212//}
213
214/// Set the `window` up to be a layer surface once it is mapped. this must be called before
215/// the `window` is realized.
216/// ## `window`
217/// A [`gtk::Window`][crate::gtk::Window] to be turned into a layer surface.
218#[doc(alias = "gtk_layer_init_for_window")]
219pub fn init_for_window(window: &impl IsA<gtk::Window>) {
220    assert_initialized_main_thread!();
221    unsafe {
222        ffi::gtk_layer_init_for_window(window.as_ref().to_glib_none().0);
223    }
224}
225
226/// ## `window`
227/// A [`gtk::Window`][crate::gtk::Window] that may or may not have a layer surface.
228///
229/// # Returns
230///
231/// if `window` has been initialized as a layer surface.
232#[doc(alias = "gtk_layer_is_layer_window")]
233pub fn is_layer_window(window: &impl IsA<gtk::Window>) -> bool {
234    assert_initialized_main_thread!();
235    unsafe {
236        from_glib(ffi::gtk_layer_is_layer_window(window.as_ref().to_glib_none().0))
237    }
238}
239
240/// May block for a Wayland roundtrip the first time it's called.
241///
242/// # Returns
243///
244/// [`true`] if the platform is Wayland and Wayland compositor supports the
245/// zwlr_layer_shell_v1 protocol.
246#[doc(alias = "gtk_layer_is_supported")]
247pub fn is_supported() -> bool {
248    assert_initialized_main_thread!();
249    unsafe {
250        from_glib(ffi::gtk_layer_is_supported())
251    }
252}
253
254/// Set whether `window` should be anchored to `edge`.
255/// - If two perpendicular edges are anchored, the surface with be anchored to that corner
256/// - If two opposite edges are anchored, the window will be stretched across the screen in that direction
257///
258/// Default is [`false`] for each [`Edge`][crate::Edge]
259/// ## `window`
260/// A layer surface.
261/// ## `edge`
262/// A [`Edge`][crate::Edge] this layer surface may be anchored to.
263/// ## `anchor_to_edge`
264/// Whether or not to anchor this layer surface to `edge`.
265#[doc(alias = "gtk_layer_set_anchor")]
266pub fn set_anchor(window: &impl IsA<gtk::Window>, edge: Edge, anchor_to_edge: bool) {
267    assert_initialized_main_thread!();
268    unsafe {
269        ffi::gtk_layer_set_anchor(window.as_ref().to_glib_none().0, edge.into_glib(), anchor_to_edge.into_glib());
270    }
271}
272
273/// Has no effect unless the surface is anchored to an edge. Requests that the compositor
274/// does not place other surfaces within the given exclusive zone of the anchored edge.
275/// For example, a panel can request to not be covered by maximized windows. See
276/// wlr-layer-shell-unstable-v1.xml for details.
277///
278/// Default is 0
279/// ## `window`
280/// A layer surface.
281/// ## `exclusive_zone`
282/// The size of the exclusive zone.
283#[doc(alias = "gtk_layer_set_exclusive_zone")]
284pub fn set_exclusive_zone(window: &impl IsA<gtk::Window>, exclusive_zone: i32) {
285    assert_initialized_main_thread!();
286    unsafe {
287        ffi::gtk_layer_set_exclusive_zone(window.as_ref().to_glib_none().0, exclusive_zone);
288    }
289}
290
291/// Sets if/when `window` should receive keyboard events from the compositor, see
292/// GtkLayerShellKeyboardMode for details.
293///
294/// Default is [`KeyboardMode::None`][crate::KeyboardMode::None]
295/// ## `window`
296/// A layer surface.
297/// ## `mode`
298/// The type of keyboard interactivity requested.
299#[doc(alias = "gtk_layer_set_keyboard_mode")]
300pub fn set_keyboard_mode(window: &impl IsA<gtk::Window>, mode: KeyboardMode) {
301    assert_initialized_main_thread!();
302    unsafe {
303        ffi::gtk_layer_set_keyboard_mode(window.as_ref().to_glib_none().0, mode.into_glib());
304    }
305}
306
307/// Set the "layer" on which the surface appears(controls if it is over top of or below other surfaces). The layer may
308/// be changed on-the-fly in the current version of the layer shell protocol, but on compositors that only support an
309/// older version the `window` is remapped so the change can take effect.
310///
311/// Default is [`Layer::Top`][crate::Layer::Top]
312/// ## `window`
313/// A layer surface.
314/// ## `layer`
315/// The layer on which this surface appears.
316#[doc(alias = "gtk_layer_set_layer")]
317pub fn set_layer(window: &impl IsA<gtk::Window>, layer: Layer) {
318    assert_initialized_main_thread!();
319    unsafe {
320        ffi::gtk_layer_set_layer(window.as_ref().to_glib_none().0, layer.into_glib());
321    }
322}
323
324/// Set the margin for a specific `edge` of a `window`. Effects both surface's distance from
325/// the edge and its exclusive zone size(if auto exclusive zone enabled).
326///
327/// Default is 0 for each [`Edge`][crate::Edge]
328/// ## `window`
329/// A layer surface.
330/// ## `edge`
331/// The [`Edge`][crate::Edge] for which to set the margin.
332/// ## `margin_size`
333/// The margin for `edge` to be set.
334#[doc(alias = "gtk_layer_set_margin")]
335pub fn set_margin(window: &impl IsA<gtk::Window>, edge: Edge, margin_size: i32) {
336    assert_initialized_main_thread!();
337    unsafe {
338        ffi::gtk_layer_set_margin(window.as_ref().to_glib_none().0, edge.into_glib(), margin_size);
339    }
340}
341
342/// Set the output for the window to be placed on, or [`None`] to let the compositor choose.
343/// If the window is currently mapped, it will get remapped so the change can take effect.
344///
345/// Default is [`None`]
346/// ## `window`
347/// A layer surface.
348/// ## `monitor`
349/// The output this layer surface will be placed on ([`None`] to let the compositor decide).
350#[doc(alias = "gtk_layer_set_monitor")]
351pub fn set_monitor(window: &impl IsA<gtk::Window>, monitor: Option<&gdk::Monitor>) {
352    assert_initialized_main_thread!();
353    unsafe {
354        ffi::gtk_layer_set_monitor(window.as_ref().to_glib_none().0, monitor.to_glib_none().0);
355    }
356}
357
358/// Set the "namespace" of the surface.
359///
360/// No one is quite sure what this is for, but it probably should be something generic
361/// ("panel", "osk", etc). The `name_space` string is copied, and caller maintains
362/// ownership of original. If the window is currently mapped, it will get remapped so
363/// the change can take effect.
364///
365/// Default is "gtk4-layer-shell" (which will be used if set to [`None`])
366/// ## `window`
367/// A layer surface.
368/// ## `name_space`
369/// The namespace of this layer surface.
370#[doc(alias = "gtk_layer_set_namespace")]
371pub fn set_namespace(window: &impl IsA<gtk::Window>, name_space: Option<&str>) {
372    assert_initialized_main_thread!();
373    unsafe {
374        ffi::gtk_layer_set_namespace(window.as_ref().to_glib_none().0, name_space.to_glib_none().0);
375    }
376}