Skip to main content

gdk_wayland_sys/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3use gdk_sys as gdk;
4use glib_sys as glib;
5
6use gdk::{GdkAtom, GdkDevicePadFeature};
7use glib::{GType, gpointer};
8use libc::{c_char, c_int, c_uint};
9
10macro_rules! opaque {
11    ($(#[$attr:meta])*
12     $name:ident) => {
13        // https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
14        $(#[$attr])*
15        #[repr(C)]
16        pub struct $name {
17            _data: [u8; 0],
18            _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
19        }
20        $(#[$attr])*
21        impl ::std::fmt::Debug for $name {
22            fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
23                write!(f, "{} @ {:?}", stringify!($name), self as *const _)
24            }
25        }
26    };
27}
28
29opaque!(GdkWaylandDevice);
30opaque!(GdkWaylandDisplay);
31opaque!(GdkWaylandGLContext);
32opaque!(GdkWaylandMonitor);
33opaque!(GdkWaylandWindow);
34opaque!(GdkWaylandSeat);
35
36unsafe extern "C" {
37    //=========================================================================
38    // GdkWaylandWindow
39    //=========================================================================
40    pub fn gdk_wayland_window_get_type() -> GType;
41
42    pub fn gdk_wayland_window_get_wl_surface(window: *mut GdkWaylandWindow) -> gpointer;
43
44    pub fn gdk_wayland_window_set_use_custom_surface(window: *mut GdkWaylandWindow);
45
46    pub fn gdk_wayland_window_set_dbus_properties_libgtk_only(
47        window: *mut GdkWaylandWindow,
48        application_id: *const c_char,
49        app_menu_path: *const c_char,
50        menubar_path: *const c_char,
51        window_object_path: *const c_char,
52        application_object_path: *const c_char,
53        unique_bus_name: *const c_char,
54    );
55
56    pub fn gdk_wayland_selection_add_targets(
57        window: *mut GdkWaylandWindow,
58        selection: GdkAtom,
59        ntargets: c_uint,
60        targets: *mut GdkAtom,
61    );
62
63    pub fn gdk_wayland_window_unexport_handle(window: *mut GdkWaylandWindow);
64
65    pub fn gdk_wayland_window_export_handle(
66        window: *mut GdkWaylandWindow,
67        cb: Option<unsafe extern "C" fn(*mut GdkWaylandWindow, *const c_char, *mut libc::c_void)>,
68        user_data: *mut libc::c_void,
69        destroy_notify: Option<unsafe extern "C" fn(*mut libc::c_void)>,
70    ) -> glib::gboolean;
71
72    pub fn gdk_wayland_window_set_transient_for_exported(
73        window: *mut GdkWaylandWindow,
74        parent_handle: *const c_char,
75    ) -> glib::gboolean;
76
77    #[cfg(feature = "v3_24_22")]
78    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24_22")))]
79    pub fn gdk_wayland_window_set_application_id(
80        window: *mut GdkWaylandWindow,
81        application_id: *const c_char,
82    ) -> glib::gboolean;
83
84    pub fn gdk_wayland_window_announce_csd(window: *mut GdkWaylandWindow);
85
86    #[cfg(feature = "v3_24")]
87    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
88    pub fn gdk_wayland_window_announce_ssd(window: *mut GdkWaylandWindow);
89
90    #[cfg(feature = "v3_24")]
91    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
92    pub fn gdk_wayland_window_add_frame_callback_surface(
93        window: *mut GdkWaylandWindow,
94        surface: glib::gconstpointer,
95    );
96
97    #[cfg(feature = "v3_24")]
98    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
99    pub fn gdk_wayland_window_remove_frame_callback_surface(
100        window: *mut GdkWaylandWindow,
101        surface: glib::gconstpointer,
102    );
103
104    //=========================================================================
105    // GdkWaylandDevice
106    //=========================================================================
107    pub fn gdk_wayland_device_get_type() -> GType;
108
109    pub fn gdk_wayland_device_get_wl_seat(device: *mut GdkWaylandDevice) -> gpointer;
110
111    pub fn gdk_wayland_device_get_wl_pointer(device: *mut GdkWaylandDevice) -> gpointer;
112
113    pub fn gdk_wayland_device_get_wl_keyboard(device: *mut GdkWaylandDevice) -> gpointer;
114
115    pub fn gdk_wayland_device_get_node_path(device: *mut GdkWaylandDevice) -> *const c_char;
116
117    pub fn gdk_wayland_device_pad_set_feedback(
118        device: *mut GdkWaylandDevice,
119        element: GdkDevicePadFeature,
120        idx: c_uint,
121        label: *const c_char,
122    );
123
124    //=========================================================================
125    // GdkWaylandDisplay
126    //=========================================================================
127    pub fn gdk_wayland_display_get_type() -> GType;
128
129    pub fn gdk_wayland_display_set_cursor_theme(
130        display: *mut GdkWaylandDisplay,
131        theme: *const c_char,
132        size: c_int,
133    );
134
135    pub fn gdk_wayland_display_get_wl_display(display: *mut GdkWaylandDisplay) -> gpointer;
136
137    pub fn gdk_wayland_display_get_wl_compositor(display: *mut GdkWaylandDisplay) -> gpointer;
138
139    pub fn gdk_wayland_display_set_startup_notification_id(
140        display: *mut GdkWaylandDisplay,
141        startup_id: *const c_char,
142    );
143
144    pub fn gdk_wayland_display_prefers_ssd(display: *mut GdkWaylandDisplay) -> glib::gboolean;
145
146    pub fn gdk_wayland_display_query_registry(
147        display: *mut GdkWaylandDisplay,
148        global: *const c_char,
149    ) -> glib::gboolean;
150
151    //=========================================================================
152    // GdkWaylandGLContext
153    //=========================================================================
154    pub fn gdk_wayland_gl_context_get_type() -> GType;
155
156    //=========================================================================
157    // GdkWaylandSeat
158    //=========================================================================
159    pub fn gdk_wayland_seat_get_type() -> GType;
160
161    pub fn gdk_wayland_seat_get_wl_seat(seat: *mut GdkWaylandSeat) -> gpointer;
162
163    //=========================================================================
164    // GdkWaylandMonitor
165    //=========================================================================
166    pub fn gdk_wayland_monitor_get_type() -> GType;
167
168    pub fn gdk_wayland_monitor_get_wl_output(monitor: *mut GdkWaylandMonitor) -> gpointer;
169}