gdkwayland/
wayland_window.rs1use gdk::Atom;
4use glib::translate::*;
5
6glib::wrapper! {
7 #[doc(alias = "GdkWaylandWindow")]
8 pub struct WaylandWindow(Object<ffi::GdkWaylandWindow>) @extends gdk::Window;
9
10 match fn {
11 type_ => || ffi::gdk_wayland_window_get_type(),
12 }
13}
14
15impl WaylandWindow {
16 #[doc(alias = "gdk_wayland_selection_add_targets")]
17 pub fn selection_add_targets(&self, selection: &Atom, targets: &[Atom]) {
18 unsafe {
19 ffi::gdk_wayland_selection_add_targets(
20 self.to_glib_none().0,
21 selection.to_glib_none().0,
22 targets.len() as _,
23 targets.to_glib_none().0,
24 )
25 }
26 }
27
28 #[doc(alias = "gdk_wayland_window_set_use_custom_surface")]
29 pub fn set_use_custom_surface(&self) {
30 unsafe { ffi::gdk_wayland_window_set_use_custom_surface(self.to_glib_none().0) }
31 }
32
33 #[doc(alias = "gdk_wayland_window_unexport_handle")]
34 pub fn unexport_handle(&self) {
35 unsafe { ffi::gdk_wayland_window_unexport_handle(self.to_glib_none().0) }
36 }
37
38 #[doc(alias = "gdk_wayland_window_export_handle")]
39 pub fn export_handle<P: Fn(&Self, &str) + 'static>(&self, callback: P) -> bool {
40 unsafe extern "C" fn callback_trampoline<P: Fn(&WaylandWindow, &str) + 'static>(
41 window: *mut ffi::GdkWaylandWindow,
42 handle: *const libc::c_char,
43 user_data: glib::ffi::gpointer,
44 ) {
45 let window = from_glib_borrow(window);
46 let handle: Borrowed<glib::GString> = from_glib_borrow(handle);
47 let callback = &*(user_data as *mut P);
48 (*callback)(&window, handle.as_str());
49 }
50 unsafe extern "C" fn destroy_notify<P: Fn(&WaylandWindow, &str) + 'static>(
51 data: glib::ffi::gpointer,
52 ) {
53 let _ = Box::from_raw(data as *mut P);
54 }
55 unsafe {
56 from_glib(ffi::gdk_wayland_window_export_handle(
57 self.to_glib_none().0,
58 Some(callback_trampoline::<P> as _),
59 Box::into_raw(Box::new(callback)) as *mut _,
60 Some(destroy_notify::<P> as _),
61 ))
62 }
63 }
64
65 #[doc(alias = "gdk_wayland_window_set_dbus_properties_libgtk_only")]
66 pub fn set_dbus_properties_libgtk_only(
67 &self,
68 application_id: &str,
69 app_menu_path: &str,
70 menubar_path: &str,
71 window_object_path: &str,
72 application_object_path: &str,
73 unique_bus_name: &str,
74 ) {
75 unsafe {
76 ffi::gdk_wayland_window_set_dbus_properties_libgtk_only(
77 self.to_glib_none().0,
78 application_id.to_glib_none().0,
79 app_menu_path.to_glib_none().0,
80 menubar_path.to_glib_none().0,
81 window_object_path.to_glib_none().0,
82 application_object_path.to_glib_none().0,
83 unique_bus_name.to_glib_none().0,
84 )
85 }
86 }
87
88 #[doc(alias = "gdk_wayland_window_set_transient_for_exported")]
89 pub fn set_transient_for_exported(&self, parent_handle: &str) -> bool {
90 unsafe {
91 from_glib(ffi::gdk_wayland_window_set_transient_for_exported(
92 self.to_glib_none().0,
93 parent_handle.to_glib_none().0,
94 ))
95 }
96 }
97
98 #[cfg(feature = "v3_24_22")]
99 #[cfg_attr(docsrs, doc(cfg(feature = "v3_24_22")))]
100 #[doc(alias = "gdk_wayland_window_set_application_id")]
101 pub fn set_application_id(&self, application_id: &str) -> bool {
102 unsafe {
103 from_glib(ffi::gdk_wayland_window_set_application_id(
104 self.to_glib_none().0,
105 application_id.to_glib_none().0,
106 ))
107 }
108 }
109
110 #[doc(alias = "gdk_wayland_window_announce_csd")]
111 pub fn announce_csd(&self) {
112 unsafe { ffi::gdk_wayland_window_announce_csd(self.to_glib_none().0) }
113 }
114
115 #[cfg(feature = "v3_24")]
116 #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
117 #[doc(alias = "gdk_wayland_window_announce_ssd")]
118 pub fn announce_ssd(&self) {
119 unsafe { ffi::gdk_wayland_window_announce_ssd(self.to_glib_none().0) }
120 }
121}