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