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::{ffi, Surface};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A [`DragSurface`][crate::DragSurface] is an interface for surfaces 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    ///  Emitted when the size of @surface is changed, or when relayout should
47    /// be performed.
48    ///
49    /// Surface size is reported in ”application pixels”, not
50    /// ”device pixels” (see gdk_surface_get_scale_factor()).
51    ///
52    ///
53    ///
54    ///
55    /// #### `leave-monitor`
56    ///  Emitted when @surface stops being present on the monitor.
57    ///
58    ///
59    ///
60    ///
61    /// #### `render`
62    ///  Emitted when part of the surface needs to be redrawn.
63    ///
64    ///
65    /// </details>
66    ///
67    /// # Implements
68    ///
69    /// [`DragSurfaceExt`][trait@crate::prelude::DragSurfaceExt], [`SurfaceExt`][trait@crate::prelude::SurfaceExt], [`DragSurfaceExtManual`][trait@crate::prelude::DragSurfaceExtManual], [`SurfaceExtManual`][trait@crate::prelude::SurfaceExtManual]
70    #[doc(alias = "GdkDragSurface")]
71    pub struct DragSurface(Interface<ffi::GdkDragSurface, ffi::GdkDragSurfaceInterface>) @requires Surface;
72
73    match fn {
74        type_ => || ffi::gdk_drag_surface_get_type(),
75    }
76}
77
78impl DragSurface {
79    pub const NONE: Option<&'static DragSurface> = None;
80}
81
82mod sealed {
83    pub trait Sealed {}
84    impl<T: super::IsA<super::DragSurface>> Sealed for T {}
85}
86
87/// Trait containing all [`struct@DragSurface`] methods.
88///
89/// # Implementors
90///
91/// [`DragSurface`][struct@crate::DragSurface]
92pub trait DragSurfaceExt: IsA<DragSurface> + sealed::Sealed + 'static {
93    /// Present @self.
94    /// ## `width`
95    /// the unconstrained drag_surface width to layout
96    /// ## `height`
97    /// the unconstrained drag_surface height to layout
98    ///
99    /// # Returns
100    ///
101    /// [`false`] if it failed to be presented, otherwise [`true`].
102    #[doc(alias = "gdk_drag_surface_present")]
103    fn present(&self, width: i32, height: i32) -> bool {
104        unsafe {
105            from_glib(ffi::gdk_drag_surface_present(
106                self.as_ref().to_glib_none().0,
107                width,
108                height,
109            ))
110        }
111    }
112}
113
114impl<O: IsA<DragSurface>> DragSurfaceExt for O {}