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