libdecor_headers/
libdecor.rs

1use core::{
2    ffi::{c_char, c_int, c_void},
3    marker::{PhantomData, PhantomPinned},
4};
5
6use wayland_headers::{wayland_client::*, xdg_shell_client_protocol::*};
7
8#[repr(C)]
9pub struct libdecor {
10    _data: (),
11    _marker: PhantomData<(*mut u8, PhantomPinned)>,
12}
13
14#[repr(C)]
15pub struct libdecor_configuration {
16    _data: (),
17    _marker: PhantomData<(*mut u8, PhantomPinned)>,
18}
19
20#[repr(C)]
21pub struct libdecor_frame {
22    _data: (),
23    _marker: PhantomData<(*mut u8, PhantomPinned)>,
24}
25
26#[derive(Clone, Copy)]
27#[repr(C)]
28pub struct libdecor_frame_interface {
29    pub configure: Option<
30        unsafe extern "C" fn(
31            frame: *mut libdecor_frame,
32            configuration: *mut libdecor_configuration,
33            user_data: *mut c_void,
34        ),
35    >,
36
37    pub close: Option<unsafe extern "C" fn(frame: *mut libdecor_frame, user_data: *mut c_void)>,
38
39    pub commit: Option<unsafe extern "C" fn(frame: *mut libdecor_frame, user_data: *mut c_void)>,
40
41    pub dismiss_popup: Option<
42        unsafe extern "C" fn(
43            frame: *mut libdecor_frame,
44            seat_name: *const c_char,
45            user_data: *mut c_void,
46        ),
47    >,
48
49    pub reserved0: Option<unsafe extern "C" fn()>,
50    pub reserved1: Option<unsafe extern "C" fn()>,
51    pub reserved2: Option<unsafe extern "C" fn()>,
52    pub reserved3: Option<unsafe extern "C" fn()>,
53    pub reserved4: Option<unsafe extern "C" fn()>,
54    pub reserved5: Option<unsafe extern "C" fn()>,
55    pub reserved6: Option<unsafe extern "C" fn()>,
56    pub reserved7: Option<unsafe extern "C" fn()>,
57    pub reserved8: Option<unsafe extern "C" fn()>,
58    pub reserved9: Option<unsafe extern "C" fn()>,
59}
60
61#[derive(Clone, Copy)]
62#[repr(C)]
63pub struct libdecor_interface {
64    pub error: Option<
65        unsafe extern "C" fn(context: *mut libdecor, error: libdecor_error, message: *const c_char),
66    >,
67
68    pub reserved0: Option<unsafe extern "C" fn()>,
69    pub reserved1: Option<unsafe extern "C" fn()>,
70    pub reserved2: Option<unsafe extern "C" fn()>,
71    pub reserved3: Option<unsafe extern "C" fn()>,
72    pub reserved4: Option<unsafe extern "C" fn()>,
73    pub reserved5: Option<unsafe extern "C" fn()>,
74    pub reserved6: Option<unsafe extern "C" fn()>,
75    pub reserved7: Option<unsafe extern "C" fn()>,
76    pub reserved8: Option<unsafe extern "C" fn()>,
77    pub reserved9: Option<unsafe extern "C" fn()>,
78}
79
80#[repr(C)]
81pub struct libdecor_state {
82    _data: (),
83    _marker: PhantomData<(*mut u8, PhantomPinned)>,
84}
85
86pub const LIBDECOR_ACTION_CLOSE: libdecor_capabilities = 1 << 4;
87pub const LIBDECOR_ACTION_FULLSCREEN: libdecor_capabilities = 1 << 3;
88pub const LIBDECOR_ACTION_MINIMIZE: libdecor_capabilities = 1 << 2;
89pub const LIBDECOR_ACTION_MOVE: libdecor_capabilities = 1 << 0;
90pub const LIBDECOR_ACTION_RESIZE: libdecor_capabilities = 1 << 1;
91pub const LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE: libdecor_error = 0;
92pub const LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION: libdecor_error = 1;
93pub const LIBDECOR_RESIZE_EDGE_BOTTOM: libdecor_resize_edge = 2;
94pub const LIBDECOR_RESIZE_EDGE_BOTTOM_LEFT: libdecor_resize_edge = 5;
95pub const LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT: libdecor_resize_edge = 8;
96pub const LIBDECOR_RESIZE_EDGE_LEFT: libdecor_resize_edge = 3;
97pub const LIBDECOR_RESIZE_EDGE_NONE: libdecor_resize_edge = 0;
98pub const LIBDECOR_RESIZE_EDGE_RIGHT: libdecor_resize_edge = 6;
99pub const LIBDECOR_RESIZE_EDGE_TOP: libdecor_resize_edge = 1;
100pub const LIBDECOR_RESIZE_EDGE_TOP_LEFT: libdecor_resize_edge = 4;
101pub const LIBDECOR_RESIZE_EDGE_TOP_RIGHT: libdecor_resize_edge = 7;
102pub const LIBDECOR_WINDOW_STATE_ACTIVE: libdecor_window_state = 1 << 0;
103pub const LIBDECOR_WINDOW_STATE_FULLSCREEN: libdecor_window_state = 1 << 2;
104pub const LIBDECOR_WINDOW_STATE_MAXIMIZED: libdecor_window_state = 1 << 1;
105pub const LIBDECOR_WINDOW_STATE_NONE: libdecor_window_state = 0;
106pub const LIBDECOR_WINDOW_STATE_SUSPENDED: libdecor_window_state = 1 << 7;
107pub const LIBDECOR_WINDOW_STATE_TILED_BOTTOM: libdecor_window_state = 1 << 6;
108pub const LIBDECOR_WINDOW_STATE_TILED_LEFT: libdecor_window_state = 1 << 3;
109pub const LIBDECOR_WINDOW_STATE_TILED_RIGHT: libdecor_window_state = 1 << 4;
110pub const LIBDECOR_WINDOW_STATE_TILED_TOP: libdecor_window_state = 1 << 5;
111
112unsafe extern "C" {
113    pub fn libdecor_configuration_get_content_size(
114        configuration: *mut libdecor_configuration,
115        frame: *mut libdecor_frame,
116        width: *mut c_int,
117        height: *mut c_int,
118    ) -> bool;
119
120    pub fn libdecor_configuration_get_window_state(
121        configuration: *mut libdecor_configuration,
122        window_state: *mut libdecor_window_state,
123    ) -> bool;
124
125    pub fn libdecor_decorate(
126        context: *mut libdecor,
127        surface: *mut wl_surface,
128        iface: *mut libdecor_frame_interface,
129        user_data: *mut c_void,
130    ) -> *mut libdecor_frame;
131
132    pub fn libdecor_dispatch(context: *mut libdecor, timeout: c_int) -> c_int;
133
134    pub fn libdecor_frame_close(frame: *mut libdecor_frame);
135
136    pub fn libdecor_frame_commit(
137        frame: *mut libdecor_frame,
138        state: *mut libdecor_state,
139        configuration: *mut libdecor_configuration,
140    );
141
142    pub fn libdecor_frame_get_max_content_size(
143        frame: *const libdecor_frame,
144        content_width: *mut c_int,
145        content_height: *mut c_int,
146    );
147
148    pub fn libdecor_frame_get_min_content_size(
149        frame: *const libdecor_frame,
150        content_width: *mut c_int,
151        content_height: *mut c_int,
152    );
153
154    pub fn libdecor_frame_get_title(frame: *mut libdecor_frame) -> *const c_char;
155
156    pub fn libdecor_frame_get_xdg_surface(frame: *mut libdecor_frame) -> *mut xdg_surface;
157
158    pub fn libdecor_frame_get_xdg_toplevel(frame: *mut libdecor_frame) -> *mut xdg_toplevel;
159
160    pub fn libdecor_frame_has_capability(
161        frame: *mut libdecor_frame,
162        capability: libdecor_capabilities,
163    ) -> bool;
164
165    pub fn libdecor_frame_is_floating(frame: *mut libdecor_frame) -> bool;
166
167    pub fn libdecor_frame_is_visible(frame: *mut libdecor_frame) -> bool;
168
169    pub fn libdecor_frame_map(frame: *mut libdecor_frame);
170
171    pub fn libdecor_frame_move(frame: *mut libdecor_frame, wl_seat: *mut wl_seat, serial: u32);
172
173    pub fn libdecor_frame_popup_grab(frame: *mut libdecor_frame, seat_name: *const c_char);
174
175    pub fn libdecor_frame_popup_ungrab(frame: *mut libdecor_frame, seat_name: *const c_char);
176
177    pub fn libdecor_frame_ref(frame: *mut libdecor_frame);
178
179    pub fn libdecor_frame_resize(
180        frame: *mut libdecor_frame,
181        wl_seat: *mut wl_seat,
182        serial: u32,
183        edge: libdecor_resize_edge,
184    );
185
186    pub fn libdecor_frame_set_app_id(frame: *mut libdecor_frame, app_id: *const c_char);
187
188    pub fn libdecor_frame_set_capabilities(
189        frame: *mut libdecor_frame,
190        capabilities: libdecor_capabilities,
191    );
192
193    pub fn libdecor_frame_set_fullscreen(frame: *mut libdecor_frame, output: *mut wl_output);
194
195    pub fn libdecor_frame_set_max_content_size(
196        frame: *mut libdecor_frame,
197        content_width: c_int,
198        content_height: c_int,
199    );
200
201    pub fn libdecor_frame_set_maximized(frame: *mut libdecor_frame);
202
203    pub fn libdecor_frame_set_min_content_size(
204        frame: *mut libdecor_frame,
205        content_width: c_int,
206        content_height: c_int,
207    );
208
209    pub fn libdecor_frame_set_minimized(frame: *mut libdecor_frame);
210
211    pub fn libdecor_frame_set_parent(frame: *mut libdecor_frame, parent: *mut libdecor_frame);
212
213    pub fn libdecor_frame_set_title(frame: *mut libdecor_frame, title: *const c_char);
214
215    pub fn libdecor_frame_set_visibility(frame: *mut libdecor_frame, visible: bool);
216
217    pub fn libdecor_frame_show_window_menu(
218        frame: *mut libdecor_frame,
219        wl_seat: *mut wl_seat,
220        serial: u32,
221        x: c_int,
222        y: c_int,
223    );
224
225    pub fn libdecor_frame_translate_coordinate(
226        frame: *mut libdecor_frame,
227        surface_x: c_int,
228        surface_y: c_int,
229        frame_x: *mut c_int,
230        frame_y: *mut c_int,
231    );
232
233    pub fn libdecor_frame_unref(frame: *mut libdecor_frame);
234
235    pub fn libdecor_frame_unset_capabilities(
236        frame: *mut libdecor_frame,
237        capabilities: libdecor_capabilities,
238    );
239
240    pub fn libdecor_frame_unset_fullscreen(frame: *mut libdecor_frame);
241
242    pub fn libdecor_frame_unset_maximized(frame: *mut libdecor_frame);
243
244    pub fn libdecor_get_fd(context: *mut libdecor) -> c_int;
245
246    pub fn libdecor_new(display: *mut wl_display, iface: *mut libdecor_interface) -> *mut libdecor;
247
248    pub fn libdecor_state_free(state: *mut libdecor_state);
249
250    pub fn libdecor_state_new(width: c_int, height: c_int) -> *mut libdecor_state;
251
252    pub fn libdecor_unref(context: *mut libdecor);
253}
254
255pub type libdecor_capabilities = c_int;
256pub type libdecor_error = c_int;
257pub type libdecor_resize_edge = c_int;
258pub type libdecor_window_state = c_int;