Skip to main content

gdkx11/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
5use crate::{X11Visual, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13use x11::xlib;
14
15glib::wrapper! {
16    ///
17    ///
18    /// ## Signals
19    ///
20    ///
21    /// #### `window-manager-changed`
22    ///
23    /// <details><summary><h4>Screen</h4></summary>
24    ///
25    ///
26    /// #### `composited-changed`
27    ///  The ::composited-changed signal is emitted when the composited
28    /// status of the screen changes
29    ///
30    ///
31    ///
32    ///
33    /// #### `monitors-changed`
34    ///  The ::monitors-changed signal is emitted when the number, size
35    /// or position of the monitors attached to the screen change.
36    ///
37    /// Only for X11 and OS X for now. A future implementation for Win32
38    /// may be a possibility.
39    ///
40    ///
41    ///
42    ///
43    /// #### `size-changed`
44    ///  The ::size-changed signal is emitted when the pixel width or
45    /// height of a screen changes.
46    ///
47    ///
48    /// </details>
49    ///
50    /// # Implements
51    ///
52    /// [`trait@gdk::prelude::ScreenExt`]
53    #[doc(alias = "GdkX11Screen")]
54    pub struct X11Screen(Object<ffi::GdkX11Screen, ffi::GdkX11ScreenClass>) @extends gdk::Screen;
55
56    match fn {
57        type_ => || ffi::gdk_x11_screen_get_type(),
58    }
59}
60
61impl X11Screen {
62    /// Returns the current workspace for `self` when running under a
63    /// window manager that supports multiple workspaces, as described
64    /// in the
65    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
66    ///
67    /// # Returns
68    ///
69    /// the current workspace, or 0 if workspaces are not supported
70    #[doc(alias = "gdk_x11_screen_get_current_desktop")]
71    #[doc(alias = "get_current_desktop")]
72    pub fn current_desktop(&self) -> u32 {
73        unsafe { ffi::gdk_x11_screen_get_current_desktop(self.to_glib_none().0) }
74    }
75
76    /// Gets the XID of the specified output/monitor.
77    /// If the X server does not support version 1.2 of the RANDR
78    /// extension, 0 is returned.
79    /// ## `monitor_num`
80    /// number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
81    ///
82    /// # Returns
83    ///
84    /// the XID of the monitor
85    #[doc(alias = "gdk_x11_screen_get_monitor_output")]
86    #[doc(alias = "get_monitor_output")]
87    pub fn monitor_output(&self, monitor_num: i32) -> xlib::XID {
88        unsafe { ffi::gdk_x11_screen_get_monitor_output(self.to_glib_none().0, monitor_num) }
89    }
90
91    /// Returns the number of workspaces for `self` when running under a
92    /// window manager that supports multiple workspaces, as described
93    /// in the
94    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
95    ///
96    /// # Returns
97    ///
98    /// the number of workspaces, or 0 if workspaces are not supported
99    #[doc(alias = "gdk_x11_screen_get_number_of_desktops")]
100    #[doc(alias = "get_number_of_desktops")]
101    pub fn number_of_desktops(&self) -> u32 {
102        unsafe { ffi::gdk_x11_screen_get_number_of_desktops(self.to_glib_none().0) }
103    }
104
105    /// Returns the index of a [`gdk::Screen`][crate::gdk::Screen].
106    ///
107    /// # Returns
108    ///
109    /// the position of `self` among the screens
110    ///  of its display
111    #[doc(alias = "gdk_x11_screen_get_screen_number")]
112    #[doc(alias = "get_screen_number")]
113    pub fn screen_number(&self) -> i32 {
114        unsafe { ffi::gdk_x11_screen_get_screen_number(self.to_glib_none().0) }
115    }
116
117    /// Returns the name of the window manager for `self`.
118    ///
119    /// # Returns
120    ///
121    /// the name of the window manager screen `self`, or
122    /// "unknown" if the window manager is unknown. The string is owned by GDK
123    /// and should not be freed.
124    #[doc(alias = "gdk_x11_screen_get_window_manager_name")]
125    #[doc(alias = "get_window_manager_name")]
126    pub fn window_manager_name(&self) -> Option<glib::GString> {
127        unsafe {
128            from_glib_none(ffi::gdk_x11_screen_get_window_manager_name(
129                self.to_glib_none().0,
130            ))
131        }
132    }
133
134    /// Looks up the [`gdk::Visual`][crate::gdk::Visual] for a particular screen and X Visual ID.
135    /// ## `xvisualid`
136    /// an X Visual ID.
137    ///
138    /// # Returns
139    ///
140    /// the [`gdk::Visual`][crate::gdk::Visual] (owned by the screen
141    ///  object), or [`None`] if the visual ID wasn’t found.
142    #[doc(alias = "gdk_x11_screen_lookup_visual")]
143    pub fn lookup_visual(&self, xvisualid: xlib::VisualID) -> Option<X11Visual> {
144        unsafe {
145            from_glib_none(ffi::gdk_x11_screen_lookup_visual(
146                self.to_glib_none().0,
147                xvisualid,
148            ))
149        }
150    }
151
152    /// This function is specific to the X11 backend of GDK, and indicates
153    /// whether the window manager supports a certain hint from the
154    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
155    ///
156    /// When using this function, keep in mind that the window manager
157    /// can change over time; so you shouldn’t use this function in
158    /// a way that impacts persistent application state. A common bug
159    /// is that your application can start up before the window manager
160    /// does when the user logs in, and before the window manager starts
161    /// [`supports_net_wm_hint()`][Self::supports_net_wm_hint()] will return [`false`] for every property.
162    /// You can monitor the window_manager_changed signal on [`gdk::Screen`][crate::gdk::Screen] to detect
163    /// a window manager change.
164    /// ## `property`
165    /// a property atom.
166    ///
167    /// # Returns
168    ///
169    /// [`true`] if the window manager supports `property`
170    #[doc(alias = "gdk_x11_screen_supports_net_wm_hint")]
171    pub fn supports_net_wm_hint(&self, property: &gdk::Atom) -> bool {
172        unsafe {
173            from_glib(ffi::gdk_x11_screen_supports_net_wm_hint(
174                self.to_glib_none().0,
175                property.to_glib_none().0,
176            ))
177        }
178    }
179
180    #[doc(alias = "window-manager-changed")]
181    pub fn connect_window_manager_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
182        unsafe extern "C" fn window_manager_changed_trampoline<F: Fn(&X11Screen) + 'static>(
183            this: *mut ffi::GdkX11Screen,
184            f: glib::ffi::gpointer,
185        ) {
186            unsafe {
187                let f: &F = &*(f as *const F);
188                f(&from_glib_borrow(this))
189            }
190        }
191        unsafe {
192            let f: Box_<F> = Box_::new(f);
193            connect_raw(
194                self.as_ptr() as *mut _,
195                c"window-manager-changed".as_ptr(),
196                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
197                    window_manager_changed_trampoline::<F> as *const (),
198                )),
199                Box_::into_raw(f),
200            )
201        }
202    }
203}