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