1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Take a look at the license at the top of the repository in the LICENSE file.

use gdk::Atom;
use glib::translate::*;

glib::wrapper! {
    #[doc(alias = "GdkWaylandWindow")]
    pub struct WaylandWindow(Object<ffi::GdkWaylandWindow>) @extends gdk::Window;

    match fn {
        type_ => || ffi::gdk_wayland_window_get_type(),
    }
}

impl WaylandWindow {
    #[doc(alias = "gdk_wayland_selection_add_targets")]
    pub fn selection_add_targets(&self, selection: &Atom, targets: &[Atom]) {
        unsafe {
            ffi::gdk_wayland_selection_add_targets(
                self.to_glib_none().0,
                selection.to_glib_none().0,
                targets.len() as _,
                targets.to_glib_none().0,
            )
        }
    }

    #[doc(alias = "gdk_wayland_window_set_use_custom_surface")]
    pub fn set_use_custom_surface(&self) {
        unsafe { ffi::gdk_wayland_window_set_use_custom_surface(self.to_glib_none().0) }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
    #[doc(alias = "gdk_wayland_window_unexport_handle")]
    pub fn unexport_handle(&self) {
        unsafe { ffi::gdk_wayland_window_unexport_handle(self.to_glib_none().0) }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
    #[doc(alias = "gdk_wayland_window_export_handle")]
    pub fn export_handle<P: Fn(&Self, &str) + 'static>(&self, callback: P) -> bool {
        unsafe extern "C" fn callback_trampoline<P: Fn(&WaylandWindow, &str) + 'static>(
            window: *mut ffi::GdkWaylandWindow,
            handle: *const libc::c_char,
            user_data: glib::ffi::gpointer,
        ) {
            let window = from_glib_borrow(window);
            let handle: Borrowed<glib::GString> = from_glib_borrow(handle);
            let callback: &P = &*(user_data as *mut _);
            (*callback)(&window, handle.as_str());
        }
        unsafe extern "C" fn destroy_notify<P: Fn(&WaylandWindow, &str) + 'static>(
            data: glib::ffi::gpointer,
        ) {
            Box::from_raw(data as *mut _);
        }
        unsafe {
            from_glib(ffi::gdk_wayland_window_export_handle(
                self.to_glib_none().0,
                Some(callback_trampoline::<P> as _),
                Box::into_raw(Box::new(callback)) as *mut _,
                Some(destroy_notify::<P> as _),
            ))
        }
    }

    #[doc(alias = "gdk_wayland_window_set_dbus_properties_libgtk_only")]
    pub fn set_dbus_properties_libgtk_only(
        &self,
        application_id: &str,
        app_menu_path: &str,
        menubar_path: &str,
        window_object_path: &str,
        application_object_path: &str,
        unique_bus_name: &str,
    ) {
        unsafe {
            ffi::gdk_wayland_window_set_dbus_properties_libgtk_only(
                self.to_glib_none().0,
                application_id.to_glib_none().0,
                app_menu_path.to_glib_none().0,
                menubar_path.to_glib_none().0,
                window_object_path.to_glib_none().0,
                application_object_path.to_glib_none().0,
                unique_bus_name.to_glib_none().0,
            )
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
    #[doc(alias = "gdk_wayland_window_set_transient_for_exported")]
    pub fn set_transient_for_exported(&self, parent_handle: &str) -> bool {
        unsafe {
            from_glib(ffi::gdk_wayland_window_set_transient_for_exported(
                self.to_glib_none().0,
                parent_handle.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v3_24_22", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24_22")))]
    #[doc(alias = "gdk_wayland_window_set_application_id")]
    pub fn set_application_id(&self, application_id: &str) -> bool {
        unsafe {
            from_glib(ffi::gdk_wayland_window_set_application_id(
                self.to_glib_none().0,
                application_id.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
    #[doc(alias = "gdk_wayland_window_announce_csd")]
    pub fn announce_csd(&self) {
        unsafe { ffi::gdk_wayland_window_announce_csd(self.to_glib_none().0) }
    }

    #[cfg(any(feature = "v3_24", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24")))]
    #[doc(alias = "gdk_wayland_window_announce_ssd")]
    pub fn announce_ssd(&self) {
        unsafe { ffi::gdk_wayland_window_announce_ssd(self.to_glib_none().0) }
    }
}