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::{SignalHandlerId, connect_raw},
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](https://specifications.freedesktop.org/wm/latest/) 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](https://specifications.freedesktop.org/wm/latest/) 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 /// t use this function in
110 /// a way that impacts persistent application state. A common bug
111 /// is that your application can start up before the window manager
112 /// does when the user logs in, and before the window manager starts
113 /// gdk_x11_screen_supports_net_wm_hint() will return [`false`] for every property.
114 /// You can monitor the window_manager_changed signal on [`X11Screen`][crate::X11Screen] to detect
115 /// a window manager change.
116 ///
117 /// # Deprecated since 4.18
118 ///
119 /// ## `property_name`
120 /// name of the WM property
121 ///
122 /// # Returns
123 ///
124 /// [`true`] if the window manager supports @property
125 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
126 #[allow(deprecated)]
127 #[doc(alias = "gdk_x11_screen_supports_net_wm_hint")]
128 pub fn supports_net_wm_hint(&self, property_name: &str) -> bool {
129 unsafe {
130 from_glib(ffi::gdk_x11_screen_supports_net_wm_hint(
131 self.to_glib_none().0,
132 property_name.to_glib_none().0,
133 ))
134 }
135 }
136
137 #[doc(alias = "window-manager-changed")]
138 pub fn connect_window_manager_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
139 unsafe extern "C" fn window_manager_changed_trampoline<F: Fn(&X11Screen) + 'static>(
140 this: *mut ffi::GdkX11Screen,
141 f: glib::ffi::gpointer,
142 ) {
143 unsafe {
144 let f: &F = &*(f as *const F);
145 f(&from_glib_borrow(this))
146 }
147 }
148 unsafe {
149 let f: Box_<F> = Box_::new(f);
150 connect_raw(
151 self.as_ptr() as *mut _,
152 c"window-manager-changed".as_ptr(),
153 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
154 window_manager_changed_trampoline::<F> as *const (),
155 )),
156 Box_::into_raw(f),
157 )
158 }
159 }
160}