gdkx11/auto/x11_window.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::{X11Display, ffi};
6use glib::{prelude::*, translate::*};
7use x11::xlib;
8
9glib::wrapper! {
10 ///
11 ///
12 /// # Implements
13 ///
14 /// [`trait@gdk::prelude::WindowExt`]
15 #[doc(alias = "GdkX11Window")]
16 pub struct X11Window(Object<ffi::GdkX11Window, ffi::GdkX11WindowClass>) @extends gdk::Window;
17
18 match fn {
19 type_ => || ffi::gdk_x11_window_get_type(),
20 }
21}
22
23impl X11Window {
24 /// Wraps a native window in a [`gdk::Window`][crate::gdk::Window]. The function will try to
25 /// look up the window using [`lookup_for_display()`][Self::lookup_for_display()] first.
26 /// If it does not find it there, it will create a new window.
27 ///
28 /// This may fail if the window has been destroyed. If the window
29 /// was already known to GDK, a new reference to the existing
30 /// [`gdk::Window`][crate::gdk::Window] is returned.
31 /// ## `display`
32 /// the [`gdk::Display`][crate::gdk::Display] where the window handle comes from.
33 /// ## `window`
34 /// an Xlib Window
35 ///
36 /// # Returns
37 ///
38 /// a [`gdk::Window`][crate::gdk::Window] wrapper for the native
39 /// window, or [`None`] if the window has been destroyed. The wrapper
40 /// will be newly created, if one doesn’t exist already.
41 #[doc(alias = "gdk_x11_window_foreign_new_for_display")]
42 pub fn foreign_new_for_display(display: &X11Display, window: xlib::Window) -> X11Window {
43 skip_assert_initialized!();
44 unsafe {
45 gdk::Window::from_glib_full(ffi::gdk_x11_window_foreign_new_for_display(
46 display.to_glib_none().0,
47 window,
48 ))
49 .unsafe_cast()
50 }
51 }
52
53 /// Gets the number of the workspace `self` is on.
54 ///
55 /// # Returns
56 ///
57 /// the current workspace of `self`
58 #[doc(alias = "gdk_x11_window_get_desktop")]
59 #[doc(alias = "get_desktop")]
60 pub fn desktop(&self) -> u32 {
61 unsafe { ffi::gdk_x11_window_get_desktop(self.to_glib_none().0) }
62 }
63
64 /// Returns the X resource (window) belonging to a [`gdk::Window`][crate::gdk::Window].
65 ///
66 /// # Returns
67 ///
68 /// the ID of `drawable`’s X resource.
69 #[doc(alias = "gdk_x11_window_get_xid")]
70 #[doc(alias = "get_xid")]
71 pub fn xid(&self) -> xlib::Window {
72 unsafe { ffi::gdk_x11_window_get_xid(self.to_glib_none().0) }
73 }
74
75 /// Moves the window to the correct workspace when running under a
76 /// window manager that supports multiple workspaces, as described
77 /// in the [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
78 /// Will not do anything if the window is already on all workspaces.
79 #[doc(alias = "gdk_x11_window_move_to_current_desktop")]
80 pub fn move_to_current_desktop(&self) {
81 unsafe {
82 ffi::gdk_x11_window_move_to_current_desktop(self.to_glib_none().0);
83 }
84 }
85
86 /// Moves the window to the given workspace when running unde a
87 /// window manager that supports multiple workspaces, as described
88 /// in the [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
89 /// ## `desktop`
90 /// the number of the workspace to move the window to
91 #[doc(alias = "gdk_x11_window_move_to_desktop")]
92 pub fn move_to_desktop(&self, desktop: u32) {
93 unsafe {
94 ffi::gdk_x11_window_move_to_desktop(self.to_glib_none().0, desktop);
95 }
96 }
97
98 /// This function can be used to disable frame synchronization for a window.
99 /// Normally frame synchronziation will be enabled or disabled based on whether
100 /// the system has a compositor that supports frame synchronization, but if
101 /// the window is not directly managed by the window manager, then frame
102 /// synchronziation may need to be disabled. This is the case for a window
103 /// embedded via the XEMBED protocol.
104 /// ## `frame_sync_enabled`
105 /// whether frame-synchronization should be enabled
106 #[doc(alias = "gdk_x11_window_set_frame_sync_enabled")]
107 pub fn set_frame_sync_enabled(&self, frame_sync_enabled: bool) {
108 unsafe {
109 ffi::gdk_x11_window_set_frame_sync_enabled(
110 self.to_glib_none().0,
111 frame_sync_enabled.into_glib(),
112 );
113 }
114 }
115
116 /// Set a hint for the window manager, requesting that the titlebar
117 /// should be hidden when the window is maximized.
118 ///
119 /// Note that this property is automatically updated by GTK+, so this
120 /// function should only be used by applications which do not use GTK+
121 /// to create toplevel windows.
122 /// ## `hide_titlebar_when_maximized`
123 /// whether to hide the titlebar when
124 /// maximized
125 #[doc(alias = "gdk_x11_window_set_hide_titlebar_when_maximized")]
126 pub fn set_hide_titlebar_when_maximized(&self, hide_titlebar_when_maximized: bool) {
127 unsafe {
128 ffi::gdk_x11_window_set_hide_titlebar_when_maximized(
129 self.to_glib_none().0,
130 hide_titlebar_when_maximized.into_glib(),
131 );
132 }
133 }
134
135 /// GTK+ applications can request a dark theme variant. In order to
136 /// make other applications - namely window managers using GTK+ for
137 /// themeing - aware of this choice, GTK+ uses this function to
138 /// export the requested theme variant as _GTK_THEME_VARIANT property
139 /// on toplevel windows.
140 ///
141 /// Note that this property is automatically updated by GTK+, so this
142 /// function should only be used by applications which do not use GTK+
143 /// to create toplevel windows.
144 /// ## `variant`
145 /// the theme variant to export
146 #[doc(alias = "gdk_x11_window_set_theme_variant")]
147 pub fn set_theme_variant(&self, variant: &str) {
148 unsafe {
149 ffi::gdk_x11_window_set_theme_variant(self.to_glib_none().0, variant.to_glib_none().0);
150 }
151 }
152
153 /// The application can use this call to update the _NET_WM_USER_TIME
154 /// property on a toplevel window. This property stores an Xserver
155 /// time which represents the time of the last user input event
156 /// received for this window. This property may be used by the window
157 /// manager to alter the focus, stacking, and/or placement behavior of
158 /// windows when they are mapped depending on whether the new window
159 /// was created by a user action or is a "pop-up" window activated by a
160 /// timer or some other event.
161 ///
162 /// Note that this property is automatically updated by GDK, so this
163 /// function should only be used by applications which handle input
164 /// events bypassing GDK.
165 /// ## `timestamp`
166 /// An XServer timestamp to which the property should be set
167 #[doc(alias = "gdk_x11_window_set_user_time")]
168 pub fn set_user_time(&self, timestamp: u32) {
169 unsafe {
170 ffi::gdk_x11_window_set_user_time(self.to_glib_none().0, timestamp);
171 }
172 }
173
174 /// This function modifies or removes an arbitrary X11 window
175 /// property of type UTF8_STRING. If the given `self` is
176 /// not a toplevel window, it is ignored.
177 /// ## `name`
178 /// Property name, will be interned as an X atom
179 /// ## `value`
180 /// Property value, or [`None`] to delete
181 #[doc(alias = "gdk_x11_window_set_utf8_property")]
182 pub fn set_utf8_property(&self, name: &str, value: Option<&str>) {
183 unsafe {
184 ffi::gdk_x11_window_set_utf8_property(
185 self.to_glib_none().0,
186 name.to_glib_none().0,
187 value.to_glib_none().0,
188 );
189 }
190 }
191
192 /// Looks up the [`gdk::Window`][crate::gdk::Window] that wraps the given native window handle.
193 /// ## `display`
194 /// the [`gdk::Display`][crate::gdk::Display] corresponding to the
195 /// window handle
196 /// ## `window`
197 /// an Xlib Window
198 ///
199 /// # Returns
200 ///
201 /// the [`gdk::Window`][crate::gdk::Window] wrapper for the native
202 /// window, or [`None`] if there is none.
203 #[doc(alias = "gdk_x11_window_lookup_for_display")]
204 pub fn lookup_for_display(display: &X11Display, window: xlib::Window) -> Option<X11Window> {
205 skip_assert_initialized!();
206 unsafe {
207 from_glib_none(ffi::gdk_x11_window_lookup_for_display(
208 display.to_glib_none().0,
209 window,
210 ))
211 }
212 }
213}