gdk4/auto/drag_surface.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Surface, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// A surface that is used during DND.
10 ///
11 /// ## Signals
12 ///
13 ///
14 /// #### `compute-size`
15 /// Emitted when the size for the surface needs to be computed, when it is
16 /// present.
17 ///
18 /// This signal will normally be emitted during the native surface layout
19 /// cycle when the surface size needs to be recomputed.
20 ///
21 /// It is the responsibility of the drag surface user to handle this signal
22 /// and compute the desired size of the surface, storing the computed size
23 /// in the [`DragSurfaceSize`][crate::DragSurfaceSize] object that is passed to the signal
24 /// handler, using [`DragSurfaceSize::set_size()`][crate::DragSurfaceSize::set_size()].
25 ///
26 /// Failing to set a size so will result in an arbitrary size being used as
27 /// a result.
28 ///
29 ///
30 /// <details><summary><h4>Surface</h4></summary>
31 ///
32 ///
33 /// #### `enter-monitor`
34 /// Emitted when @surface starts being present on the monitor.
35 ///
36 ///
37 ///
38 ///
39 /// #### `event`
40 /// Emitted when GDK receives an input event for @surface.
41 ///
42 ///
43 ///
44 ///
45 /// #### `layout`
46 /// (see gdk_surface_get_scale_factor()).
47 ///
48 ///
49 ///
50 ///
51 /// #### `leave-monitor`
52 /// Emitted when @surface stops being present on the monitor.
53 ///
54 ///
55 ///
56 ///
57 /// #### `render`
58 /// Emitted when part of the surface needs to be redrawn.
59 ///
60 ///
61 /// </details>
62 ///
63 /// # Implements
64 ///
65 /// [`DragSurfaceExt`][trait@crate::prelude::DragSurfaceExt], [`SurfaceExt`][trait@crate::prelude::SurfaceExt], [`DragSurfaceExtManual`][trait@crate::prelude::DragSurfaceExtManual], [`SurfaceExtManual`][trait@crate::prelude::SurfaceExtManual]
66 #[doc(alias = "GdkDragSurface")]
67 pub struct DragSurface(Interface<ffi::GdkDragSurface, ffi::GdkDragSurfaceInterface>) @requires Surface;
68
69 match fn {
70 type_ => || ffi::gdk_drag_surface_get_type(),
71 }
72}
73
74impl DragSurface {
75 pub const NONE: Option<&'static DragSurface> = None;
76}
77
78/// Trait containing all [`struct@DragSurface`] methods.
79///
80/// # Implementors
81///
82/// [`DragSurface`][struct@crate::DragSurface]
83pub trait DragSurfaceExt: IsA<DragSurface> + 'static {
84 /// Present @self.
85 /// ## `width`
86 /// the unconstrained drag_surface width to layout
87 /// ## `height`
88 /// the unconstrained drag_surface height to layout
89 ///
90 /// # Returns
91 ///
92 /// [`false`] if it failed to be presented, otherwise [`true`].
93 #[doc(alias = "gdk_drag_surface_present")]
94 fn present(&self, width: i32, height: i32) -> bool {
95 unsafe {
96 from_glib(ffi::gdk_drag_surface_present(
97 self.as_ref().to_glib_none().0,
98 width,
99 height,
100 ))
101 }
102 }
103}
104
105impl<O: IsA<DragSurface>> DragSurfaceExt for O {}