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>) -> 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_surface()`.
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/// ## `window`
209/// A layer surface.
210///
211/// # Returns
212///
213/// if the respect_close behavior is enabled, see [`set_respect_close()`][crate::set_respect_close()]
214#[cfg(feature = "v1_3")]
215#[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
216#[doc(alias = "gtk_layer_get_respect_close")]
217#[doc(alias = "get_respect_close")]
218pub fn is_respect_close(window: &impl IsA<gtk::Window>) -> bool {
219 assert_initialized_main_thread!();
220 unsafe {
221 from_glib(ffi::gtk_layer_get_respect_close(window.as_ref().to_glib_none().0))
222 }
223}
224
225//#[doc(alias = "gtk_layer_get_zwlr_layer_surface_v1")]
226//#[doc(alias = "get_zwlr_layer_surface_v1")]
227//pub fn zwlr_layer_surface_v1(window: &impl IsA<gtk::Window>) -> /*Unimplemented*/Option<Basic: Pointer> {
228// unsafe { TODO: call ffi:gtk_layer_get_zwlr_layer_surface_v1() }
229//}
230
231/// Set the `window` up to be a layer surface once it is mapped. this must be called before
232/// the `window` is realized.
233/// ## `window`
234/// A [`gtk::Window`][crate::gtk::Window] to be turned into a layer surface.
235#[doc(alias = "gtk_layer_init_for_window")]
236pub fn init_for_window(window: &impl IsA<gtk::Window>) {
237 assert_initialized_main_thread!();
238 unsafe {
239 ffi::gtk_layer_init_for_window(window.as_ref().to_glib_none().0);
240 }
241}
242
243/// ## `window`
244/// A [`gtk::Window`][crate::gtk::Window] that may or may not have a layer surface.
245///
246/// # Returns
247///
248/// if `window` has been initialized as a layer surface.
249#[doc(alias = "gtk_layer_is_layer_window")]
250pub fn is_layer_window(window: &impl IsA<gtk::Window>) -> bool {
251 assert_initialized_main_thread!();
252 unsafe {
253 from_glib(ffi::gtk_layer_is_layer_window(window.as_ref().to_glib_none().0))
254 }
255}
256
257/// May block for a Wayland roundtrip the first time it's called.
258///
259/// # Returns
260///
261/// [`true`] if the platform is Wayland and Wayland compositor supports the
262/// zwlr_layer_shell_v1 protocol.
263#[doc(alias = "gtk_layer_is_supported")]
264pub fn is_supported() -> bool {
265 assert_initialized_main_thread!();
266 unsafe {
267 from_glib(ffi::gtk_layer_is_supported())
268 }
269}
270
271/// Set whether `window` should be anchored to `edge`.
272/// - If two perpendicular edges are anchored, the surface with be anchored to that corner
273/// - If two opposite edges are anchored, the window will be stretched across the screen in that direction
274///
275/// Default is [`false`] for each [`Edge`][crate::Edge]
276/// ## `window`
277/// A layer surface.
278/// ## `edge`
279/// A [`Edge`][crate::Edge] this layer surface may be anchored to.
280/// ## `anchor_to_edge`
281/// Whether or not to anchor this layer surface to `edge`.
282#[doc(alias = "gtk_layer_set_anchor")]
283pub fn set_anchor(window: &impl IsA<gtk::Window>, edge: Edge, anchor_to_edge: bool) {
284 assert_initialized_main_thread!();
285 unsafe {
286 ffi::gtk_layer_set_anchor(window.as_ref().to_glib_none().0, edge.into_glib(), anchor_to_edge.into_glib());
287 }
288}
289
290/// Has no effect unless the surface is anchored to an edge. Requests that the compositor
291/// does not place other surfaces within the given exclusive zone of the anchored edge.
292/// For example, a panel can request to not be covered by maximized windows. See
293/// wlr-layer-shell-unstable-v1.xml for details.
294///
295/// Default is 0
296/// ## `window`
297/// A layer surface.
298/// ## `exclusive_zone`
299/// The size of the exclusive zone.
300#[doc(alias = "gtk_layer_set_exclusive_zone")]
301pub fn set_exclusive_zone(window: &impl IsA<gtk::Window>, exclusive_zone: i32) {
302 assert_initialized_main_thread!();
303 unsafe {
304 ffi::gtk_layer_set_exclusive_zone(window.as_ref().to_glib_none().0, exclusive_zone);
305 }
306}
307
308/// Sets if/when `window` should receive keyboard events from the compositor, see
309/// GtkLayerShellKeyboardMode for details. To control mouse/touch interactivity use input regions,
310/// see [`61`](https://github.com/wmww/gtk4-layer-shell/issues/61) for details.
311///
312/// Default is [`KeyboardMode::None`][crate::KeyboardMode::None]
313/// ## `window`
314/// A layer surface.
315/// ## `mode`
316/// The type of keyboard interactivity requested.
317#[doc(alias = "gtk_layer_set_keyboard_mode")]
318pub fn set_keyboard_mode(window: &impl IsA<gtk::Window>, mode: KeyboardMode) {
319 assert_initialized_main_thread!();
320 unsafe {
321 ffi::gtk_layer_set_keyboard_mode(window.as_ref().to_glib_none().0, mode.into_glib());
322 }
323}
324
325/// Set the "layer" on which the surface appears(controls if it is over top of or below other surfaces). The layer may
326/// be changed on-the-fly in the current version of the layer shell protocol, but on compositors that only support an
327/// older version the `window` is remapped so the change can take effect.
328///
329/// Default is [`Layer::Top`][crate::Layer::Top]
330/// ## `window`
331/// A layer surface.
332/// ## `layer`
333/// The layer on which this surface appears.
334#[doc(alias = "gtk_layer_set_layer")]
335pub fn set_layer(window: &impl IsA<gtk::Window>, layer: Layer) {
336 assert_initialized_main_thread!();
337 unsafe {
338 ffi::gtk_layer_set_layer(window.as_ref().to_glib_none().0, layer.into_glib());
339 }
340}
341
342/// Set the margin for a specific `edge` of a `window`. Effects both surface's distance from
343/// the edge and its exclusive zone size(if auto exclusive zone enabled).
344///
345/// Default is 0 for each [`Edge`][crate::Edge]
346/// ## `window`
347/// A layer surface.
348/// ## `edge`
349/// The [`Edge`][crate::Edge] for which to set the margin.
350/// ## `margin_size`
351/// The margin for `edge` to be set.
352#[doc(alias = "gtk_layer_set_margin")]
353pub fn set_margin(window: &impl IsA<gtk::Window>, edge: Edge, margin_size: i32) {
354 assert_initialized_main_thread!();
355 unsafe {
356 ffi::gtk_layer_set_margin(window.as_ref().to_glib_none().0, edge.into_glib(), margin_size);
357 }
358}
359
360/// Set the output for the window to be placed on, or [`None`] to let the compositor choose.
361/// If the window is currently mapped, it will get remapped so the change can take effect.
362///
363/// Default is [`None`]
364/// ## `window`
365/// A layer surface.
366/// ## `monitor`
367/// The output this layer surface will be placed on ([`None`] to let the compositor decide).
368#[doc(alias = "gtk_layer_set_monitor")]
369pub fn set_monitor(window: &impl IsA<gtk::Window>, monitor: Option<&gdk::Monitor>) {
370 assert_initialized_main_thread!();
371 unsafe {
372 ffi::gtk_layer_set_monitor(window.as_ref().to_glib_none().0, monitor.to_glib_none().0);
373 }
374}
375
376/// Set the "namespace" of the surface.
377///
378/// No one is quite sure what this is for, but it probably should be something generic
379/// ("panel", "osk", etc). The `name_space` string is copied, and caller maintains
380/// ownership of original. If the window is currently mapped, it will get remapped so
381/// the change can take effect.
382///
383/// Default is "gtk4-layer-shell" (which will be used if set to [`None`])
384/// ## `window`
385/// A layer surface.
386/// ## `name_space`
387/// The namespace of this layer surface.
388#[doc(alias = "gtk_layer_set_namespace")]
389pub fn set_namespace(window: &impl IsA<gtk::Window>, name_space: Option<&str>) {
390 assert_initialized_main_thread!();
391 unsafe {
392 ffi::gtk_layer_set_namespace(window.as_ref().to_glib_none().0, name_space.to_glib_none().0);
393 }
394}
395
396/// Compositors may send the `zwlr_layer_surface_v1.closed` event in some cases (such as
397/// when an output is destroyed). Prior to v1.3 this always triggered a GTK `close-request`
398/// signal, which would destroy the window if not intercepted by application code. In v1.3+
399/// this behavior is disabled by default, and can be turned back on by calling this
400/// function with [`true`]. To handle the `.closed` event without destroying your window
401/// turn respect_close on and connect a `close-request` listener that returns [`true`].
402/// ## `window`
403/// A layer surface.
404/// ## `respect_close`
405/// If to forward the .closed event to GTK.
406#[cfg(feature = "v1_3")]
407#[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
408#[doc(alias = "gtk_layer_set_respect_close")]
409pub fn set_respect_close(window: &impl IsA<gtk::Window>, respect_close: bool) {
410 assert_initialized_main_thread!();
411 unsafe {
412 ffi::gtk_layer_set_respect_close(window.as_ref().to_glib_none().0, respect_close.into_glib());
413 }
414}