Skip to main content

gdk/auto/
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
5#[cfg(feature = "v3_24")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
7use crate::{AnchorHints, Gravity};
8use crate::{
9    Cursor, Device, Display, DragProtocol, DrawingContext, Event, EventMask, FrameClock,
10    FullscreenMode, GLContext, Geometry, InputSource, ModifierType, Rectangle, Screen, Visual,
11    WMDecoration, WMFunction, WindowEdge, WindowHints, WindowState, WindowType, WindowTypeHint,
12    ffi,
13};
14use glib::{
15    object::ObjectType as _,
16    prelude::*,
17    signal::{SignalHandlerId, connect_raw},
18    translate::*,
19};
20use std::boxed::Box as Box_;
21
22glib::wrapper! {
23    ///
24    ///
25    /// This is an Abstract Base Class, you cannot instantiate it.
26    ///
27    /// ## Properties
28    ///
29    ///
30    /// #### `cursor`
31    ///  The mouse pointer for a [`Window`][crate::Window]. See [`Window::set_cursor()`][crate::Window::set_cursor()] and
32    /// [`Window::cursor()`][crate::Window::cursor()] for details.
33    ///
34    /// Readable | Writable
35    ///
36    /// ## Signals
37    ///
38    ///
39    /// #### `create-surface`
40    ///  The ::create-surface signal is emitted when an offscreen window
41    /// needs its surface (re)created, which happens either when the
42    /// window is first drawn to, or when the window is being
43    /// resized. The first signal handler that returns a non-[`None`]
44    /// surface will stop any further signal emission, and its surface
45    /// will be used.
46    ///
47    /// Note that it is not possible to access the window's previous
48    /// surface from within any callback of this signal. Calling
49    /// `gdk_offscreen_window_get_surface()` will lead to a crash.
50    ///
51    ///
52    ///
53    ///
54    /// #### `from-embedder`
55    ///  The ::from-embedder signal is emitted to translate coordinates
56    /// in the embedder of an offscreen window to the offscreen window.
57    ///
58    /// See also [`to-embedder`][struct@crate::Window#to-embedder].
59    ///
60    ///
61    ///
62    ///
63    /// #### `moved-to-rect`
64    ///  Emitted when the position of `window` is finalized after being moved to a
65    /// destination rectangle.
66    ///
67    /// `window` might be flipped over the destination rectangle in order to keep
68    /// it on-screen, in which case `flipped_x` and `flipped_y` will be set to [`true`]
69    /// accordingly.
70    ///
71    /// `flipped_rect` is the ideal position of `window` after any possible
72    /// flipping, but before any possible sliding. `final_rect` is `flipped_rect`,
73    /// but possibly translated in the case that flipping is still ineffective in
74    /// keeping `window` on-screen.
75    ///
76    ///
77    ///
78    ///
79    /// #### `pick-embedded-child`
80    ///  The ::pick-embedded-child signal is emitted to find an embedded
81    /// child at the given position.
82    ///
83    ///
84    ///
85    ///
86    /// #### `to-embedder`
87    ///  The ::to-embedder signal is emitted to translate coordinates
88    /// in an offscreen window to its embedder.
89    ///
90    /// See also [`from-embedder`][struct@crate::Window#from-embedder].
91    ///
92    ///
93    ///
94    /// # Implements
95    ///
96    /// [`WindowExtManual`][trait@crate::prelude::WindowExtManual]
97    #[doc(alias = "GdkWindow")]
98    pub struct Window(Object<ffi::GdkWindow, ffi::GdkWindowClass>);
99
100    match fn {
101        type_ => || ffi::gdk_window_get_type(),
102    }
103}
104
105impl Window {
106    //#[doc(alias = "gdk_window_add_filter")]
107    //pub fn add_filter(&self, function: /*Unimplemented*/Fn(/*Unimplemented*/XEvent, &Event) -> /*Ignored*/FilterReturn, data: /*Unimplemented*/Option<Basic: Pointer>) {
108    //    unsafe { TODO: call ffi:gdk_window_add_filter() }
109    //}
110
111    /// Emits a short beep associated to `self` in the appropriate
112    /// display, if supported. Otherwise, emits a short beep on
113    /// the display just as [`Display::beep()`][crate::Display::beep()].
114    #[doc(alias = "gdk_window_beep")]
115    pub fn beep(&self) {
116        unsafe {
117            ffi::gdk_window_beep(self.to_glib_none().0);
118        }
119    }
120
121    /// Indicates that you are beginning the process of redrawing `region`
122    /// on `self`, and provides you with a [`DrawingContext`][crate::DrawingContext].
123    ///
124    /// If `self` is a top level [`Window`][crate::Window], backed by a native window
125    /// implementation, a backing store (offscreen buffer) large enough to
126    /// contain `region` will be created. The backing store will be initialized
127    /// with the background color or background surface for `self`. Then, all
128    /// drawing operations performed on `self` will be diverted to the
129    /// backing store. When you call `gdk_window_end_frame()`, the contents of
130    /// the backing store will be copied to `self`, making it visible
131    /// on screen. Only the part of `self` contained in `region` will be
132    /// modified; that is, drawing operations are clipped to `region`.
133    ///
134    /// The net result of all this is to remove flicker, because the user
135    /// sees the finished product appear all at once when you call
136    /// [`end_draw_frame()`][Self::end_draw_frame()]. If you draw to `self` directly without
137    /// calling [`begin_draw_frame()`][Self::begin_draw_frame()], the user may see flicker
138    /// as individual drawing operations are performed in sequence.
139    ///
140    /// When using GTK+, the widget system automatically places calls to
141    /// [`begin_draw_frame()`][Self::begin_draw_frame()] and [`end_draw_frame()`][Self::end_draw_frame()] around
142    /// emissions of the `GtkWidget::draw` signal. That is, if you’re
143    /// drawing the contents of the widget yourself, you can assume that the
144    /// widget has a cleared background, is already set as the clip region,
145    /// and already has a backing store. Therefore in most cases, application
146    /// code in GTK does not need to call [`begin_draw_frame()`][Self::begin_draw_frame()]
147    /// explicitly.
148    /// ## `region`
149    /// a Cairo region
150    ///
151    /// # Returns
152    ///
153    /// a [`DrawingContext`][crate::DrawingContext] context that should be
154    ///  used to draw the contents of the window; the returned context is owned
155    ///  by GDK.
156    #[doc(alias = "gdk_window_begin_draw_frame")]
157    pub fn begin_draw_frame(&self, region: &cairo::Region) -> Option<DrawingContext> {
158        unsafe {
159            from_glib_none(ffi::gdk_window_begin_draw_frame(
160                self.to_glib_none().0,
161                region.to_glib_none().0,
162            ))
163        }
164    }
165
166    /// Begins a window move operation (for a toplevel window).
167    ///
168    /// This function assumes that the drag is controlled by the
169    /// client pointer device, use [`begin_move_drag_for_device()`][Self::begin_move_drag_for_device()]
170    /// to begin a drag with a different device.
171    /// ## `button`
172    /// the button being used to drag, or 0 for a keyboard-initiated drag
173    /// ## `root_x`
174    /// root window X coordinate of mouse click that began the drag
175    /// ## `root_y`
176    /// root window Y coordinate of mouse click that began the drag
177    /// ## `timestamp`
178    /// timestamp of mouse click that began the drag
179    #[doc(alias = "gdk_window_begin_move_drag")]
180    pub fn begin_move_drag(&self, button: i32, root_x: i32, root_y: i32, timestamp: u32) {
181        unsafe {
182            ffi::gdk_window_begin_move_drag(
183                self.to_glib_none().0,
184                button,
185                root_x,
186                root_y,
187                timestamp,
188            );
189        }
190    }
191
192    /// Begins a window move operation (for a toplevel window).
193    /// You might use this function to implement a “window move grip,” for
194    /// example. The function works best with window managers that support the
195    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec)
196    /// but has a fallback implementation for other window managers.
197    /// ## `device`
198    /// the device used for the operation
199    /// ## `button`
200    /// the button being used to drag, or 0 for a keyboard-initiated drag
201    /// ## `root_x`
202    /// root window X coordinate of mouse click that began the drag
203    /// ## `root_y`
204    /// root window Y coordinate of mouse click that began the drag
205    /// ## `timestamp`
206    /// timestamp of mouse click that began the drag
207    #[doc(alias = "gdk_window_begin_move_drag_for_device")]
208    pub fn begin_move_drag_for_device(
209        &self,
210        device: &impl IsA<Device>,
211        button: i32,
212        root_x: i32,
213        root_y: i32,
214        timestamp: u32,
215    ) {
216        unsafe {
217            ffi::gdk_window_begin_move_drag_for_device(
218                self.to_glib_none().0,
219                device.as_ref().to_glib_none().0,
220                button,
221                root_x,
222                root_y,
223                timestamp,
224            );
225        }
226    }
227
228    /// Begins a window resize operation (for a toplevel window).
229    ///
230    /// This function assumes that the drag is controlled by the
231    /// client pointer device, use [`begin_resize_drag_for_device()`][Self::begin_resize_drag_for_device()]
232    /// to begin a drag with a different device.
233    /// ## `edge`
234    /// the edge or corner from which the drag is started
235    /// ## `button`
236    /// the button being used to drag, or 0 for a keyboard-initiated drag
237    /// ## `root_x`
238    /// root window X coordinate of mouse click that began the drag
239    /// ## `root_y`
240    /// root window Y coordinate of mouse click that began the drag
241    /// ## `timestamp`
242    /// timestamp of mouse click that began the drag (use `gdk_event_get_time()`)
243    #[doc(alias = "gdk_window_begin_resize_drag")]
244    pub fn begin_resize_drag(
245        &self,
246        edge: WindowEdge,
247        button: i32,
248        root_x: i32,
249        root_y: i32,
250        timestamp: u32,
251    ) {
252        unsafe {
253            ffi::gdk_window_begin_resize_drag(
254                self.to_glib_none().0,
255                edge.into_glib(),
256                button,
257                root_x,
258                root_y,
259                timestamp,
260            );
261        }
262    }
263
264    /// Begins a window resize operation (for a toplevel window).
265    /// You might use this function to implement a “window resize grip,” for
266    /// example; in fact `GtkStatusbar` uses it. The function works best
267    /// with window managers that support the
268    /// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec)
269    /// but has a fallback implementation for other window managers.
270    /// ## `edge`
271    /// the edge or corner from which the drag is started
272    /// ## `device`
273    /// the device used for the operation
274    /// ## `button`
275    /// the button being used to drag, or 0 for a keyboard-initiated drag
276    /// ## `root_x`
277    /// root window X coordinate of mouse click that began the drag
278    /// ## `root_y`
279    /// root window Y coordinate of mouse click that began the drag
280    /// ## `timestamp`
281    /// timestamp of mouse click that began the drag (use `gdk_event_get_time()`)
282    #[doc(alias = "gdk_window_begin_resize_drag_for_device")]
283    pub fn begin_resize_drag_for_device(
284        &self,
285        edge: WindowEdge,
286        device: &impl IsA<Device>,
287        button: i32,
288        root_x: i32,
289        root_y: i32,
290        timestamp: u32,
291    ) {
292        unsafe {
293            ffi::gdk_window_begin_resize_drag_for_device(
294                self.to_glib_none().0,
295                edge.into_glib(),
296                device.as_ref().to_glib_none().0,
297                button,
298                root_x,
299                root_y,
300                timestamp,
301            );
302        }
303    }
304
305    /// Transforms window coordinates from a parent window to a child
306    /// window, where the parent window is the normal parent as returned by
307    /// [`parent()`][Self::parent()] for normal windows, and the window's
308    /// embedder as returned by `gdk_offscreen_window_get_embedder()` for
309    /// offscreen windows.
310    ///
311    /// For normal windows, calling this function is equivalent to subtracting
312    /// the return values of [`position()`][Self::position()] from the parent coordinates.
313    /// For offscreen windows however (which can be arbitrarily transformed),
314    /// this function calls the GdkWindow::from-embedder: signal to translate
315    /// the coordinates.
316    ///
317    /// You should always use this function when writing generic code that
318    /// walks down a window hierarchy.
319    ///
320    /// See also: [`coords_to_parent()`][Self::coords_to_parent()]
321    /// ## `parent_x`
322    /// X coordinate in parent’s coordinate system
323    /// ## `parent_y`
324    /// Y coordinate in parent’s coordinate system
325    ///
326    /// # Returns
327    ///
328    ///
329    /// ## `x`
330    /// return location for X coordinate in child’s coordinate system
331    ///
332    /// ## `y`
333    /// return location for Y coordinate in child’s coordinate system
334    #[doc(alias = "gdk_window_coords_from_parent")]
335    pub fn coords_from_parent(&self, parent_x: f64, parent_y: f64) -> (f64, f64) {
336        unsafe {
337            let mut x = std::mem::MaybeUninit::uninit();
338            let mut y = std::mem::MaybeUninit::uninit();
339            ffi::gdk_window_coords_from_parent(
340                self.to_glib_none().0,
341                parent_x,
342                parent_y,
343                x.as_mut_ptr(),
344                y.as_mut_ptr(),
345            );
346            (x.assume_init(), y.assume_init())
347        }
348    }
349
350    /// Transforms window coordinates from a child window to its parent
351    /// window, where the parent window is the normal parent as returned by
352    /// [`parent()`][Self::parent()] for normal windows, and the window's
353    /// embedder as returned by `gdk_offscreen_window_get_embedder()` for
354    /// offscreen windows.
355    ///
356    /// For normal windows, calling this function is equivalent to adding
357    /// the return values of [`position()`][Self::position()] to the child coordinates.
358    /// For offscreen windows however (which can be arbitrarily transformed),
359    /// this function calls the GdkWindow::to-embedder: signal to translate
360    /// the coordinates.
361    ///
362    /// You should always use this function when writing generic code that
363    /// walks up a window hierarchy.
364    ///
365    /// See also: [`coords_from_parent()`][Self::coords_from_parent()]
366    /// ## `x`
367    /// X coordinate in child’s coordinate system
368    /// ## `y`
369    /// Y coordinate in child’s coordinate system
370    ///
371    /// # Returns
372    ///
373    ///
374    /// ## `parent_x`
375    /// return location for X coordinate
376    /// in parent’s coordinate system, or [`None`]
377    ///
378    /// ## `parent_y`
379    /// return location for Y coordinate
380    /// in parent’s coordinate system, or [`None`]
381    #[doc(alias = "gdk_window_coords_to_parent")]
382    pub fn coords_to_parent(&self, x: f64, y: f64) -> (f64, f64) {
383        unsafe {
384            let mut parent_x = std::mem::MaybeUninit::uninit();
385            let mut parent_y = std::mem::MaybeUninit::uninit();
386            ffi::gdk_window_coords_to_parent(
387                self.to_glib_none().0,
388                x,
389                y,
390                parent_x.as_mut_ptr(),
391                parent_y.as_mut_ptr(),
392            );
393            (parent_x.assume_init(), parent_y.assume_init())
394        }
395    }
396
397    /// Creates a new [`GLContext`][crate::GLContext] matching the
398    /// framebuffer format to the visual of the [`Window`][crate::Window]. The context
399    /// is disconnected from any particular window or surface.
400    ///
401    /// If the creation of the [`GLContext`][crate::GLContext] failed, `error` will be set.
402    ///
403    /// Before using the returned [`GLContext`][crate::GLContext], you will need to
404    /// call [`GLContext::make_current()`][crate::GLContext::make_current()] or [`GLContext::realize()`][crate::GLContext::realize()].
405    ///
406    /// # Returns
407    ///
408    /// the newly created [`GLContext`][crate::GLContext], or
409    /// [`None`] on error
410    #[doc(alias = "gdk_window_create_gl_context")]
411    pub fn create_gl_context(&self) -> Result<GLContext, glib::Error> {
412        unsafe {
413            let mut error = std::ptr::null_mut();
414            let ret = ffi::gdk_window_create_gl_context(self.to_glib_none().0, &mut error);
415            if error.is_null() {
416                Ok(from_glib_full(ret))
417            } else {
418                Err(from_glib_full(error))
419            }
420        }
421    }
422
423    /// Attempt to deiconify (unminimize) `self`. On X11 the window manager may
424    /// choose to ignore the request to deiconify. When using GTK+,
425    /// use `gtk_window_deiconify()` instead of the [`Window`][crate::Window] variant. Or better yet,
426    /// you probably want to use `gtk_window_present_with_time()`, which raises the window, focuses it,
427    /// unminimizes it, and puts it on the current desktop.
428    #[doc(alias = "gdk_window_deiconify")]
429    pub fn deiconify(&self) {
430        unsafe {
431            ffi::gdk_window_deiconify(self.to_glib_none().0);
432        }
433    }
434
435    #[doc(alias = "gdk_window_destroy")]
436    pub fn destroy(&self) {
437        unsafe {
438            ffi::gdk_window_destroy(self.to_glib_none().0);
439        }
440    }
441
442    #[doc(alias = "gdk_window_destroy_notify")]
443    pub fn destroy_notify(&self) {
444        unsafe {
445            ffi::gdk_window_destroy_notify(self.to_glib_none().0);
446        }
447    }
448
449    /// Indicates that the drawing of the contents of `self` started with
450    /// `gdk_window_begin_frame()` has been completed.
451    ///
452    /// This function will take care of destroying the [`DrawingContext`][crate::DrawingContext].
453    ///
454    /// It is an error to call this function without a matching
455    /// `gdk_window_begin_frame()` first.
456    /// ## `context`
457    /// the [`DrawingContext`][crate::DrawingContext] created by [`begin_draw_frame()`][Self::begin_draw_frame()]
458    #[doc(alias = "gdk_window_end_draw_frame")]
459    pub fn end_draw_frame(&self, context: &DrawingContext) {
460        unsafe {
461            ffi::gdk_window_end_draw_frame(self.to_glib_none().0, context.to_glib_none().0);
462        }
463    }
464
465    /// Indicates that the backing store created by the most recent call
466    /// to `gdk_window_begin_paint_region()` should be copied onscreen and
467    /// deleted, leaving the next-most-recent backing store or no backing
468    /// store at all as the active paint region. See
469    /// `gdk_window_begin_paint_region()` for full details.
470    ///
471    /// It is an error to call this function without a matching
472    /// `gdk_window_begin_paint_region()` first.
473    #[doc(alias = "gdk_window_end_paint")]
474    pub fn end_paint(&self) {
475        unsafe {
476            ffi::gdk_window_end_paint(self.to_glib_none().0);
477        }
478    }
479
480    /// Tries to ensure that there is a window-system native window for this
481    /// GdkWindow. This may fail in some situations, returning [`false`].
482    ///
483    /// Offscreen window and children of them can never have native windows.
484    ///
485    /// Some backends may not support native child windows.
486    ///
487    /// # Returns
488    ///
489    /// [`true`] if the window has a native window, [`false`] otherwise
490    #[doc(alias = "gdk_window_ensure_native")]
491    pub fn ensure_native(&self) -> bool {
492        unsafe { from_glib(ffi::gdk_window_ensure_native(self.to_glib_none().0)) }
493    }
494
495    /// Sets keyboard focus to `self`. In most cases, `gtk_window_present_with_time()`
496    /// should be used on a `GtkWindow`, rather than calling this function.
497    /// ## `timestamp`
498    /// timestamp of the event triggering the window focus
499    #[doc(alias = "gdk_window_focus")]
500    pub fn focus(&self, timestamp: u32) {
501        unsafe {
502            ffi::gdk_window_focus(self.to_glib_none().0, timestamp);
503        }
504    }
505
506    /// Temporarily freezes a window such that it won’t receive expose
507    /// events. The window will begin receiving expose events again when
508    /// [`thaw_updates()`][Self::thaw_updates()] is called. If [`freeze_updates()`][Self::freeze_updates()]
509    /// has been called more than once, [`thaw_updates()`][Self::thaw_updates()] must be called
510    /// an equal number of times to begin processing exposes.
511    #[doc(alias = "gdk_window_freeze_updates")]
512    pub fn freeze_updates(&self) {
513        unsafe {
514            ffi::gdk_window_freeze_updates(self.to_glib_none().0);
515        }
516    }
517
518    /// Moves the window into fullscreen mode. This means the
519    /// window covers the entire screen and is above any panels
520    /// or task bars.
521    ///
522    /// If the window was already fullscreen, then this function does nothing.
523    ///
524    /// On X11, asks the window manager to put `self` in a fullscreen
525    /// state, if the window manager supports this operation. Not all
526    /// window managers support this, and some deliberately ignore it or
527    /// don’t have a concept of “fullscreen”; so you can’t rely on the
528    /// fullscreenification actually happening. But it will happen with
529    /// most standard window managers, and GDK makes a best effort to get
530    /// it to happen.
531    #[doc(alias = "gdk_window_fullscreen")]
532    pub fn fullscreen(&self) {
533        unsafe {
534            ffi::gdk_window_fullscreen(self.to_glib_none().0);
535        }
536    }
537
538    /// Moves the window into fullscreen mode on the given monitor. This means
539    /// the window covers the entire screen and is above any panels or task bars.
540    ///
541    /// If the window was already fullscreen, then this function does nothing.
542    /// ## `monitor`
543    /// Which monitor to display fullscreen on.
544    #[doc(alias = "gdk_window_fullscreen_on_monitor")]
545    pub fn fullscreen_on_monitor(&self, monitor: i32) {
546        unsafe {
547            ffi::gdk_window_fullscreen_on_monitor(self.to_glib_none().0, monitor);
548        }
549    }
550
551    /// This function informs GDK that the geometry of an embedded
552    /// offscreen window has changed. This is necessary for GDK to keep
553    /// track of which offscreen window the pointer is in.
554    #[doc(alias = "gdk_window_geometry_changed")]
555    pub fn geometry_changed(&self) {
556        unsafe {
557            ffi::gdk_window_geometry_changed(self.to_glib_none().0);
558        }
559    }
560
561    /// Determines whether or not the desktop environment shuld be hinted that
562    /// the window does not want to receive input focus.
563    ///
564    /// # Returns
565    ///
566    /// whether or not the window should receive input focus.
567    #[doc(alias = "gdk_window_get_accept_focus")]
568    #[doc(alias = "get_accept_focus")]
569    pub fn accepts_focus(&self) -> bool {
570        unsafe { from_glib(ffi::gdk_window_get_accept_focus(self.to_glib_none().0)) }
571    }
572
573    /// Gets the list of children of `self` known to GDK.
574    /// This function only returns children created via GDK,
575    /// so for example it’s useless when used with the root window;
576    /// it only returns windows an application created itself.
577    ///
578    /// The returned list must be freed, but the elements in the
579    /// list need not be.
580    ///
581    /// # Returns
582    ///
583    ///
584    ///  list of child windows inside `self`
585    #[doc(alias = "gdk_window_get_children")]
586    #[doc(alias = "get_children")]
587    pub fn children(&self) -> Vec<Window> {
588        unsafe {
589            FromGlibPtrContainer::from_glib_container(ffi::gdk_window_get_children(
590                self.to_glib_none().0,
591            ))
592        }
593    }
594
595    //#[doc(alias = "gdk_window_get_children_with_user_data")]
596    //#[doc(alias = "get_children_with_user_data")]
597    //pub fn children_with_user_data(&self, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> Vec<Window> {
598    //    unsafe { TODO: call ffi:gdk_window_get_children_with_user_data() }
599    //}
600
601    /// Computes the region of a window that potentially can be written
602    /// to by drawing primitives. This region may not take into account
603    /// other factors such as if the window is obscured by other windows,
604    /// but no area outside of this region will be affected by drawing
605    /// primitives.
606    ///
607    /// # Returns
608    ///
609    /// a [`cairo::Region`][crate::cairo::Region]. This must be freed with `cairo_region_destroy()`
610    ///  when you are done.
611    #[doc(alias = "gdk_window_get_clip_region")]
612    #[doc(alias = "get_clip_region")]
613    pub fn clip_region(&self) -> Option<cairo::Region> {
614        unsafe { from_glib_full(ffi::gdk_window_get_clip_region(self.to_glib_none().0)) }
615    }
616
617    /// Retrieves a [`Cursor`][crate::Cursor] pointer for the cursor currently set on the
618    /// specified [`Window`][crate::Window], or [`None`]. If the return value is [`None`] then
619    /// there is no custom cursor set on the specified window, and it is
620    /// using the cursor for its parent window.
621    ///
622    /// # Returns
623    ///
624    /// a [`Cursor`][crate::Cursor], or [`None`]. The
625    ///  returned object is owned by the [`Window`][crate::Window] and should not be
626    ///  unreferenced directly. Use [`set_cursor()`][Self::set_cursor()] to unset the
627    ///  cursor of the window
628    #[doc(alias = "gdk_window_get_cursor")]
629    #[doc(alias = "get_cursor")]
630    pub fn cursor(&self) -> Option<Cursor> {
631        unsafe { from_glib_none(ffi::gdk_window_get_cursor(self.to_glib_none().0)) }
632    }
633
634    /// Returns the decorations set on the GdkWindow with
635    /// [`set_decorations()`][Self::set_decorations()].
636    ///
637    /// # Returns
638    ///
639    /// [`true`] if the window has decorations set, [`false`] otherwise.
640    ///
641    /// ## `decorations`
642    /// The window decorations will be written here
643    #[doc(alias = "gdk_window_get_decorations")]
644    #[doc(alias = "get_decorations")]
645    pub fn decorations(&self) -> Option<WMDecoration> {
646        unsafe {
647            let mut decorations = std::mem::MaybeUninit::uninit();
648            let ret = from_glib(ffi::gdk_window_get_decorations(
649                self.to_glib_none().0,
650                decorations.as_mut_ptr(),
651            ));
652            if ret {
653                Some(from_glib(decorations.assume_init()))
654            } else {
655                None
656            }
657        }
658    }
659
660    /// Retrieves a [`Cursor`][crate::Cursor] pointer for the `device` currently set on the
661    /// specified [`Window`][crate::Window], or [`None`]. If the return value is [`None`] then
662    /// there is no custom cursor set on the specified window, and it is
663    /// using the cursor for its parent window.
664    /// ## `device`
665    /// a master, pointer [`Device`][crate::Device].
666    ///
667    /// # Returns
668    ///
669    /// a [`Cursor`][crate::Cursor], or [`None`]. The
670    ///  returned object is owned by the [`Window`][crate::Window] and should not be
671    ///  unreferenced directly. Use [`set_cursor()`][Self::set_cursor()] to unset the
672    ///  cursor of the window
673    #[doc(alias = "gdk_window_get_device_cursor")]
674    #[doc(alias = "get_device_cursor")]
675    pub fn device_cursor(&self, device: &impl IsA<Device>) -> Option<Cursor> {
676        unsafe {
677            from_glib_none(ffi::gdk_window_get_device_cursor(
678                self.to_glib_none().0,
679                device.as_ref().to_glib_none().0,
680            ))
681        }
682    }
683
684    /// Returns the event mask for `self` corresponding to an specific device.
685    /// ## `device`
686    /// a [`Device`][crate::Device].
687    ///
688    /// # Returns
689    ///
690    /// device event mask for `self`
691    #[doc(alias = "gdk_window_get_device_events")]
692    #[doc(alias = "get_device_events")]
693    pub fn device_events(&self, device: &impl IsA<Device>) -> EventMask {
694        unsafe {
695            from_glib(ffi::gdk_window_get_device_events(
696                self.to_glib_none().0,
697                device.as_ref().to_glib_none().0,
698            ))
699        }
700    }
701
702    /// Obtains the current device position and modifier state.
703    /// The position is given in coordinates relative to the upper left
704    /// corner of `self`.
705    ///
706    /// Use [`device_position_double()`][Self::device_position_double()] if you need subpixel precision.
707    /// ## `device`
708    /// pointer [`Device`][crate::Device] to query to.
709    ///
710    /// # Returns
711    ///
712    /// The window underneath `device`
713    /// (as with [`DeviceExt::window_at_position()`][crate::prelude::DeviceExt::window_at_position()]), or [`None`] if the
714    /// window is not known to GDK.
715    ///
716    /// ## `x`
717    /// return location for the X coordinate of `device`, or [`None`].
718    ///
719    /// ## `y`
720    /// return location for the Y coordinate of `device`, or [`None`].
721    ///
722    /// ## `mask`
723    /// return location for the modifier mask, or [`None`].
724    #[doc(alias = "gdk_window_get_device_position")]
725    #[doc(alias = "get_device_position")]
726    pub fn device_position(
727        &self,
728        device: &impl IsA<Device>,
729    ) -> (Option<Window>, i32, i32, ModifierType) {
730        unsafe {
731            let mut x = std::mem::MaybeUninit::uninit();
732            let mut y = std::mem::MaybeUninit::uninit();
733            let mut mask = std::mem::MaybeUninit::uninit();
734            let ret = from_glib_none(ffi::gdk_window_get_device_position(
735                self.to_glib_none().0,
736                device.as_ref().to_glib_none().0,
737                x.as_mut_ptr(),
738                y.as_mut_ptr(),
739                mask.as_mut_ptr(),
740            ));
741            (
742                ret,
743                x.assume_init(),
744                y.assume_init(),
745                from_glib(mask.assume_init()),
746            )
747        }
748    }
749
750    /// Obtains the current device position in doubles and modifier state.
751    /// The position is given in coordinates relative to the upper left
752    /// corner of `self`.
753    /// ## `device`
754    /// pointer [`Device`][crate::Device] to query to.
755    ///
756    /// # Returns
757    ///
758    /// The window underneath `device`
759    /// (as with [`DeviceExt::window_at_position()`][crate::prelude::DeviceExt::window_at_position()]), or [`None`] if the
760    /// window is not known to GDK.
761    ///
762    /// ## `x`
763    /// return location for the X coordinate of `device`, or [`None`].
764    ///
765    /// ## `y`
766    /// return location for the Y coordinate of `device`, or [`None`].
767    ///
768    /// ## `mask`
769    /// return location for the modifier mask, or [`None`].
770    #[doc(alias = "gdk_window_get_device_position_double")]
771    #[doc(alias = "get_device_position_double")]
772    pub fn device_position_double(
773        &self,
774        device: &impl IsA<Device>,
775    ) -> (Option<Window>, f64, f64, ModifierType) {
776        unsafe {
777            let mut x = std::mem::MaybeUninit::uninit();
778            let mut y = std::mem::MaybeUninit::uninit();
779            let mut mask = std::mem::MaybeUninit::uninit();
780            let ret = from_glib_none(ffi::gdk_window_get_device_position_double(
781                self.to_glib_none().0,
782                device.as_ref().to_glib_none().0,
783                x.as_mut_ptr(),
784                y.as_mut_ptr(),
785                mask.as_mut_ptr(),
786            ));
787            (
788                ret,
789                x.assume_init(),
790                y.assume_init(),
791                from_glib(mask.assume_init()),
792            )
793        }
794    }
795
796    /// Gets the [`Display`][crate::Display] associated with a [`Window`][crate::Window].
797    ///
798    /// # Returns
799    ///
800    /// the [`Display`][crate::Display] associated with `self`
801    #[doc(alias = "gdk_window_get_display")]
802    #[doc(alias = "get_display")]
803    pub fn display(&self) -> Display {
804        unsafe { from_glib_none(ffi::gdk_window_get_display(self.to_glib_none().0)) }
805    }
806
807    /// Finds out the DND protocol supported by a window.
808    ///
809    /// # Returns
810    ///
811    /// the supported DND protocol.
812    ///
813    /// ## `target`
814    /// location of the window
815    ///  where the drop should happen. This may be `self` or a proxy window,
816    ///  or [`None`] if `self` does not support Drag and Drop.
817    #[doc(alias = "gdk_window_get_drag_protocol")]
818    #[doc(alias = "get_drag_protocol")]
819    pub fn drag_protocol(&self) -> (DragProtocol, Window) {
820        unsafe {
821            let mut target = std::ptr::null_mut();
822            let ret = from_glib(ffi::gdk_window_get_drag_protocol(
823                self.to_glib_none().0,
824                &mut target,
825            ));
826            (ret, from_glib_full(target))
827        }
828    }
829
830    /// Obtains the parent of `self`, as known to GDK. Works like
831    /// [`parent()`][Self::parent()] for normal windows, but returns the
832    /// window’s embedder for offscreen windows.
833    ///
834    /// See also: `gdk_offscreen_window_get_embedder()`
835    ///
836    /// # Returns
837    ///
838    /// effective parent of `self`
839    #[doc(alias = "gdk_window_get_effective_parent")]
840    #[doc(alias = "get_effective_parent")]
841    #[must_use]
842    pub fn effective_parent(&self) -> Option<Window> {
843        unsafe { from_glib_none(ffi::gdk_window_get_effective_parent(self.to_glib_none().0)) }
844    }
845
846    /// Gets the toplevel window that’s an ancestor of `self`.
847    ///
848    /// Works like [`toplevel()`][Self::toplevel()], but treats an offscreen window's
849    /// embedder as its parent, using [`effective_parent()`][Self::effective_parent()].
850    ///
851    /// See also: `gdk_offscreen_window_get_embedder()`
852    ///
853    /// # Returns
854    ///
855    /// the effective toplevel window containing `self`
856    #[doc(alias = "gdk_window_get_effective_toplevel")]
857    #[doc(alias = "get_effective_toplevel")]
858    #[must_use]
859    pub fn effective_toplevel(&self) -> Window {
860        unsafe {
861            from_glib_none(ffi::gdk_window_get_effective_toplevel(
862                self.to_glib_none().0,
863            ))
864        }
865    }
866
867    /// Get the current event compression setting for this window.
868    ///
869    /// # Returns
870    ///
871    /// [`true`] if motion events will be compressed
872    #[doc(alias = "gdk_window_get_event_compression")]
873    #[doc(alias = "get_event_compression")]
874    pub fn does_event_compression(&self) -> bool {
875        unsafe { from_glib(ffi::gdk_window_get_event_compression(self.to_glib_none().0)) }
876    }
877
878    /// Gets the event mask for `self` for all master input devices. See
879    /// [`set_events()`][Self::set_events()].
880    ///
881    /// # Returns
882    ///
883    /// event mask for `self`
884    #[doc(alias = "gdk_window_get_events")]
885    #[doc(alias = "get_events")]
886    pub fn events(&self) -> EventMask {
887        unsafe { from_glib(ffi::gdk_window_get_events(self.to_glib_none().0)) }
888    }
889
890    /// Determines whether or not the desktop environment should be hinted that the
891    /// window does not want to receive input focus when it is mapped.
892    ///
893    /// # Returns
894    ///
895    /// whether or not the window wants to receive input focus when
896    /// it is mapped.
897    #[doc(alias = "gdk_window_get_focus_on_map")]
898    #[doc(alias = "get_focus_on_map")]
899    pub fn gets_focus_on_map(&self) -> bool {
900        unsafe { from_glib(ffi::gdk_window_get_focus_on_map(self.to_glib_none().0)) }
901    }
902
903    /// Gets the frame clock for the window. The frame clock for a window
904    /// never changes unless the window is reparented to a new toplevel
905    /// window.
906    ///
907    /// # Returns
908    ///
909    /// the frame clock
910    #[doc(alias = "gdk_window_get_frame_clock")]
911    #[doc(alias = "get_frame_clock")]
912    pub fn frame_clock(&self) -> Option<FrameClock> {
913        unsafe { from_glib_none(ffi::gdk_window_get_frame_clock(self.to_glib_none().0)) }
914    }
915
916    /// Obtains the bounding box of the window, including window manager
917    /// titlebar/borders if any. The frame position is given in root window
918    /// coordinates. To get the position of the window itself (rather than
919    /// the frame) in root window coordinates, use [`origin()`][Self::origin()].
920    ///
921    /// # Returns
922    ///
923    ///
924    /// ## `rect`
925    /// rectangle to fill with bounding box of the window frame
926    #[doc(alias = "gdk_window_get_frame_extents")]
927    #[doc(alias = "get_frame_extents")]
928    pub fn frame_extents(&self) -> Rectangle {
929        unsafe {
930            let mut rect = Rectangle::uninitialized();
931            ffi::gdk_window_get_frame_extents(self.to_glib_none().0, rect.to_glib_none_mut().0);
932            rect
933        }
934    }
935
936    /// Obtains the [`FullscreenMode`][crate::FullscreenMode] of the `self`.
937    ///
938    /// # Returns
939    ///
940    /// The [`FullscreenMode`][crate::FullscreenMode] applied to the window when fullscreen.
941    #[doc(alias = "gdk_window_get_fullscreen_mode")]
942    #[doc(alias = "get_fullscreen_mode")]
943    pub fn fullscreen_mode(&self) -> FullscreenMode {
944        unsafe { from_glib(ffi::gdk_window_get_fullscreen_mode(self.to_glib_none().0)) }
945    }
946
947    /// Any of the return location arguments to this function may be [`None`],
948    /// if you aren’t interested in getting the value of that field.
949    ///
950    /// The X and Y coordinates returned are relative to the parent window
951    /// of `self`, which for toplevels usually means relative to the
952    /// window decorations (titlebar, etc.) rather than relative to the
953    /// root window (screen-size background window).
954    ///
955    /// On the X11 platform, the geometry is obtained from the X server,
956    /// so reflects the latest position of `self`; this may be out-of-sync
957    /// with the position of `self` delivered in the most-recently-processed
958    /// [`EventConfigure`][crate::EventConfigure]. [`position()`][Self::position()] in contrast gets the
959    /// position from the most recent configure event.
960    ///
961    /// Note: If `self` is not a toplevel, it is much better
962    /// to call [`position()`][Self::position()], [`width()`][Self::width()] and
963    /// [`height()`][Self::height()] instead, because it avoids the roundtrip to
964    /// the X server and because these functions support the full 32-bit
965    /// coordinate space, whereas [`geometry()`][Self::geometry()] is restricted to
966    /// the 16-bit coordinates of X11.
967    ///
968    /// # Returns
969    ///
970    ///
971    /// ## `x`
972    /// return location for X coordinate of window (relative to its parent)
973    ///
974    /// ## `y`
975    /// return location for Y coordinate of window (relative to its parent)
976    ///
977    /// ## `width`
978    /// return location for width of window
979    ///
980    /// ## `height`
981    /// return location for height of window
982    #[doc(alias = "gdk_window_get_geometry")]
983    #[doc(alias = "get_geometry")]
984    pub fn geometry(&self) -> (i32, i32, i32, i32) {
985        unsafe {
986            let mut x = std::mem::MaybeUninit::uninit();
987            let mut y = std::mem::MaybeUninit::uninit();
988            let mut width = std::mem::MaybeUninit::uninit();
989            let mut height = std::mem::MaybeUninit::uninit();
990            ffi::gdk_window_get_geometry(
991                self.to_glib_none().0,
992                x.as_mut_ptr(),
993                y.as_mut_ptr(),
994                width.as_mut_ptr(),
995                height.as_mut_ptr(),
996            );
997            (
998                x.assume_init(),
999                y.assume_init(),
1000                width.assume_init(),
1001                height.assume_init(),
1002            )
1003        }
1004    }
1005
1006    /// Returns the group leader window for `self`. See [`set_group()`][Self::set_group()].
1007    ///
1008    /// # Returns
1009    ///
1010    /// the group leader window for `self`
1011    #[doc(alias = "gdk_window_get_group")]
1012    #[doc(alias = "get_group")]
1013    #[must_use]
1014    pub fn group(&self) -> Option<Window> {
1015        unsafe { from_glib_none(ffi::gdk_window_get_group(self.to_glib_none().0)) }
1016    }
1017
1018    /// Returns the height of the given `self`.
1019    ///
1020    /// On the X11 platform the returned size is the size reported in the
1021    /// most-recently-processed configure event, rather than the current
1022    /// size on the X server.
1023    ///
1024    /// # Returns
1025    ///
1026    /// The height of `self`
1027    #[doc(alias = "gdk_window_get_height")]
1028    #[doc(alias = "get_height")]
1029    pub fn height(&self) -> i32 {
1030        unsafe { ffi::gdk_window_get_height(self.to_glib_none().0) }
1031    }
1032
1033    /// Determines whether or not the window manager is hinted that `self`
1034    /// has modal behaviour.
1035    ///
1036    /// # Returns
1037    ///
1038    /// whether or not the window has the modal hint set.
1039    #[doc(alias = "gdk_window_get_modal_hint")]
1040    #[doc(alias = "get_modal_hint")]
1041    pub fn is_modal_hint(&self) -> bool {
1042        unsafe { from_glib(ffi::gdk_window_get_modal_hint(self.to_glib_none().0)) }
1043    }
1044
1045    /// Obtains the position of a window in root window coordinates.
1046    /// (Compare with [`position()`][Self::position()] and
1047    /// [`geometry()`][Self::geometry()] which return the position of a window
1048    /// relative to its parent window.)
1049    ///
1050    /// # Returns
1051    ///
1052    /// not meaningful, ignore
1053    ///
1054    /// ## `x`
1055    /// return location for X coordinate
1056    ///
1057    /// ## `y`
1058    /// return location for Y coordinate
1059    #[doc(alias = "gdk_window_get_origin")]
1060    #[doc(alias = "get_origin")]
1061    pub fn origin(&self) -> (i32, i32, i32) {
1062        unsafe {
1063            let mut x = std::mem::MaybeUninit::uninit();
1064            let mut y = std::mem::MaybeUninit::uninit();
1065            let ret =
1066                ffi::gdk_window_get_origin(self.to_glib_none().0, x.as_mut_ptr(), y.as_mut_ptr());
1067            (ret, x.assume_init(), y.assume_init())
1068        }
1069    }
1070
1071    /// Obtains the parent of `self`, as known to GDK. Does not query the
1072    /// X server; thus this returns the parent as passed to [`new()`][Self::new()],
1073    /// not the actual parent. This should never matter unless you’re using
1074    /// Xlib calls mixed with GDK calls on the X11 platform. It may also
1075    /// matter for toplevel windows, because the window manager may choose
1076    /// to reparent them.
1077    ///
1078    /// Note that you should use [`effective_parent()`][Self::effective_parent()] when
1079    /// writing generic code that walks up a window hierarchy, because
1080    /// [`parent()`][Self::parent()] will most likely not do what you expect if
1081    /// there are offscreen windows in the hierarchy.
1082    ///
1083    /// # Returns
1084    ///
1085    /// parent of `self`
1086    #[doc(alias = "gdk_window_get_parent")]
1087    #[doc(alias = "get_parent")]
1088    #[must_use]
1089    pub fn parent(&self) -> Option<Window> {
1090        unsafe { from_glib_none(ffi::gdk_window_get_parent(self.to_glib_none().0)) }
1091    }
1092
1093    /// Returns whether input to the window is passed through to the window
1094    /// below.
1095    ///
1096    /// See [`set_pass_through()`][Self::set_pass_through()] for details
1097    #[doc(alias = "gdk_window_get_pass_through")]
1098    #[doc(alias = "get_pass_through")]
1099    pub fn is_pass_through(&self) -> bool {
1100        unsafe { from_glib(ffi::gdk_window_get_pass_through(self.to_glib_none().0)) }
1101    }
1102
1103    /// Obtains the position of the window as reported in the
1104    /// most-recently-processed [`EventConfigure`][crate::EventConfigure]. Contrast with
1105    /// [`geometry()`][Self::geometry()] which queries the X server for the
1106    /// current window position, regardless of which events have been
1107    /// received or processed.
1108    ///
1109    /// The position coordinates are relative to the window’s parent window.
1110    ///
1111    /// # Returns
1112    ///
1113    ///
1114    /// ## `x`
1115    /// X coordinate of window
1116    ///
1117    /// ## `y`
1118    /// Y coordinate of window
1119    #[doc(alias = "gdk_window_get_position")]
1120    #[doc(alias = "get_position")]
1121    pub fn position(&self) -> (i32, i32) {
1122        unsafe {
1123            let mut x = std::mem::MaybeUninit::uninit();
1124            let mut y = std::mem::MaybeUninit::uninit();
1125            ffi::gdk_window_get_position(self.to_glib_none().0, x.as_mut_ptr(), y.as_mut_ptr());
1126            (x.assume_init(), y.assume_init())
1127        }
1128    }
1129
1130    /// Obtains the position of a window position in root
1131    /// window coordinates. This is similar to
1132    /// [`origin()`][Self::origin()] but allows you to pass
1133    /// in any position in the window, not just the origin.
1134    /// ## `x`
1135    /// X coordinate in window
1136    /// ## `y`
1137    /// Y coordinate in window
1138    ///
1139    /// # Returns
1140    ///
1141    ///
1142    /// ## `root_x`
1143    /// return location for X coordinate
1144    ///
1145    /// ## `root_y`
1146    /// return location for Y coordinate
1147    #[doc(alias = "gdk_window_get_root_coords")]
1148    #[doc(alias = "get_root_coords")]
1149    pub fn root_coords(&self, x: i32, y: i32) -> (i32, i32) {
1150        unsafe {
1151            let mut root_x = std::mem::MaybeUninit::uninit();
1152            let mut root_y = std::mem::MaybeUninit::uninit();
1153            ffi::gdk_window_get_root_coords(
1154                self.to_glib_none().0,
1155                x,
1156                y,
1157                root_x.as_mut_ptr(),
1158                root_y.as_mut_ptr(),
1159            );
1160            (root_x.assume_init(), root_y.assume_init())
1161        }
1162    }
1163
1164    /// Obtains the top-left corner of the window manager frame in root
1165    /// window coordinates.
1166    ///
1167    /// # Returns
1168    ///
1169    ///
1170    /// ## `x`
1171    /// return location for X position of window frame
1172    ///
1173    /// ## `y`
1174    /// return location for Y position of window frame
1175    #[doc(alias = "gdk_window_get_root_origin")]
1176    #[doc(alias = "get_root_origin")]
1177    pub fn root_origin(&self) -> (i32, i32) {
1178        unsafe {
1179            let mut x = std::mem::MaybeUninit::uninit();
1180            let mut y = std::mem::MaybeUninit::uninit();
1181            ffi::gdk_window_get_root_origin(self.to_glib_none().0, x.as_mut_ptr(), y.as_mut_ptr());
1182            (x.assume_init(), y.assume_init())
1183        }
1184    }
1185
1186    /// Returns the internal scale factor that maps from window coordiantes
1187    /// to the actual device pixels. On traditional systems this is 1, but
1188    /// on very high density outputs this can be a higher value (often 2).
1189    ///
1190    /// A higher value means that drawing is automatically scaled up to
1191    /// a higher resolution, so any code doing drawing will automatically look
1192    /// nicer. However, if you are supplying pixel-based data the scale
1193    /// value can be used to determine whether to use a pixel resource
1194    /// with higher resolution data.
1195    ///
1196    /// The scale of a window may change during runtime, if this happens
1197    /// a configure event will be sent to the toplevel window.
1198    ///
1199    /// # Returns
1200    ///
1201    /// the scale factor
1202    #[doc(alias = "gdk_window_get_scale_factor")]
1203    #[doc(alias = "get_scale_factor")]
1204    pub fn scale_factor(&self) -> i32 {
1205        unsafe { ffi::gdk_window_get_scale_factor(self.to_glib_none().0) }
1206    }
1207
1208    /// Gets the [`Screen`][crate::Screen] associated with a [`Window`][crate::Window].
1209    ///
1210    /// # Returns
1211    ///
1212    /// the [`Screen`][crate::Screen] associated with `self`
1213    #[doc(alias = "gdk_window_get_screen")]
1214    #[doc(alias = "get_screen")]
1215    pub fn screen(&self) -> Screen {
1216        unsafe { from_glib_none(ffi::gdk_window_get_screen(self.to_glib_none().0)) }
1217    }
1218
1219    /// Returns the event mask for `self` corresponding to the device class specified
1220    /// by `source`.
1221    /// ## `source`
1222    /// a [`InputSource`][crate::InputSource] to define the source class.
1223    ///
1224    /// # Returns
1225    ///
1226    /// source event mask for `self`
1227    #[doc(alias = "gdk_window_get_source_events")]
1228    #[doc(alias = "get_source_events")]
1229    pub fn source_events(&self, source: InputSource) -> EventMask {
1230        unsafe {
1231            from_glib(ffi::gdk_window_get_source_events(
1232                self.to_glib_none().0,
1233                source.into_glib(),
1234            ))
1235        }
1236    }
1237
1238    /// Gets the bitwise OR of the currently active window state flags,
1239    /// from the [`WindowState`][crate::WindowState] enumeration.
1240    ///
1241    /// # Returns
1242    ///
1243    /// window state bitfield
1244    #[doc(alias = "gdk_window_get_state")]
1245    #[doc(alias = "get_state")]
1246    pub fn state(&self) -> WindowState {
1247        unsafe { from_glib(ffi::gdk_window_get_state(self.to_glib_none().0)) }
1248    }
1249
1250    /// Returns [`true`] if the window is aware of the existence of multiple
1251    /// devices.
1252    ///
1253    /// # Returns
1254    ///
1255    /// [`true`] if the window handles multidevice features.
1256    #[doc(alias = "gdk_window_get_support_multidevice")]
1257    #[doc(alias = "get_support_multidevice")]
1258    pub fn supports_multidevice(&self) -> bool {
1259        unsafe {
1260            from_glib(ffi::gdk_window_get_support_multidevice(
1261                self.to_glib_none().0,
1262            ))
1263        }
1264    }
1265
1266    /// Gets the toplevel window that’s an ancestor of `self`.
1267    ///
1268    /// Any window type but [`WindowType::Child`][crate::WindowType::Child] is considered a
1269    /// toplevel window, as is a [`WindowType::Child`][crate::WindowType::Child] window that
1270    /// has a root window as parent.
1271    ///
1272    /// Note that you should use [`effective_toplevel()`][Self::effective_toplevel()] when
1273    /// you want to get to a window’s toplevel as seen on screen, because
1274    /// [`toplevel()`][Self::toplevel()] will most likely not do what you expect
1275    /// if there are offscreen windows in the hierarchy.
1276    ///
1277    /// # Returns
1278    ///
1279    /// the toplevel window containing `self`
1280    #[doc(alias = "gdk_window_get_toplevel")]
1281    #[doc(alias = "get_toplevel")]
1282    #[must_use]
1283    pub fn toplevel(&self) -> Window {
1284        unsafe { from_glib_none(ffi::gdk_window_get_toplevel(self.to_glib_none().0)) }
1285    }
1286
1287    /// This function returns the type hint set for a window.
1288    ///
1289    /// # Returns
1290    ///
1291    /// The type hint set for `self`
1292    #[doc(alias = "gdk_window_get_type_hint")]
1293    #[doc(alias = "get_type_hint")]
1294    pub fn type_hint(&self) -> WindowTypeHint {
1295        unsafe { from_glib(ffi::gdk_window_get_type_hint(self.to_glib_none().0)) }
1296    }
1297
1298    /// Transfers ownership of the update area from `self` to the caller
1299    /// of the function. That is, after calling this function, `self` will
1300    /// no longer have an invalid/dirty region; the update area is removed
1301    /// from `self` and handed to you. If a window has no update area,
1302    /// [`update_area()`][Self::update_area()] returns [`None`]. You are responsible for
1303    /// calling `cairo_region_destroy()` on the returned region if it’s non-[`None`].
1304    ///
1305    /// # Returns
1306    ///
1307    /// the update area for `self`
1308    #[doc(alias = "gdk_window_get_update_area")]
1309    #[doc(alias = "get_update_area")]
1310    pub fn update_area(&self) -> Option<cairo::Region> {
1311        unsafe { from_glib_full(ffi::gdk_window_get_update_area(self.to_glib_none().0)) }
1312    }
1313
1314    /// Computes the region of the `self` that is potentially visible.
1315    /// This does not necessarily take into account if the window is
1316    /// obscured by other windows, but no area outside of this region
1317    /// is visible.
1318    ///
1319    /// # Returns
1320    ///
1321    /// a [`cairo::Region`][crate::cairo::Region]. This must be freed with `cairo_region_destroy()`
1322    ///  when you are done.
1323    #[doc(alias = "gdk_window_get_visible_region")]
1324    #[doc(alias = "get_visible_region")]
1325    pub fn visible_region(&self) -> Option<cairo::Region> {
1326        unsafe { from_glib_full(ffi::gdk_window_get_visible_region(self.to_glib_none().0)) }
1327    }
1328
1329    /// Gets the [`Visual`][crate::Visual] describing the pixel format of `self`.
1330    ///
1331    /// # Returns
1332    ///
1333    /// a [`Visual`][crate::Visual]
1334    #[doc(alias = "gdk_window_get_visual")]
1335    #[doc(alias = "get_visual")]
1336    pub fn visual(&self) -> Visual {
1337        unsafe { from_glib_none(ffi::gdk_window_get_visual(self.to_glib_none().0)) }
1338    }
1339
1340    /// Returns the width of the given `self`.
1341    ///
1342    /// On the X11 platform the returned size is the size reported in the
1343    /// most-recently-processed configure event, rather than the current
1344    /// size on the X server.
1345    ///
1346    /// # Returns
1347    ///
1348    /// The width of `self`
1349    #[doc(alias = "gdk_window_get_width")]
1350    #[doc(alias = "get_width")]
1351    pub fn width(&self) -> i32 {
1352        unsafe { ffi::gdk_window_get_width(self.to_glib_none().0) }
1353    }
1354
1355    /// Gets the type of the window. See [`WindowType`][crate::WindowType].
1356    ///
1357    /// # Returns
1358    ///
1359    /// type of window
1360    #[doc(alias = "gdk_window_get_window_type")]
1361    #[doc(alias = "get_window_type")]
1362    pub fn window_type(&self) -> WindowType {
1363        unsafe { from_glib(ffi::gdk_window_get_window_type(self.to_glib_none().0)) }
1364    }
1365
1366    /// Checks whether the window has a native window or not. Note that
1367    /// you can use [`ensure_native()`][Self::ensure_native()] if a native window is needed.
1368    ///
1369    /// # Returns
1370    ///
1371    /// [`true`] if the `self` has a native window, [`false`] otherwise.
1372    #[doc(alias = "gdk_window_has_native")]
1373    pub fn has_native(&self) -> bool {
1374        unsafe { from_glib(ffi::gdk_window_has_native(self.to_glib_none().0)) }
1375    }
1376
1377    /// For toplevel windows, withdraws them, so they will no longer be
1378    /// known to the window manager; for all windows, unmaps them, so
1379    /// they won’t be displayed. Normally done automatically as
1380    /// part of `gtk_widget_hide()`.
1381    #[doc(alias = "gdk_window_hide")]
1382    pub fn hide(&self) {
1383        unsafe {
1384            ffi::gdk_window_hide(self.to_glib_none().0);
1385        }
1386    }
1387
1388    /// Asks to iconify (minimize) `self`. The window manager may choose
1389    /// to ignore the request, but normally will honor it. Using
1390    /// `gtk_window_iconify()` is preferred, if you have a `GtkWindow` widget.
1391    ///
1392    /// This function only makes sense when `self` is a toplevel window.
1393    #[doc(alias = "gdk_window_iconify")]
1394    pub fn iconify(&self) {
1395        unsafe {
1396            ffi::gdk_window_iconify(self.to_glib_none().0);
1397        }
1398    }
1399
1400    /// Like [`shape_combine_region()`][Self::shape_combine_region()], but the shape applies
1401    /// only to event handling. Mouse events which happen while
1402    /// the pointer position corresponds to an unset bit in the
1403    /// mask will be passed on the window below `self`.
1404    ///
1405    /// An input shape is typically used with RGBA windows.
1406    /// The alpha channel of the window defines which pixels are
1407    /// invisible and allows for nicely antialiased borders,
1408    /// and the input shape controls where the window is
1409    /// “clickable”.
1410    ///
1411    /// On the X11 platform, this requires version 1.1 of the
1412    /// shape extension.
1413    ///
1414    /// On the Win32 platform, this functionality is not present and the
1415    /// function does nothing.
1416    /// ## `shape_region`
1417    /// region of window to be non-transparent
1418    /// ## `offset_x`
1419    /// X position of `shape_region` in `self` coordinates
1420    /// ## `offset_y`
1421    /// Y position of `shape_region` in `self` coordinates
1422    #[doc(alias = "gdk_window_input_shape_combine_region")]
1423    pub fn input_shape_combine_region(
1424        &self,
1425        shape_region: &cairo::Region,
1426        offset_x: i32,
1427        offset_y: i32,
1428    ) {
1429        unsafe {
1430            ffi::gdk_window_input_shape_combine_region(
1431                self.to_glib_none().0,
1432                shape_region.to_glib_none().0,
1433                offset_x,
1434                offset_y,
1435            );
1436        }
1437    }
1438
1439    /// Adds `region` to the update area for `self`. The update area is the
1440    /// region that needs to be redrawn, or “dirty region.” The call
1441    /// `gdk_window_process_updates()` sends one or more expose events to the
1442    /// window, which together cover the entire update area. An
1443    /// application would normally redraw the contents of `self` in
1444    /// response to those expose events.
1445    ///
1446    /// GDK will call `gdk_window_process_all_updates()` on your behalf
1447    /// whenever your program returns to the main loop and becomes idle, so
1448    /// normally there’s no need to do that manually, you just need to
1449    /// invalidate regions that you know should be redrawn.
1450    ///
1451    /// The `child_func` parameter controls whether the region of
1452    /// each child window that intersects `region` will also be invalidated.
1453    /// Only children for which `child_func` returns [`true`] will have the area
1454    /// invalidated.
1455    /// ## `region`
1456    /// a [`cairo::Region`][crate::cairo::Region]
1457    /// ## `child_func`
1458    /// function to use to decide if to
1459    ///  recurse to a child, [`None`] means never recurse.
1460    #[doc(alias = "gdk_window_invalidate_maybe_recurse")]
1461    pub fn invalidate_maybe_recurse(
1462        &self,
1463        region: &cairo::Region,
1464        child_func: Option<&mut dyn FnMut(&Window) -> bool>,
1465    ) {
1466        let mut child_func_data: Option<&mut dyn FnMut(&Window) -> bool> = child_func;
1467        unsafe extern "C" fn child_func_func(
1468            window: *mut ffi::GdkWindow,
1469            user_data: glib::ffi::gpointer,
1470        ) -> glib::ffi::gboolean {
1471            unsafe {
1472                let window = from_glib_borrow(window);
1473                let callback = user_data as *mut Option<&mut dyn FnMut(&Window) -> bool>;
1474                if let Some(ref mut callback) = *callback {
1475                    callback(&window)
1476                } else {
1477                    panic!("cannot get closure...")
1478                }
1479                .into_glib()
1480            }
1481        }
1482        let child_func = if child_func_data.is_some() {
1483            Some(child_func_func as _)
1484        } else {
1485            None
1486        };
1487        let super_callback0: &mut Option<&mut dyn FnMut(&Window) -> bool> = &mut child_func_data;
1488        unsafe {
1489            ffi::gdk_window_invalidate_maybe_recurse(
1490                self.to_glib_none().0,
1491                region.to_glib_none().0,
1492                child_func,
1493                super_callback0 as *mut _ as *mut _,
1494            );
1495        }
1496    }
1497
1498    /// A convenience wrapper around [`invalidate_region()`][Self::invalidate_region()] which
1499    /// invalidates a rectangular region. See
1500    /// [`invalidate_region()`][Self::invalidate_region()] for details.
1501    /// ## `rect`
1502    /// rectangle to invalidate or [`None`] to invalidate the whole
1503    ///  window
1504    /// ## `invalidate_children`
1505    /// whether to also invalidate child windows
1506    #[doc(alias = "gdk_window_invalidate_rect")]
1507    pub fn invalidate_rect(&self, rect: Option<&Rectangle>, invalidate_children: bool) {
1508        unsafe {
1509            ffi::gdk_window_invalidate_rect(
1510                self.to_glib_none().0,
1511                rect.to_glib_none().0,
1512                invalidate_children.into_glib(),
1513            );
1514        }
1515    }
1516
1517    /// Adds `region` to the update area for `self`. The update area is the
1518    /// region that needs to be redrawn, or “dirty region.” The call
1519    /// `gdk_window_process_updates()` sends one or more expose events to the
1520    /// window, which together cover the entire update area. An
1521    /// application would normally redraw the contents of `self` in
1522    /// response to those expose events.
1523    ///
1524    /// GDK will call `gdk_window_process_all_updates()` on your behalf
1525    /// whenever your program returns to the main loop and becomes idle, so
1526    /// normally there’s no need to do that manually, you just need to
1527    /// invalidate regions that you know should be redrawn.
1528    ///
1529    /// The `invalidate_children` parameter controls whether the region of
1530    /// each child window that intersects `region` will also be invalidated.
1531    /// If [`false`], then the update area for child windows will remain
1532    /// unaffected. See gdk_window_invalidate_maybe_recurse if you need
1533    /// fine grained control over which children are invalidated.
1534    /// ## `region`
1535    /// a [`cairo::Region`][crate::cairo::Region]
1536    /// ## `invalidate_children`
1537    /// [`true`] to also invalidate child windows
1538    #[doc(alias = "gdk_window_invalidate_region")]
1539    pub fn invalidate_region(&self, region: &cairo::Region, invalidate_children: bool) {
1540        unsafe {
1541            ffi::gdk_window_invalidate_region(
1542                self.to_glib_none().0,
1543                region.to_glib_none().0,
1544                invalidate_children.into_glib(),
1545            );
1546        }
1547    }
1548
1549    /// Check to see if a window is destroyed..
1550    ///
1551    /// # Returns
1552    ///
1553    /// [`true`] if the window is destroyed
1554    #[doc(alias = "gdk_window_is_destroyed")]
1555    pub fn is_destroyed(&self) -> bool {
1556        unsafe { from_glib(ffi::gdk_window_is_destroyed(self.to_glib_none().0)) }
1557    }
1558
1559    /// Determines whether or not the window is an input only window.
1560    ///
1561    /// # Returns
1562    ///
1563    /// [`true`] if `self` is input only
1564    #[doc(alias = "gdk_window_is_input_only")]
1565    pub fn is_input_only(&self) -> bool {
1566        unsafe { from_glib(ffi::gdk_window_is_input_only(self.to_glib_none().0)) }
1567    }
1568
1569    /// Determines whether or not the window is shaped.
1570    ///
1571    /// # Returns
1572    ///
1573    /// [`true`] if `self` is shaped
1574    #[doc(alias = "gdk_window_is_shaped")]
1575    pub fn is_shaped(&self) -> bool {
1576        unsafe { from_glib(ffi::gdk_window_is_shaped(self.to_glib_none().0)) }
1577    }
1578
1579    /// Check if the window and all ancestors of the window are
1580    /// mapped. (This is not necessarily "viewable" in the X sense, since
1581    /// we only check as far as we have GDK window parents, not to the root
1582    /// window.)
1583    ///
1584    /// # Returns
1585    ///
1586    /// [`true`] if the window is viewable
1587    #[doc(alias = "gdk_window_is_viewable")]
1588    pub fn is_viewable(&self) -> bool {
1589        unsafe { from_glib(ffi::gdk_window_is_viewable(self.to_glib_none().0)) }
1590    }
1591
1592    /// Checks whether the window has been mapped (with [`show()`][Self::show()] or
1593    /// [`show_unraised()`][Self::show_unraised()]).
1594    ///
1595    /// # Returns
1596    ///
1597    /// [`true`] if the window is mapped
1598    #[doc(alias = "gdk_window_is_visible")]
1599    pub fn is_visible(&self) -> bool {
1600        unsafe { from_glib(ffi::gdk_window_is_visible(self.to_glib_none().0)) }
1601    }
1602
1603    /// Lowers `self` to the bottom of the Z-order (stacking order), so that
1604    /// other windows with the same parent window appear above `self`.
1605    /// This is true whether or not the other windows are visible.
1606    ///
1607    /// If `self` is a toplevel, the window manager may choose to deny the
1608    /// request to move the window in the Z-order, [`lower()`][Self::lower()] only
1609    /// requests the restack, does not guarantee it.
1610    ///
1611    /// Note that [`show()`][Self::show()] raises the window again, so don’t call this
1612    /// function before [`show()`][Self::show()]. (Try [`show_unraised()`][Self::show_unraised()].)
1613    #[doc(alias = "gdk_window_lower")]
1614    pub fn lower(&self) {
1615        unsafe {
1616            ffi::gdk_window_lower(self.to_glib_none().0);
1617        }
1618    }
1619
1620    /// If you call this during a paint (e.g. between `gdk_window_begin_paint_region()`
1621    /// and [`end_paint()`][Self::end_paint()] then GDK will mark the current clip region of the
1622    /// window as being drawn. This is required when mixing GL rendering via
1623    /// `gdk_cairo_draw_from_gl()` and cairo rendering, as otherwise GDK has no way
1624    /// of knowing when something paints over the GL-drawn regions.
1625    ///
1626    /// This is typically called automatically by GTK+ and you don't need
1627    /// to care about this.
1628    /// ## `cr`
1629    /// a [`cairo::Context`][crate::cairo::Context]
1630    #[doc(alias = "gdk_window_mark_paint_from_clip")]
1631    pub fn mark_paint_from_clip(&self, cr: &cairo::Context) {
1632        unsafe {
1633            ffi::gdk_window_mark_paint_from_clip(
1634                self.to_glib_none().0,
1635                mut_override(cr.to_glib_none().0),
1636            );
1637        }
1638    }
1639
1640    /// Maximizes the window. If the window was already maximized, then
1641    /// this function does nothing.
1642    ///
1643    /// On X11, asks the window manager to maximize `self`, if the window
1644    /// manager supports this operation. Not all window managers support
1645    /// this, and some deliberately ignore it or don’t have a concept of
1646    /// “maximized”; so you can’t rely on the maximization actually
1647    /// happening. But it will happen with most standard window managers,
1648    /// and GDK makes a best effort to get it to happen.
1649    ///
1650    /// On Windows, reliably maximizes the window.
1651    #[doc(alias = "gdk_window_maximize")]
1652    pub fn maximize(&self) {
1653        unsafe {
1654            ffi::gdk_window_maximize(self.to_glib_none().0);
1655        }
1656    }
1657
1658    /// Merges the input shape masks for any child windows into the
1659    /// input shape mask for `self`. i.e. the union of all input masks
1660    /// for `self` and its children will become the new input mask
1661    /// for `self`. See [`input_shape_combine_region()`][Self::input_shape_combine_region()].
1662    ///
1663    /// This function is distinct from [`set_child_input_shapes()`][Self::set_child_input_shapes()]
1664    /// because it includes `self`’s input shape mask in the set of
1665    /// shapes to be merged.
1666    #[doc(alias = "gdk_window_merge_child_input_shapes")]
1667    pub fn merge_child_input_shapes(&self) {
1668        unsafe {
1669            ffi::gdk_window_merge_child_input_shapes(self.to_glib_none().0);
1670        }
1671    }
1672
1673    /// Merges the shape masks for any child windows into the
1674    /// shape mask for `self`. i.e. the union of all masks
1675    /// for `self` and its children will become the new mask
1676    /// for `self`. See [`shape_combine_region()`][Self::shape_combine_region()].
1677    ///
1678    /// This function is distinct from [`set_child_shapes()`][Self::set_child_shapes()]
1679    /// because it includes `self`’s shape mask in the set of shapes to
1680    /// be merged.
1681    #[doc(alias = "gdk_window_merge_child_shapes")]
1682    pub fn merge_child_shapes(&self) {
1683        unsafe {
1684            ffi::gdk_window_merge_child_shapes(self.to_glib_none().0);
1685        }
1686    }
1687
1688    /// Repositions a window relative to its parent window.
1689    /// For toplevel windows, window managers may ignore or modify the move;
1690    /// you should probably use `gtk_window_move()` on a `GtkWindow` widget
1691    /// anyway, instead of using GDK functions. For child windows,
1692    /// the move will reliably succeed.
1693    ///
1694    /// If you’re also planning to resize the window, use [`move_resize()`][Self::move_resize()]
1695    /// to both move and resize simultaneously, for a nicer visual effect.
1696    /// ## `x`
1697    /// X coordinate relative to window’s parent
1698    /// ## `y`
1699    /// Y coordinate relative to window’s parent
1700    #[doc(alias = "gdk_window_move")]
1701    #[doc(alias = "move")]
1702    pub fn move_(&self, x: i32, y: i32) {
1703        unsafe {
1704            ffi::gdk_window_move(self.to_glib_none().0, x, y);
1705        }
1706    }
1707
1708    /// Move the part of `self` indicated by `region` by `dy` pixels in the Y
1709    /// direction and `dx` pixels in the X direction. The portions of `region`
1710    /// that not covered by the new position of `region` are invalidated.
1711    ///
1712    /// Child windows are not moved.
1713    /// ## `region`
1714    /// The [`cairo::Region`][crate::cairo::Region] to move
1715    /// ## `dx`
1716    /// Amount to move in the X direction
1717    /// ## `dy`
1718    /// Amount to move in the Y direction
1719    #[doc(alias = "gdk_window_move_region")]
1720    pub fn move_region(&self, region: &cairo::Region, dx: i32, dy: i32) {
1721        unsafe {
1722            ffi::gdk_window_move_region(self.to_glib_none().0, region.to_glib_none().0, dx, dy);
1723        }
1724    }
1725
1726    /// Equivalent to calling [`move_()`][Self::move_()] and [`resize()`][Self::resize()],
1727    /// except that both operations are performed at once, avoiding strange
1728    /// visual effects. (i.e. the user may be able to see the window first
1729    /// move, then resize, if you don’t use [`move_resize()`][Self::move_resize()].)
1730    /// ## `x`
1731    /// new X position relative to window’s parent
1732    /// ## `y`
1733    /// new Y position relative to window’s parent
1734    /// ## `width`
1735    /// new width
1736    /// ## `height`
1737    /// new height
1738    #[doc(alias = "gdk_window_move_resize")]
1739    pub fn move_resize(&self, x: i32, y: i32, width: i32, height: i32) {
1740        unsafe {
1741            ffi::gdk_window_move_resize(self.to_glib_none().0, x, y, width, height);
1742        }
1743    }
1744
1745    /// Moves `self` to `rect`, aligning their anchor points.
1746    ///
1747    /// `rect` is relative to the top-left corner of the window that `self` is
1748    /// transient for. `rect_anchor` and `window_anchor` determine anchor points on
1749    /// `rect` and `self` to pin together. `rect`'s anchor point can optionally be
1750    /// offset by `rect_anchor_dx` and `rect_anchor_dy`, which is equivalent to
1751    /// offsetting the position of `self`.
1752    ///
1753    /// `anchor_hints` determines how `self` will be moved if the anchor points cause
1754    /// it to move off-screen. For example, [`AnchorHints::FLIP_X`][crate::AnchorHints::FLIP_X] will replace
1755    /// [`Gravity::NorthWest`][crate::Gravity::NorthWest] with [`Gravity::NorthEast`][crate::Gravity::NorthEast] and vice versa if
1756    /// `self` extends beyond the left or right edges of the monitor.
1757    ///
1758    /// Connect to the [`moved-to-rect`][struct@crate::Window#moved-to-rect] signal to find out how it was
1759    /// actually positioned.
1760    /// ## `rect`
1761    /// the destination [`Rectangle`][crate::Rectangle] to align `self` with
1762    /// ## `rect_anchor`
1763    /// the point on `rect` to align with `self`'s anchor point
1764    /// ## `window_anchor`
1765    /// the point on `self` to align with `rect`'s anchor point
1766    /// ## `anchor_hints`
1767    /// positioning hints to use when limited on space
1768    /// ## `rect_anchor_dx`
1769    /// horizontal offset to shift `self`, i.e. `rect`'s anchor
1770    ///  point
1771    /// ## `rect_anchor_dy`
1772    /// vertical offset to shift `self`, i.e. `rect`'s anchor point
1773    #[cfg(feature = "v3_24")]
1774    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
1775    #[doc(alias = "gdk_window_move_to_rect")]
1776    pub fn move_to_rect(
1777        &self,
1778        rect: &Rectangle,
1779        rect_anchor: Gravity,
1780        window_anchor: Gravity,
1781        anchor_hints: AnchorHints,
1782        rect_anchor_dx: i32,
1783        rect_anchor_dy: i32,
1784    ) {
1785        unsafe {
1786            ffi::gdk_window_move_to_rect(
1787                self.to_glib_none().0,
1788                rect.to_glib_none().0,
1789                rect_anchor.into_glib(),
1790                window_anchor.into_glib(),
1791                anchor_hints.into_glib(),
1792                rect_anchor_dx,
1793                rect_anchor_dy,
1794            );
1795        }
1796    }
1797
1798    /// Like [`children()`][Self::children()], but does not copy the list of
1799    /// children, so the list does not need to be freed.
1800    ///
1801    /// # Returns
1802    ///
1803    ///
1804    ///  a reference to the list of child windows in `self`
1805    #[doc(alias = "gdk_window_peek_children")]
1806    pub fn peek_children(&self) -> Vec<Window> {
1807        unsafe {
1808            FromGlibPtrContainer::from_glib_none(ffi::gdk_window_peek_children(
1809                self.to_glib_none().0,
1810            ))
1811        }
1812    }
1813
1814    /// Raises `self` to the top of the Z-order (stacking order), so that
1815    /// other windows with the same parent window appear below `self`.
1816    /// This is true whether or not the windows are visible.
1817    ///
1818    /// If `self` is a toplevel, the window manager may choose to deny the
1819    /// request to move the window in the Z-order, [`raise()`][Self::raise()] only
1820    /// requests the restack, does not guarantee it.
1821    #[doc(alias = "gdk_window_raise")]
1822    pub fn raise(&self) {
1823        unsafe {
1824            ffi::gdk_window_raise(self.to_glib_none().0);
1825        }
1826    }
1827
1828    /// Registers a window as a potential drop destination.
1829    #[doc(alias = "gdk_window_register_dnd")]
1830    pub fn register_dnd(&self) {
1831        unsafe {
1832            ffi::gdk_window_register_dnd(self.to_glib_none().0);
1833        }
1834    }
1835
1836    //#[doc(alias = "gdk_window_remove_filter")]
1837    //pub fn remove_filter(&self, function: /*Unimplemented*/Fn(/*Unimplemented*/XEvent, &Event) -> /*Ignored*/FilterReturn, data: /*Unimplemented*/Option<Basic: Pointer>) {
1838    //    unsafe { TODO: call ffi:gdk_window_remove_filter() }
1839    //}
1840
1841    /// Reparents `self` into the given `new_parent`. The window being
1842    /// reparented will be unmapped as a side effect.
1843    /// ## `new_parent`
1844    /// new parent to move `self` into
1845    /// ## `x`
1846    /// X location inside the new parent
1847    /// ## `y`
1848    /// Y location inside the new parent
1849    #[doc(alias = "gdk_window_reparent")]
1850    pub fn reparent(&self, new_parent: &Window, x: i32, y: i32) {
1851        unsafe {
1852            ffi::gdk_window_reparent(self.to_glib_none().0, new_parent.to_glib_none().0, x, y);
1853        }
1854    }
1855
1856    /// Resizes `self`; for toplevel windows, asks the window manager to resize
1857    /// the window. The window manager may not allow the resize. When using GTK+,
1858    /// use `gtk_window_resize()` instead of this low-level GDK function.
1859    ///
1860    /// Windows may not be resized below 1x1.
1861    ///
1862    /// If you’re also planning to move the window, use [`move_resize()`][Self::move_resize()]
1863    /// to both move and resize simultaneously, for a nicer visual effect.
1864    /// ## `width`
1865    /// new width of the window
1866    /// ## `height`
1867    /// new height of the window
1868    #[doc(alias = "gdk_window_resize")]
1869    pub fn resize(&self, width: i32, height: i32) {
1870        unsafe {
1871            ffi::gdk_window_resize(self.to_glib_none().0, width, height);
1872        }
1873    }
1874
1875    /// Changes the position of `self` in the Z-order (stacking order), so that
1876    /// it is above `sibling` (if `above` is [`true`]) or below `sibling` (if `above` is
1877    /// [`false`]).
1878    ///
1879    /// If `sibling` is [`None`], then this either raises (if `above` is [`true`]) or
1880    /// lowers the window.
1881    ///
1882    /// If `self` is a toplevel, the window manager may choose to deny the
1883    /// request to move the window in the Z-order, [`restack()`][Self::restack()] only
1884    /// requests the restack, does not guarantee it.
1885    /// ## `sibling`
1886    /// a [`Window`][crate::Window] that is a sibling of `self`, or [`None`]
1887    /// ## `above`
1888    /// a boolean
1889    #[doc(alias = "gdk_window_restack")]
1890    pub fn restack(&self, sibling: Option<&Window>, above: bool) {
1891        unsafe {
1892            ffi::gdk_window_restack(
1893                self.to_glib_none().0,
1894                sibling.to_glib_none().0,
1895                above.into_glib(),
1896            );
1897        }
1898    }
1899
1900    /// Scroll the contents of `self`, both pixels and children, by the
1901    /// given amount. `self` itself does not move. Portions of the window
1902    /// that the scroll operation brings in from offscreen areas are
1903    /// invalidated. The invalidated region may be bigger than what would
1904    /// strictly be necessary.
1905    ///
1906    /// For X11, a minimum area will be invalidated if the window has no
1907    /// subwindows, or if the edges of the window’s parent do not extend
1908    /// beyond the edges of the window. In other cases, a multi-step process
1909    /// is used to scroll the window which may produce temporary visual
1910    /// artifacts and unnecessary invalidations.
1911    /// ## `dx`
1912    /// Amount to scroll in the X direction
1913    /// ## `dy`
1914    /// Amount to scroll in the Y direction
1915    #[doc(alias = "gdk_window_scroll")]
1916    pub fn scroll(&self, dx: i32, dy: i32) {
1917        unsafe {
1918            ffi::gdk_window_scroll(self.to_glib_none().0, dx, dy);
1919        }
1920    }
1921
1922    /// Setting `accept_focus` to [`false`] hints the desktop environment that the
1923    /// window doesn’t want to receive input focus.
1924    ///
1925    /// On X, it is the responsibility of the window manager to interpret this
1926    /// hint. ICCCM-compliant window manager usually respect it.
1927    /// ## `accept_focus`
1928    /// [`true`] if the window should receive input focus
1929    #[doc(alias = "gdk_window_set_accept_focus")]
1930    pub fn set_accept_focus(&self, accept_focus: bool) {
1931        unsafe {
1932            ffi::gdk_window_set_accept_focus(self.to_glib_none().0, accept_focus.into_glib());
1933        }
1934    }
1935
1936    /// Sets the input shape mask of `self` to the union of input shape masks
1937    /// for all children of `self`, ignoring the input shape mask of `self`
1938    /// itself. Contrast with [`merge_child_input_shapes()`][Self::merge_child_input_shapes()] which includes
1939    /// the input shape mask of `self` in the masks to be merged.
1940    #[doc(alias = "gdk_window_set_child_input_shapes")]
1941    pub fn set_child_input_shapes(&self) {
1942        unsafe {
1943            ffi::gdk_window_set_child_input_shapes(self.to_glib_none().0);
1944        }
1945    }
1946
1947    /// Sets the shape mask of `self` to the union of shape masks
1948    /// for all children of `self`, ignoring the shape mask of `self`
1949    /// itself. Contrast with [`merge_child_shapes()`][Self::merge_child_shapes()] which includes
1950    /// the shape mask of `self` in the masks to be merged.
1951    #[doc(alias = "gdk_window_set_child_shapes")]
1952    pub fn set_child_shapes(&self) {
1953        unsafe {
1954            ffi::gdk_window_set_child_shapes(self.to_glib_none().0);
1955        }
1956    }
1957
1958    /// Sets the default mouse pointer for a [`Window`][crate::Window].
1959    ///
1960    /// Note that `cursor` must be for the same display as `self`.
1961    ///
1962    /// Use [`Cursor::for_display()`][crate::Cursor::for_display()] or [`Cursor::from_pixbuf()`][crate::Cursor::from_pixbuf()] to
1963    /// create the cursor. To make the cursor invisible, use [`CursorType::BlankCursor`][crate::CursorType::BlankCursor].
1964    /// Passing [`None`] for the `cursor` argument to [`set_cursor()`][Self::set_cursor()] means
1965    /// that `self` will use the cursor of its parent window. Most windows
1966    /// should use this default.
1967    /// ## `cursor`
1968    /// a cursor
1969    #[doc(alias = "gdk_window_set_cursor")]
1970    #[doc(alias = "cursor")]
1971    pub fn set_cursor(&self, cursor: Option<&Cursor>) {
1972        unsafe {
1973            ffi::gdk_window_set_cursor(self.to_glib_none().0, cursor.to_glib_none().0);
1974        }
1975    }
1976
1977    /// “Decorations” are the features the window manager adds to a toplevel [`Window`][crate::Window].
1978    /// This function sets the traditional Motif window manager hints that tell the
1979    /// window manager which decorations you would like your window to have.
1980    /// Usually you should use `gtk_window_set_decorated()` on a `GtkWindow` instead of
1981    /// using the GDK function directly.
1982    ///
1983    /// The `decorations` argument is the logical OR of the fields in
1984    /// the [`WMDecoration`][crate::WMDecoration] enumeration. If [`WMDecoration::ALL`][crate::WMDecoration::ALL] is included in the
1985    /// mask, the other bits indicate which decorations should be turned off.
1986    /// If [`WMDecoration::ALL`][crate::WMDecoration::ALL] is not included, then the other bits indicate
1987    /// which decorations should be turned on.
1988    ///
1989    /// Most window managers honor a decorations hint of 0 to disable all decorations,
1990    /// but very few honor all possible combinations of bits.
1991    /// ## `decorations`
1992    /// decoration hint mask
1993    #[doc(alias = "gdk_window_set_decorations")]
1994    pub fn set_decorations(&self, decorations: WMDecoration) {
1995        unsafe {
1996            ffi::gdk_window_set_decorations(self.to_glib_none().0, decorations.into_glib());
1997        }
1998    }
1999
2000    /// Sets a specific [`Cursor`][crate::Cursor] for a given device when it gets inside `self`.
2001    /// Use [`Cursor::for_display()`][crate::Cursor::for_display()] or [`Cursor::from_pixbuf()`][crate::Cursor::from_pixbuf()] to create
2002    /// the cursor. To make the cursor invisible, use [`CursorType::BlankCursor`][crate::CursorType::BlankCursor]. Passing
2003    /// [`None`] for the `cursor` argument to [`set_cursor()`][Self::set_cursor()] means that
2004    /// `self` will use the cursor of its parent window. Most windows should
2005    /// use this default.
2006    /// ## `device`
2007    /// a master, pointer [`Device`][crate::Device]
2008    /// ## `cursor`
2009    /// a [`Cursor`][crate::Cursor]
2010    #[doc(alias = "gdk_window_set_device_cursor")]
2011    pub fn set_device_cursor(&self, device: &impl IsA<Device>, cursor: &Cursor) {
2012        unsafe {
2013            ffi::gdk_window_set_device_cursor(
2014                self.to_glib_none().0,
2015                device.as_ref().to_glib_none().0,
2016                cursor.to_glib_none().0,
2017            );
2018        }
2019    }
2020
2021    /// Sets the event mask for a given device (Normally a floating device, not
2022    /// attached to any visible pointer) to `self`. For example, an event mask
2023    /// including [`EventMask::BUTTON_PRESS_MASK`][crate::EventMask::BUTTON_PRESS_MASK] means the window should report button
2024    /// press events. The event mask is the bitwise OR of values from the
2025    /// [`EventMask`][crate::EventMask] enumeration.
2026    ///
2027    /// See the [input handling overview][event-masks] for details.
2028    /// ## `device`
2029    /// [`Device`][crate::Device] to enable events for.
2030    /// ## `event_mask`
2031    /// event mask for `self`
2032    #[doc(alias = "gdk_window_set_device_events")]
2033    pub fn set_device_events(&self, device: &impl IsA<Device>, event_mask: EventMask) {
2034        unsafe {
2035            ffi::gdk_window_set_device_events(
2036                self.to_glib_none().0,
2037                device.as_ref().to_glib_none().0,
2038                event_mask.into_glib(),
2039            );
2040        }
2041    }
2042
2043    /// Determines whether or not extra unprocessed motion events in
2044    /// the event queue can be discarded. If [`true`] only the most recent
2045    /// event will be delivered.
2046    ///
2047    /// Some types of applications, e.g. paint programs, need to see all
2048    /// motion events and will benefit from turning off event compression.
2049    ///
2050    /// By default, event compression is enabled.
2051    /// ## `event_compression`
2052    /// [`true`] if motion events should be compressed
2053    #[doc(alias = "gdk_window_set_event_compression")]
2054    pub fn set_event_compression(&self, event_compression: bool) {
2055        unsafe {
2056            ffi::gdk_window_set_event_compression(
2057                self.to_glib_none().0,
2058                event_compression.into_glib(),
2059            );
2060        }
2061    }
2062
2063    /// The event mask for a window determines which events will be reported
2064    /// for that window from all master input devices. For example, an event mask
2065    /// including [`EventMask::BUTTON_PRESS_MASK`][crate::EventMask::BUTTON_PRESS_MASK] means the window should report button
2066    /// press events. The event mask is the bitwise OR of values from the
2067    /// [`EventMask`][crate::EventMask] enumeration.
2068    ///
2069    /// See the [input handling overview][event-masks] for details.
2070    /// ## `event_mask`
2071    /// event mask for `self`
2072    #[doc(alias = "gdk_window_set_events")]
2073    pub fn set_events(&self, event_mask: EventMask) {
2074        unsafe {
2075            ffi::gdk_window_set_events(self.to_glib_none().0, event_mask.into_glib());
2076        }
2077    }
2078
2079    /// Setting `focus_on_map` to [`false`] hints the desktop environment that the
2080    /// window doesn’t want to receive input focus when it is mapped.
2081    /// focus_on_map should be turned off for windows that aren’t triggered
2082    /// interactively (such as popups from network activity).
2083    ///
2084    /// On X, it is the responsibility of the window manager to interpret
2085    /// this hint. Window managers following the freedesktop.org window
2086    /// manager extension specification should respect it.
2087    /// ## `focus_on_map`
2088    /// [`true`] if the window should receive input focus when mapped
2089    #[doc(alias = "gdk_window_set_focus_on_map")]
2090    pub fn set_focus_on_map(&self, focus_on_map: bool) {
2091        unsafe {
2092            ffi::gdk_window_set_focus_on_map(self.to_glib_none().0, focus_on_map.into_glib());
2093        }
2094    }
2095
2096    /// Specifies whether the `self` should span over all monitors (in a multi-head
2097    /// setup) or only the current monitor when in fullscreen mode.
2098    ///
2099    /// The `mode` argument is from the [`FullscreenMode`][crate::FullscreenMode] enumeration.
2100    /// If [`FullscreenMode::AllMonitors`][crate::FullscreenMode::AllMonitors] is specified, the fullscreen `self` will
2101    /// span over all monitors from the [`Screen`][crate::Screen].
2102    ///
2103    /// On X11, searches through the list of monitors from the [`Screen`][crate::Screen] the ones
2104    /// which delimit the 4 edges of the entire [`Screen`][crate::Screen] and will ask the window
2105    /// manager to span the `self` over these monitors.
2106    ///
2107    /// If the XINERAMA extension is not available or not usable, this function
2108    /// has no effect.
2109    ///
2110    /// Not all window managers support this, so you can’t rely on the fullscreen
2111    /// window to span over the multiple monitors when [`FullscreenMode::AllMonitors`][crate::FullscreenMode::AllMonitors]
2112    /// is specified.
2113    /// ## `mode`
2114    /// fullscreen mode
2115    #[doc(alias = "gdk_window_set_fullscreen_mode")]
2116    pub fn set_fullscreen_mode(&self, mode: FullscreenMode) {
2117        unsafe {
2118            ffi::gdk_window_set_fullscreen_mode(self.to_glib_none().0, mode.into_glib());
2119        }
2120    }
2121
2122    /// Sets hints about the window management functions to make available
2123    /// via buttons on the window frame.
2124    ///
2125    /// On the X backend, this function sets the traditional Motif window
2126    /// manager hint for this purpose. However, few window managers do
2127    /// anything reliable or interesting with this hint. Many ignore it
2128    /// entirely.
2129    ///
2130    /// The `functions` argument is the logical OR of values from the
2131    /// [`WMFunction`][crate::WMFunction] enumeration. If the bitmask includes [`WMFunction::ALL`][crate::WMFunction::ALL],
2132    /// then the other bits indicate which functions to disable; if
2133    /// it doesn’t include [`WMFunction::ALL`][crate::WMFunction::ALL], it indicates which functions to
2134    /// enable.
2135    /// ## `functions`
2136    /// bitmask of operations to allow on `self`
2137    #[doc(alias = "gdk_window_set_functions")]
2138    pub fn set_functions(&self, functions: WMFunction) {
2139        unsafe {
2140            ffi::gdk_window_set_functions(self.to_glib_none().0, functions.into_glib());
2141        }
2142    }
2143
2144    /// Sets the geometry hints for `self`. Hints flagged in `geom_mask`
2145    /// are set, hints not flagged in `geom_mask` are unset.
2146    /// To unset all hints, use a `geom_mask` of 0 and a `geometry` of [`None`].
2147    ///
2148    /// This function provides hints to the windowing system about
2149    /// acceptable sizes for a toplevel window. The purpose of
2150    /// this is to constrain user resizing, but the windowing system
2151    /// will typically (but is not required to) also constrain the
2152    /// current size of the window to the provided values and
2153    /// constrain programatic resizing via [`resize()`][Self::resize()] or
2154    /// [`move_resize()`][Self::move_resize()].
2155    ///
2156    /// Note that on X11, this effect has no effect on windows
2157    /// of type [`WindowType::Temp`][crate::WindowType::Temp] or windows where override redirect
2158    /// has been turned on via [`set_override_redirect()`][Self::set_override_redirect()]
2159    /// since these windows are not resizable by the user.
2160    ///
2161    /// Since you can’t count on the windowing system doing the
2162    /// constraints for programmatic resizes, you should generally
2163    /// call [`constrain_size()`][Self::constrain_size()] yourself to determine
2164    /// appropriate sizes.
2165    /// ## `geometry`
2166    /// geometry hints
2167    /// ## `geom_mask`
2168    /// bitmask indicating fields of `geometry` to pay attention to
2169    #[doc(alias = "gdk_window_set_geometry_hints")]
2170    pub fn set_geometry_hints(&self, geometry: &Geometry, geom_mask: WindowHints) {
2171        unsafe {
2172            ffi::gdk_window_set_geometry_hints(
2173                self.to_glib_none().0,
2174                geometry.to_glib_none().0,
2175                geom_mask.into_glib(),
2176            );
2177        }
2178    }
2179
2180    /// Sets the group leader window for `self`. By default,
2181    /// GDK sets the group leader for all toplevel windows
2182    /// to a global window implicitly created by GDK. With this function
2183    /// you can override this default.
2184    ///
2185    /// The group leader window allows the window manager to distinguish
2186    /// all windows that belong to a single application. It may for example
2187    /// allow users to minimize/unminimize all windows belonging to an
2188    /// application at once. You should only set a non-default group window
2189    /// if your application pretends to be multiple applications.
2190    /// ## `leader`
2191    /// group leader window, or [`None`] to restore the default group leader window
2192    #[doc(alias = "gdk_window_set_group")]
2193    pub fn set_group(&self, leader: Option<&Window>) {
2194        unsafe {
2195            ffi::gdk_window_set_group(self.to_glib_none().0, leader.to_glib_none().0);
2196        }
2197    }
2198
2199    /// Sets a list of icons for the window. One of these will be used
2200    /// to represent the window when it has been iconified. The icon is
2201    /// usually shown in an icon box or some sort of task bar. Which icon
2202    /// size is shown depends on the window manager. The window manager
2203    /// can scale the icon but setting several size icons can give better
2204    /// image quality since the window manager may only need to scale the
2205    /// icon by a small amount or not at all.
2206    ///
2207    /// Note that some platforms don't support window icons.
2208    /// ## `pixbufs`
2209    ///
2210    ///  A list of pixbufs, of different sizes.
2211    #[doc(alias = "gdk_window_set_icon_list")]
2212    pub fn set_icon_list(&self, pixbufs: &[gdk_pixbuf::Pixbuf]) {
2213        unsafe {
2214            ffi::gdk_window_set_icon_list(self.to_glib_none().0, pixbufs.to_glib_none().0);
2215        }
2216    }
2217
2218    /// Windows may have a name used while minimized, distinct from the
2219    /// name they display in their titlebar. Most of the time this is a bad
2220    /// idea from a user interface standpoint. But you can set such a name
2221    /// with this function, if you like.
2222    ///
2223    /// After calling this with a non-[`None`] `name`, calls to [`set_title()`][Self::set_title()]
2224    /// will not update the icon title.
2225    ///
2226    /// Using [`None`] for `name` unsets the icon title; further calls to
2227    /// [`set_title()`][Self::set_title()] will again update the icon title as well.
2228    ///
2229    /// Note that some platforms don't support window icons.
2230    /// ## `name`
2231    /// name of window while iconified (minimized)
2232    #[doc(alias = "gdk_window_set_icon_name")]
2233    pub fn set_icon_name(&self, name: Option<&str>) {
2234        unsafe {
2235            ffi::gdk_window_set_icon_name(self.to_glib_none().0, name.to_glib_none().0);
2236        }
2237    }
2238
2239    //#[doc(alias = "gdk_window_set_invalidate_handler")]
2240    //pub fn set_invalidate_handler<P: Fn(&Window) + 'static>(&self, handler: P) {
2241    //    unsafe { TODO: call ffi:gdk_window_set_invalidate_handler() }
2242    //}
2243
2244    /// Set if `self` must be kept above other windows. If the
2245    /// window was already above, then this function does nothing.
2246    ///
2247    /// On X11, asks the window manager to keep `self` above, if the window
2248    /// manager supports this operation. Not all window managers support
2249    /// this, and some deliberately ignore it or don’t have a concept of
2250    /// “keep above”; so you can’t rely on the window being kept above.
2251    /// But it will happen with most standard window managers,
2252    /// and GDK makes a best effort to get it to happen.
2253    /// ## `setting`
2254    /// whether to keep `self` above other windows
2255    #[doc(alias = "gdk_window_set_keep_above")]
2256    pub fn set_keep_above(&self, setting: bool) {
2257        unsafe {
2258            ffi::gdk_window_set_keep_above(self.to_glib_none().0, setting.into_glib());
2259        }
2260    }
2261
2262    /// Set if `self` must be kept below other windows. If the
2263    /// window was already below, then this function does nothing.
2264    ///
2265    /// On X11, asks the window manager to keep `self` below, if the window
2266    /// manager supports this operation. Not all window managers support
2267    /// this, and some deliberately ignore it or don’t have a concept of
2268    /// “keep below”; so you can’t rely on the window being kept below.
2269    /// But it will happen with most standard window managers,
2270    /// and GDK makes a best effort to get it to happen.
2271    /// ## `setting`
2272    /// whether to keep `self` below other windows
2273    #[doc(alias = "gdk_window_set_keep_below")]
2274    pub fn set_keep_below(&self, setting: bool) {
2275        unsafe {
2276            ffi::gdk_window_set_keep_below(self.to_glib_none().0, setting.into_glib());
2277        }
2278    }
2279
2280    /// The application can use this hint to tell the window manager
2281    /// that a certain window has modal behaviour. The window manager
2282    /// can use this information to handle modal windows in a special
2283    /// way.
2284    ///
2285    /// You should only use this on windows for which you have
2286    /// previously called [`set_transient_for()`][Self::set_transient_for()]
2287    /// ## `modal`
2288    /// [`true`] if the window is modal, [`false`] otherwise.
2289    #[doc(alias = "gdk_window_set_modal_hint")]
2290    pub fn set_modal_hint(&self, modal: bool) {
2291        unsafe {
2292            ffi::gdk_window_set_modal_hint(self.to_glib_none().0, modal.into_glib());
2293        }
2294    }
2295
2296    /// Set `self` to render as partially transparent,
2297    /// with opacity 0 being fully transparent and 1 fully opaque. (Values
2298    /// of the opacity parameter are clamped to the [0,1] range.)
2299    ///
2300    /// For toplevel windows this depends on support from the windowing system
2301    /// that may not always be there. For instance, On X11, this works only on
2302    /// X screens with a compositing manager running. On Wayland, there is no
2303    /// per-window opacity value that the compositor would apply. Instead, use
2304    /// `gdk_window_set_opaque_region (window, NULL)` to tell the compositor
2305    /// that the entire window is (potentially) non-opaque, and draw your content
2306    /// with alpha, or use `gtk_widget_set_opacity()` to set an overall opacity
2307    /// for your widgets.
2308    ///
2309    /// For child windows this function only works for non-native windows.
2310    ///
2311    /// For setting up per-pixel alpha topelevels, see [`Screen::rgba_visual()`][crate::Screen::rgba_visual()],
2312    /// and for non-toplevels, see `gdk_window_set_composited()`.
2313    ///
2314    /// Support for non-toplevel windows was added in 3.8.
2315    /// ## `opacity`
2316    /// opacity
2317    #[doc(alias = "gdk_window_set_opacity")]
2318    pub fn set_opacity(&self, opacity: f64) {
2319        unsafe {
2320            ffi::gdk_window_set_opacity(self.to_glib_none().0, opacity);
2321        }
2322    }
2323
2324    /// For optimisation purposes, compositing window managers may
2325    /// like to not draw obscured regions of windows, or turn off blending
2326    /// during for these regions. With RGB windows with no transparency,
2327    /// this is just the shape of the window, but with ARGB32 windows, the
2328    /// compositor does not know what regions of the window are transparent
2329    /// or not.
2330    ///
2331    /// This function only works for toplevel windows.
2332    ///
2333    /// GTK+ will update this property automatically if
2334    /// the `self` background is opaque, as we know where the opaque regions
2335    /// are. If your window background is not opaque, please update this
2336    /// property in your `GtkWidget::style-updated` handler.
2337    /// ## `region`
2338    /// a region, or [`None`]
2339    #[doc(alias = "gdk_window_set_opaque_region")]
2340    pub fn set_opaque_region(&self, region: Option<&cairo::Region>) {
2341        unsafe {
2342            ffi::gdk_window_set_opaque_region(
2343                self.to_glib_none().0,
2344                mut_override(region.to_glib_none().0),
2345            );
2346        }
2347    }
2348
2349    /// An override redirect window is not under the control of the window manager.
2350    /// This means it won’t have a titlebar, won’t be minimizable, etc. - it will
2351    /// be entirely under the control of the application. The window manager
2352    /// can’t see the override redirect window at all.
2353    ///
2354    /// Override redirect should only be used for short-lived temporary
2355    /// windows, such as popup menus. `GtkMenu` uses an override redirect
2356    /// window in its implementation, for example.
2357    /// ## `override_redirect`
2358    /// [`true`] if window should be override redirect
2359    #[doc(alias = "gdk_window_set_override_redirect")]
2360    pub fn set_override_redirect(&self, override_redirect: bool) {
2361        unsafe {
2362            ffi::gdk_window_set_override_redirect(
2363                self.to_glib_none().0,
2364                override_redirect.into_glib(),
2365            );
2366        }
2367    }
2368
2369    /// Sets whether input to the window is passed through to the window
2370    /// below.
2371    ///
2372    /// The default value of this is [`false`], which means that pointer
2373    /// events that happen inside the window are send first to the window,
2374    /// but if the event is not selected by the event mask then the event
2375    /// is sent to the parent window, and so on up the hierarchy.
2376    ///
2377    /// If `pass_through` is [`true`] then such pointer events happen as if the
2378    /// window wasn't there at all, and thus will be sent first to any
2379    /// windows below `self`. This is useful if the window is used in a
2380    /// transparent fashion. In the terminology of the web this would be called
2381    /// "pointer-events: none".
2382    ///
2383    /// Note that a window with `pass_through` [`true`] can still have a subwindow
2384    /// without pass through, so you can get events on a subset of a window. And in
2385    /// that cases you would get the in-between related events such as the pointer
2386    /// enter/leave events on its way to the destination window.
2387    /// ## `pass_through`
2388    /// a boolean
2389    #[doc(alias = "gdk_window_set_pass_through")]
2390    pub fn set_pass_through(&self, pass_through: bool) {
2391        unsafe {
2392            ffi::gdk_window_set_pass_through(self.to_glib_none().0, pass_through.into_glib());
2393        }
2394    }
2395
2396    /// When using GTK+, typically you should use `gtk_window_set_role()` instead
2397    /// of this low-level function.
2398    ///
2399    /// The window manager and session manager use a window’s role to
2400    /// distinguish it from other kinds of window in the same application.
2401    /// When an application is restarted after being saved in a previous
2402    /// session, all windows with the same title and role are treated as
2403    /// interchangeable. So if you have two windows with the same title
2404    /// that should be distinguished for session management purposes, you
2405    /// should set the role on those windows. It doesn’t matter what string
2406    /// you use for the role, as long as you have a different role for each
2407    /// non-interchangeable kind of window.
2408    /// ## `role`
2409    /// a string indicating its role
2410    #[doc(alias = "gdk_window_set_role")]
2411    pub fn set_role(&self, role: &str) {
2412        unsafe {
2413            ffi::gdk_window_set_role(self.to_glib_none().0, role.to_glib_none().0);
2414        }
2415    }
2416
2417    /// Newer GTK+ windows using client-side decorations use extra geometry
2418    /// around their frames for effects like shadows and invisible borders.
2419    /// Window managers that want to maximize windows or snap to edges need
2420    /// to know where the extents of the actual frame lie, so that users
2421    /// don’t feel like windows are snapping against random invisible edges.
2422    ///
2423    /// Note that this property is automatically updated by GTK+, so this
2424    /// function should only be used by applications which do not use GTK+
2425    /// to create toplevel windows.
2426    /// ## `left`
2427    /// The left extent
2428    /// ## `right`
2429    /// The right extent
2430    /// ## `top`
2431    /// The top extent
2432    /// ## `bottom`
2433    /// The bottom extent
2434    #[doc(alias = "gdk_window_set_shadow_width")]
2435    pub fn set_shadow_width(&self, left: i32, right: i32, top: i32, bottom: i32) {
2436        unsafe {
2437            ffi::gdk_window_set_shadow_width(self.to_glib_none().0, left, right, top, bottom);
2438        }
2439    }
2440
2441    /// Toggles whether a window should appear in a pager (workspace
2442    /// switcher, or other desktop utility program that displays a small
2443    /// thumbnail representation of the windows on the desktop). If a
2444    /// window’s semantic type as specified with [`set_type_hint()`][Self::set_type_hint()]
2445    /// already fully describes the window, this function should
2446    /// not be called in addition, instead you should
2447    /// allow the window to be treated according to standard policy for
2448    /// its semantic type.
2449    /// ## `skips_pager`
2450    /// [`true`] to skip the pager
2451    #[doc(alias = "gdk_window_set_skip_pager_hint")]
2452    pub fn set_skip_pager_hint(&self, skips_pager: bool) {
2453        unsafe {
2454            ffi::gdk_window_set_skip_pager_hint(self.to_glib_none().0, skips_pager.into_glib());
2455        }
2456    }
2457
2458    /// Toggles whether a window should appear in a task list or window
2459    /// list. If a window’s semantic type as specified with
2460    /// [`set_type_hint()`][Self::set_type_hint()] already fully describes the window, this
2461    /// function should not be called in addition,
2462    /// instead you should allow the window to be treated according to
2463    /// standard policy for its semantic type.
2464    /// ## `skips_taskbar`
2465    /// [`true`] to skip the taskbar
2466    #[doc(alias = "gdk_window_set_skip_taskbar_hint")]
2467    pub fn set_skip_taskbar_hint(&self, skips_taskbar: bool) {
2468        unsafe {
2469            ffi::gdk_window_set_skip_taskbar_hint(self.to_glib_none().0, skips_taskbar.into_glib());
2470        }
2471    }
2472
2473    /// Sets the event mask for any floating device (i.e. not attached to any
2474    /// visible pointer) that has the source defined as `source`. This event
2475    /// mask will be applied both to currently existing, newly added devices
2476    /// after this call, and devices being attached/detached.
2477    /// ## `source`
2478    /// a [`InputSource`][crate::InputSource] to define the source class.
2479    /// ## `event_mask`
2480    /// event mask for `self`
2481    #[doc(alias = "gdk_window_set_source_events")]
2482    pub fn set_source_events(&self, source: InputSource, event_mask: EventMask) {
2483        unsafe {
2484            ffi::gdk_window_set_source_events(
2485                self.to_glib_none().0,
2486                source.into_glib(),
2487                event_mask.into_glib(),
2488            );
2489        }
2490    }
2491
2492    /// When using GTK+, typically you should use `gtk_window_set_startup_id()`
2493    /// instead of this low-level function.
2494    /// ## `startup_id`
2495    /// a string with startup-notification identifier
2496    #[doc(alias = "gdk_window_set_startup_id")]
2497    pub fn set_startup_id(&self, startup_id: &str) {
2498        unsafe {
2499            ffi::gdk_window_set_startup_id(self.to_glib_none().0, startup_id.to_glib_none().0);
2500        }
2501    }
2502
2503    /// This function will enable multidevice features in `self`.
2504    ///
2505    /// Multidevice aware windows will need to handle properly multiple,
2506    /// per device enter/leave events, device grabs and grab ownerships.
2507    /// ## `support_multidevice`
2508    /// [`true`] to enable multidevice support in `self`.
2509    #[doc(alias = "gdk_window_set_support_multidevice")]
2510    pub fn set_support_multidevice(&self, support_multidevice: bool) {
2511        unsafe {
2512            ffi::gdk_window_set_support_multidevice(
2513                self.to_glib_none().0,
2514                support_multidevice.into_glib(),
2515            );
2516        }
2517    }
2518
2519    /// Sets the title of a toplevel window, to be displayed in the titlebar.
2520    /// If you haven’t explicitly set the icon name for the window
2521    /// (using [`set_icon_name()`][Self::set_icon_name()]), the icon name will be set to
2522    /// `title` as well. `title` must be in UTF-8 encoding (as with all
2523    /// user-readable strings in GDK/GTK+). `title` may not be [`None`].
2524    /// ## `title`
2525    /// title of `self`
2526    #[doc(alias = "gdk_window_set_title")]
2527    pub fn set_title(&self, title: &str) {
2528        unsafe {
2529            ffi::gdk_window_set_title(self.to_glib_none().0, title.to_glib_none().0);
2530        }
2531    }
2532
2533    /// Indicates to the window manager that `self` is a transient dialog
2534    /// associated with the application window `parent`. This allows the
2535    /// window manager to do things like center `self` on `parent` and
2536    /// keep `self` above `parent`.
2537    ///
2538    /// See `gtk_window_set_transient_for()` if you’re using `GtkWindow` or
2539    /// `GtkDialog`.
2540    /// ## `parent`
2541    /// another toplevel [`Window`][crate::Window]
2542    #[doc(alias = "gdk_window_set_transient_for")]
2543    pub fn set_transient_for(&self, parent: &Window) {
2544        unsafe {
2545            ffi::gdk_window_set_transient_for(self.to_glib_none().0, parent.to_glib_none().0);
2546        }
2547    }
2548
2549    /// The application can use this call to provide a hint to the window
2550    /// manager about the functionality of a window. The window manager
2551    /// can use this information when determining the decoration and behaviour
2552    /// of the window.
2553    ///
2554    /// The hint must be set before the window is mapped.
2555    /// ## `hint`
2556    /// A hint of the function this window will have
2557    #[doc(alias = "gdk_window_set_type_hint")]
2558    pub fn set_type_hint(&self, hint: WindowTypeHint) {
2559        unsafe {
2560            ffi::gdk_window_set_type_hint(self.to_glib_none().0, hint.into_glib());
2561        }
2562    }
2563
2564    /// Toggles whether a window needs the user's
2565    /// urgent attention.
2566    /// ## `urgent`
2567    /// [`true`] if the window is urgent
2568    #[doc(alias = "gdk_window_set_urgency_hint")]
2569    pub fn set_urgency_hint(&self, urgent: bool) {
2570        unsafe {
2571            ffi::gdk_window_set_urgency_hint(self.to_glib_none().0, urgent.into_glib());
2572        }
2573    }
2574
2575    /// Makes pixels in `self` outside `shape_region` be transparent,
2576    /// so that the window may be nonrectangular.
2577    ///
2578    /// If `shape_region` is [`None`], the shape will be unset, so the whole
2579    /// window will be opaque again. `offset_x` and `offset_y` are ignored
2580    /// if `shape_region` is [`None`].
2581    ///
2582    /// On the X11 platform, this uses an X server extension which is
2583    /// widely available on most common platforms, but not available on
2584    /// very old X servers, and occasionally the implementation will be
2585    /// buggy. On servers without the shape extension, this function
2586    /// will do nothing.
2587    ///
2588    /// This function works on both toplevel and child windows.
2589    /// ## `shape_region`
2590    /// region of window to be non-transparent
2591    /// ## `offset_x`
2592    /// X position of `shape_region` in `self` coordinates
2593    /// ## `offset_y`
2594    /// Y position of `shape_region` in `self` coordinates
2595    #[doc(alias = "gdk_window_shape_combine_region")]
2596    pub fn shape_combine_region(
2597        &self,
2598        shape_region: Option<&cairo::Region>,
2599        offset_x: i32,
2600        offset_y: i32,
2601    ) {
2602        unsafe {
2603            ffi::gdk_window_shape_combine_region(
2604                self.to_glib_none().0,
2605                shape_region.to_glib_none().0,
2606                offset_x,
2607                offset_y,
2608            );
2609        }
2610    }
2611
2612    /// Like [`show_unraised()`][Self::show_unraised()], but also raises the window to the
2613    /// top of the window stack (moves the window to the front of the
2614    /// Z-order).
2615    ///
2616    /// This function maps a window so it’s visible onscreen. Its opposite
2617    /// is [`hide()`][Self::hide()].
2618    ///
2619    /// When implementing a `GtkWidget`, you should call this function on the widget's
2620    /// [`Window`][crate::Window] as part of the “map” method.
2621    #[doc(alias = "gdk_window_show")]
2622    pub fn show(&self) {
2623        unsafe {
2624            ffi::gdk_window_show(self.to_glib_none().0);
2625        }
2626    }
2627
2628    /// Shows a [`Window`][crate::Window] onscreen, but does not modify its stacking
2629    /// order. In contrast, [`show()`][Self::show()] will raise the window
2630    /// to the top of the window stack.
2631    ///
2632    /// On the X11 platform, in Xlib terms, this function calls
2633    /// XMapWindow() (it also updates some internal GDK state, which means
2634    /// that you can’t really use XMapWindow() directly on a GDK window).
2635    #[doc(alias = "gdk_window_show_unraised")]
2636    pub fn show_unraised(&self) {
2637        unsafe {
2638            ffi::gdk_window_show_unraised(self.to_glib_none().0);
2639        }
2640    }
2641
2642    /// Asks the windowing system to show the window menu. The window menu
2643    /// is the menu shown when right-clicking the titlebar on traditional
2644    /// windows managed by the window manager. This is useful for windows
2645    /// using client-side decorations, activating it with a right-click
2646    /// on the window decorations.
2647    /// ## `event`
2648    /// a `GdkEvent` to show the menu for
2649    ///
2650    /// # Returns
2651    ///
2652    /// [`true`] if the window menu was shown and [`false`] otherwise.
2653    #[doc(alias = "gdk_window_show_window_menu")]
2654    pub fn show_window_menu(&self, event: &mut Event) -> bool {
2655        unsafe {
2656            from_glib(ffi::gdk_window_show_window_menu(
2657                self.to_glib_none().0,
2658                event.to_glib_none_mut().0,
2659            ))
2660        }
2661    }
2662
2663    /// “Pins” a window such that it’s on all workspaces and does not scroll
2664    /// with viewports, for window managers that have scrollable viewports.
2665    /// (When using `GtkWindow`, `gtk_window_stick()` may be more useful.)
2666    ///
2667    /// On the X11 platform, this function depends on window manager
2668    /// support, so may have no effect with many window managers. However,
2669    /// GDK will do the best it can to convince the window manager to stick
2670    /// the window. For window managers that don’t support this operation,
2671    /// there’s nothing you can do to force it to happen.
2672    #[doc(alias = "gdk_window_stick")]
2673    pub fn stick(&self) {
2674        unsafe {
2675            ffi::gdk_window_stick(self.to_glib_none().0);
2676        }
2677    }
2678
2679    /// Thaws a window frozen with [`freeze_updates()`][Self::freeze_updates()].
2680    #[doc(alias = "gdk_window_thaw_updates")]
2681    pub fn thaw_updates(&self) {
2682        unsafe {
2683            ffi::gdk_window_thaw_updates(self.to_glib_none().0);
2684        }
2685    }
2686
2687    /// Moves the window out of fullscreen mode. If the window was not
2688    /// fullscreen, does nothing.
2689    ///
2690    /// On X11, asks the window manager to move `self` out of the fullscreen
2691    /// state, if the window manager supports this operation. Not all
2692    /// window managers support this, and some deliberately ignore it or
2693    /// don’t have a concept of “fullscreen”; so you can’t rely on the
2694    /// unfullscreenification actually happening. But it will happen with
2695    /// most standard window managers, and GDK makes a best effort to get
2696    /// it to happen.
2697    #[doc(alias = "gdk_window_unfullscreen")]
2698    pub fn unfullscreen(&self) {
2699        unsafe {
2700            ffi::gdk_window_unfullscreen(self.to_glib_none().0);
2701        }
2702    }
2703
2704    /// Unmaximizes the window. If the window wasn’t maximized, then this
2705    /// function does nothing.
2706    ///
2707    /// On X11, asks the window manager to unmaximize `self`, if the
2708    /// window manager supports this operation. Not all window managers
2709    /// support this, and some deliberately ignore it or don’t have a
2710    /// concept of “maximized”; so you can’t rely on the unmaximization
2711    /// actually happening. But it will happen with most standard window
2712    /// managers, and GDK makes a best effort to get it to happen.
2713    ///
2714    /// On Windows, reliably unmaximizes the window.
2715    #[doc(alias = "gdk_window_unmaximize")]
2716    pub fn unmaximize(&self) {
2717        unsafe {
2718            ffi::gdk_window_unmaximize(self.to_glib_none().0);
2719        }
2720    }
2721
2722    /// Reverse operation for [`stick()`][Self::stick()]; see [`stick()`][Self::stick()],
2723    /// and `gtk_window_unstick()`.
2724    #[doc(alias = "gdk_window_unstick")]
2725    pub fn unstick(&self) {
2726        unsafe {
2727            ffi::gdk_window_unstick(self.to_glib_none().0);
2728        }
2729    }
2730
2731    /// Withdraws a window (unmaps it and asks the window manager to forget about it).
2732    /// This function is not really useful as [`hide()`][Self::hide()] automatically
2733    /// withdraws toplevel windows before hiding them.
2734    #[doc(alias = "gdk_window_withdraw")]
2735    pub fn withdraw(&self) {
2736        unsafe {
2737            ffi::gdk_window_withdraw(self.to_glib_none().0);
2738        }
2739    }
2740
2741    /// Constrains a desired width and height according to a
2742    /// set of geometry hints (such as minimum and maximum size).
2743    /// ## `geometry`
2744    /// a [`Geometry`][crate::Geometry] structure
2745    /// ## `flags`
2746    /// a mask indicating what portions of `geometry` are set
2747    /// ## `width`
2748    /// desired width of window
2749    /// ## `height`
2750    /// desired height of the window
2751    ///
2752    /// # Returns
2753    ///
2754    ///
2755    /// ## `new_width`
2756    /// location to store resulting width
2757    ///
2758    /// ## `new_height`
2759    /// location to store resulting height
2760    #[doc(alias = "gdk_window_constrain_size")]
2761    pub fn constrain_size(
2762        geometry: &mut Geometry,
2763        flags: WindowHints,
2764        width: i32,
2765        height: i32,
2766    ) -> (i32, i32) {
2767        assert_initialized_main_thread!();
2768        unsafe {
2769            let mut new_width = std::mem::MaybeUninit::uninit();
2770            let mut new_height = std::mem::MaybeUninit::uninit();
2771            ffi::gdk_window_constrain_size(
2772                geometry.to_glib_none_mut().0,
2773                flags.into_glib(),
2774                width,
2775                height,
2776                new_width.as_mut_ptr(),
2777                new_height.as_mut_ptr(),
2778            );
2779            (new_width.assume_init(), new_height.assume_init())
2780        }
2781    }
2782
2783    /// The ::create-surface signal is emitted when an offscreen window
2784    /// needs its surface (re)created, which happens either when the
2785    /// window is first drawn to, or when the window is being
2786    /// resized. The first signal handler that returns a non-[`None`]
2787    /// surface will stop any further signal emission, and its surface
2788    /// will be used.
2789    ///
2790    /// Note that it is not possible to access the window's previous
2791    /// surface from within any callback of this signal. Calling
2792    /// `gdk_offscreen_window_get_surface()` will lead to a crash.
2793    /// ## `width`
2794    /// the width of the offscreen surface to create
2795    /// ## `height`
2796    /// the height of the offscreen surface to create
2797    ///
2798    /// # Returns
2799    ///
2800    /// the newly created [`cairo::Surface`][crate::cairo::Surface] for the offscreen window
2801    #[doc(alias = "create-surface")]
2802    pub fn connect_create_surface<F: Fn(&Self, i32, i32) -> cairo::Surface + 'static>(
2803        &self,
2804        f: F,
2805    ) -> SignalHandlerId {
2806        unsafe extern "C" fn create_surface_trampoline<
2807            F: Fn(&Window, i32, i32) -> cairo::Surface + 'static,
2808        >(
2809            this: *mut ffi::GdkWindow,
2810            width: std::ffi::c_int,
2811            height: std::ffi::c_int,
2812            f: glib::ffi::gpointer,
2813        ) -> *mut cairo::ffi::cairo_surface_t {
2814            unsafe {
2815                let f: &F = &*(f as *const F);
2816                f(&from_glib_borrow(this), width, height).to_glib_full()
2817            }
2818        }
2819        unsafe {
2820            let f: Box_<F> = Box_::new(f);
2821            connect_raw(
2822                self.as_ptr() as *mut _,
2823                c"create-surface".as_ptr(),
2824                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2825                    create_surface_trampoline::<F> as *const (),
2826                )),
2827                Box_::into_raw(f),
2828            )
2829        }
2830    }
2831
2832    //#[doc(alias = "from-embedder")]
2833    //pub fn connect_from_embedder<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
2834    //    Out offscreen_x: *.Double
2835    //    Out offscreen_y: *.Double
2836    //}
2837
2838    //#[doc(alias = "moved-to-rect")]
2839    //pub fn connect_moved_to_rect<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
2840    //    Unimplemented flipped_rect: *.Pointer
2841    //    Unimplemented final_rect: *.Pointer
2842    //}
2843
2844    /// The ::pick-embedded-child signal is emitted to find an embedded
2845    /// child at the given position.
2846    /// ## `x`
2847    /// x coordinate in the window
2848    /// ## `y`
2849    /// y coordinate in the window
2850    ///
2851    /// # Returns
2852    ///
2853    /// the [`Window`][crate::Window] of the
2854    ///  embedded child at `x`, `y`, or [`None`]
2855    #[doc(alias = "pick-embedded-child")]
2856    pub fn connect_pick_embedded_child<F: Fn(&Self, f64, f64) -> Option<Window> + 'static>(
2857        &self,
2858        f: F,
2859    ) -> SignalHandlerId {
2860        unsafe extern "C" fn pick_embedded_child_trampoline<
2861            F: Fn(&Window, f64, f64) -> Option<Window> + 'static,
2862        >(
2863            this: *mut ffi::GdkWindow,
2864            x: std::ffi::c_double,
2865            y: std::ffi::c_double,
2866            f: glib::ffi::gpointer,
2867        ) -> *mut ffi::GdkWindow {
2868            unsafe {
2869                let f: &F = &*(f as *const F);
2870                f(&from_glib_borrow(this), x, y) /*Not checked*/
2871                    .to_glib_none()
2872                    .0
2873            }
2874        }
2875        unsafe {
2876            let f: Box_<F> = Box_::new(f);
2877            connect_raw(
2878                self.as_ptr() as *mut _,
2879                c"pick-embedded-child".as_ptr(),
2880                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2881                    pick_embedded_child_trampoline::<F> as *const (),
2882                )),
2883                Box_::into_raw(f),
2884            )
2885        }
2886    }
2887
2888    //#[doc(alias = "to-embedder")]
2889    //pub fn connect_to_embedder<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
2890    //    Out embedder_x: *.Double
2891    //    Out embedder_y: *.Double
2892    //}
2893
2894    #[doc(alias = "cursor")]
2895    pub fn connect_cursor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2896        unsafe extern "C" fn notify_cursor_trampoline<F: Fn(&Window) + 'static>(
2897            this: *mut ffi::GdkWindow,
2898            _param_spec: glib::ffi::gpointer,
2899            f: glib::ffi::gpointer,
2900        ) {
2901            unsafe {
2902                let f: &F = &*(f as *const F);
2903                f(&from_glib_borrow(this))
2904            }
2905        }
2906        unsafe {
2907            let f: Box_<F> = Box_::new(f);
2908            connect_raw(
2909                self.as_ptr() as *mut _,
2910                c"notify::cursor".as_ptr(),
2911                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2912                    notify_cursor_trampoline::<F> as *const (),
2913                )),
2914                Box_::into_raw(f),
2915            )
2916        }
2917    }
2918}