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