gdk4_x11/auto/
x11_screen.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#![allow(deprecated)]
5
6use crate::ffi;
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    ///
17    ///
18    /// ## Signals
19    ///
20    ///
21    /// #### `window-manager-changed`
22    ///
23    #[doc(alias = "GdkX11Screen")]
24    pub struct X11Screen(Object<ffi::GdkX11Screen, ffi::GdkX11ScreenClass>);
25
26    match fn {
27        type_ => || ffi::gdk_x11_screen_get_type(),
28    }
29}
30
31impl X11Screen {
32    /// Returns the current workspace for @self when running under a
33    /// window manager that supports multiple workspaces, as described
34    /// in the
35    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
36    ///
37    /// # Deprecated since 4.18
38    ///
39    ///
40    /// # Returns
41    ///
42    /// the current workspace, or 0 if workspaces are not supported
43    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
44    #[allow(deprecated)]
45    #[doc(alias = "gdk_x11_screen_get_current_desktop")]
46    #[doc(alias = "get_current_desktop")]
47    pub fn current_desktop(&self) -> u32 {
48        unsafe { ffi::gdk_x11_screen_get_current_desktop(self.to_glib_none().0) }
49    }
50
51    /// Returns the number of workspaces for @self when running under a
52    /// window manager that supports multiple workspaces, as described
53    /// in the
54    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
55    ///
56    /// # Deprecated since 4.18
57    ///
58    ///
59    /// # Returns
60    ///
61    /// the number of workspaces, or 0 if workspaces are not supported
62    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
63    #[allow(deprecated)]
64    #[doc(alias = "gdk_x11_screen_get_number_of_desktops")]
65    #[doc(alias = "get_number_of_desktops")]
66    pub fn number_of_desktops(&self) -> u32 {
67        unsafe { ffi::gdk_x11_screen_get_number_of_desktops(self.to_glib_none().0) }
68    }
69
70    /// Returns the index of a [`X11Screen`][crate::X11Screen].
71    ///
72    /// # Deprecated since 4.18
73    ///
74    ///
75    /// # Returns
76    ///
77    /// the position of @self among the screens
78    ///   of its display
79    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
80    #[allow(deprecated)]
81    #[doc(alias = "gdk_x11_screen_get_screen_number")]
82    #[doc(alias = "get_screen_number")]
83    pub fn screen_number(&self) -> i32 {
84        unsafe { ffi::gdk_x11_screen_get_screen_number(self.to_glib_none().0) }
85    }
86
87    /// Returns the name of the window manager for @self.
88    ///
89    /// # Deprecated since 4.18
90    ///
91    ///
92    /// # Returns
93    ///
94    /// the name of the window manager screen @self, or
95    /// "unknown" if the window manager is unknown. The string is owned by GDK
96    /// and should not be freed.
97    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
98    #[allow(deprecated)]
99    #[doc(alias = "gdk_x11_screen_get_window_manager_name")]
100    #[doc(alias = "get_window_manager_name")]
101    pub fn window_manager_name(&self) -> glib::GString {
102        unsafe {
103            from_glib_none(ffi::gdk_x11_screen_get_window_manager_name(
104                self.to_glib_none().0,
105            ))
106        }
107    }
108
109    /// This function is specific to the X11 backend of GDK, and indicates
110    /// whether the window manager supports a certain hint from the
111    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
112    ///
113    /// When using this function, keep in mind that the window manager
114    /// can change over time; so you shouldn’t use this function in
115    /// a way that impacts persistent application state. A common bug
116    /// is that your application can start up before the window manager
117    /// does when the user logs in, and before the window manager starts
118    /// gdk_x11_screen_supports_net_wm_hint() will return [`false`] for every property.
119    /// You can monitor the window_manager_changed signal on [`X11Screen`][crate::X11Screen] to detect
120    /// a window manager change.
121    ///
122    /// # Deprecated since 4.18
123    ///
124    /// ## `property_name`
125    /// name of the WM property
126    ///
127    /// # Returns
128    ///
129    /// [`true`] if the window manager supports @property
130    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
131    #[allow(deprecated)]
132    #[doc(alias = "gdk_x11_screen_supports_net_wm_hint")]
133    pub fn supports_net_wm_hint(&self, property_name: &str) -> bool {
134        unsafe {
135            from_glib(ffi::gdk_x11_screen_supports_net_wm_hint(
136                self.to_glib_none().0,
137                property_name.to_glib_none().0,
138            ))
139        }
140    }
141
142    #[doc(alias = "window-manager-changed")]
143    pub fn connect_window_manager_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
144        unsafe extern "C" fn window_manager_changed_trampoline<F: Fn(&X11Screen) + 'static>(
145            this: *mut ffi::GdkX11Screen,
146            f: glib::ffi::gpointer,
147        ) {
148            let f: &F = &*(f as *const F);
149            f(&from_glib_borrow(this))
150        }
151        unsafe {
152            let f: Box_<F> = Box_::new(f);
153            connect_raw(
154                self.as_ptr() as *mut _,
155                b"window-manager-changed\0".as_ptr() as *const _,
156                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
157                    window_manager_changed_trampoline::<F> as *const (),
158                )),
159                Box_::into_raw(f),
160            )
161        }
162    }
163}