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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#include "platform/wayland/internal.h"
static struct yasl_display *impl_display_open(struct yasl_loop *loop, const struct yasl_display_spec *spec)
{
struct wayland_display *result = wayland_display_open(loop, spec);
return result ? &result->base : NULL;
}
static void impl_display_close(struct yasl_display *d)
{
wayland_display_close((struct wayland_display *)d);
}
static uint32_t impl_display_caps(const struct yasl_display *d)
{
return wayland_display_caps((const struct wayland_display *)d);
}
static int impl_display_dispatch_timeout(struct yasl_display *d, int timeout_ms)
{
return wayland_display_dispatch_timeout((struct wayland_display *)d, timeout_ms);
}
static void impl_display_flush(struct yasl_display *d)
{
wayland_display_flush((struct wayland_display *)d);
}
static int impl_display_modifiers(const struct yasl_display *d)
{
return wayland_display_modifiers((const struct wayland_display *)d);
}
static void impl_display_copy(struct yasl_display *d, enum yasl_selection sel, const char *text)
{
wayland_display_copy((struct wayland_display *)d, sel, text);
}
static void impl_display_paste(struct yasl_display *d, enum yasl_selection sel, struct yasl_surface *target)
{
wayland_display_paste((struct wayland_display *)d, sel, (struct wayland_surface *)target);
}
static bool impl_display_drag_start(struct yasl_display *d, struct yasl_surface *origin, const struct yasl_drag_image *image, const struct yasl_drag_listener *l, void *ud)
{
return wayland_display_drag_start((struct wayland_display *)d, (struct wayland_surface *)origin, image, l, ud);
}
static void impl_display_drag_cancel(struct yasl_display *d)
{
wayland_display_drag_cancel((struct wayland_display *)d);
}
static struct yasl_surface *impl_surface_create_toplevel(struct yasl_display *d,
const struct yasl_window_spec *spec, void *graphics_device)
{
struct wayland_surface *result = wayland_surface_create_toplevel((struct wayland_display *)d, spec, graphics_device);
return result ? &result->base : NULL;
}
static struct yasl_surface *impl_surface_create_popup(struct yasl_surface *parent, const struct yasl_popup_spec *spec)
{
struct wayland_surface *result = wayland_surface_create_popup((struct wayland_surface *)parent, spec);
return result ? &result->base : NULL;
}
static bool impl_surface_popup_reposition(struct yasl_surface *popup, const struct yasl_popup_spec *spec)
{
return wayland_surface_popup_reposition((struct wayland_surface *)popup, spec);
}
static void impl_surface_destroy(struct yasl_surface *s)
{
wayland_surface_destroy((struct wayland_surface *)s);
}
static struct yasl_display *impl_surface_display(const struct yasl_surface *s)
{
const struct wayland_surface *w = (const struct wayland_surface *)s;
struct wayland_display *result = w ? w->conn : NULL;
return result ? &result->base : NULL;
}
static void impl_surface_set_callbacks(struct yasl_surface *s, const struct yasl_window_cbs *cbs, void *ud)
{
wayland_surface_set_callbacks((struct wayland_surface *)s, cbs, ud);
}
static void impl_surface_set_title(struct yasl_surface *s, const char *title)
{
wayland_surface_set_title((struct wayland_surface *)s, title);
}
static void impl_surface_schedule_redraw(struct yasl_surface *s)
{
wayland_surface_schedule_redraw((struct wayland_surface *)s);
}
static bool impl_surface_present(struct yasl_surface *s, const struct yasl_framebuffer *fb, const struct yasl_damage_list *damage)
{
return wayland_surface_present((struct wayland_surface *)s, fb, damage);
}
static bool impl_surface_poll_event(struct yasl_surface *s, struct yasl_event *ev)
{
return wayland_surface_poll_event((struct wayland_surface *)s, ev);
}
static struct yasl_geometry impl_surface_geometry(const struct yasl_surface *s)
{
return wayland_surface_geometry((const struct wayland_surface *)s);
}
static struct yasl_timing impl_surface_timing(const struct yasl_surface *s)
{
return wayland_surface_timing((const struct wayland_surface *)s);
}
static uint64_t impl_surface_frame_time_ns(struct yasl_surface *s, uint64_t now)
{
return yasl_clock_frame_timestamp_ns(&((struct wayland_surface *)s)->clock, now);
}
static void impl_surface_set_cursor(struct yasl_surface *s, enum yasl_cursor cursor)
{
wayland_surface_set_cursor((struct wayland_surface *)s, cursor);
}
static bool impl_surface_set_pointer_mode(struct yasl_surface *s, enum yasl_pointer_mode mode)
{
return wayland_surface_set_pointer_mode((struct wayland_surface *)s, mode);
}
static void impl_surface_set_background_color(struct yasl_surface *s, uint32_t bg)
{
wayland_surface_set_background_color((struct wayland_surface *)s, bg);
}
static const char *impl_surface_ime_preedit(const struct yasl_surface *s)
{
const struct wayland_surface *w = (const struct wayland_surface *)s;
return w ? w->ime_shown : NULL;
}
static bool impl_surface_ime_preedit_cursor(const struct yasl_surface *s, int *begin, int *end)
{
return wayland_surface_ime_preedit_cursor((const struct wayland_surface *)s, begin, end);
}
static void impl_surface_set_ime_caret(struct yasl_surface *s, struct yasl_rect2i caret)
{
wayland_surface_set_ime_caret((struct wayland_surface *)s, caret);
}
static bool impl_surface_start_interactive_move(struct yasl_surface *s)
{
return wayland_surface_start_interactive_move((struct wayland_surface *)s);
}
static bool impl_surface_start_interactive_resize(struct yasl_surface *s, enum yasl_resize_edge edge)
{
return wayland_surface_start_interactive_resize((struct wayland_surface *)s, edge);
}
static bool impl_surface_show_window_menu(struct yasl_surface *s, struct yasl_vector2i pos)
{
return wayland_surface_show_window_menu((struct wayland_surface *)s, pos);
}
static bool impl_surface_drag_carry(struct yasl_surface *s, struct yasl_vector2i offset)
{
return wayland_surface_drag_carry((struct wayland_surface *)s, offset);
}
static bool impl_surface_place_under_pointer(struct yasl_surface *s, struct yasl_vector2i at)
{
return wayland_surface_place_under_pointer((struct wayland_surface *)s, at);
}
static void *impl_display_get_native_handle(struct yasl_display *d)
{
struct wayland_display *w = (struct wayland_display *)d;
return w ? w->wl : NULL;
}
static void *impl_surface_get_native_handle(struct yasl_surface *s)
{
struct wayland_surface *w = (struct wayland_surface *)s;
return w ? w->surface : NULL;
}
const struct yasl_backend_ops yasl_wayland_backend = {
.type = YASL_BACKEND_WAYLAND,
.display_open = impl_display_open,
.display_close = impl_display_close,
.display_caps = impl_display_caps,
.display_dispatch_timeout = impl_display_dispatch_timeout,
.display_flush = impl_display_flush,
.display_modifiers = impl_display_modifiers,
.display_copy = impl_display_copy,
.display_paste = impl_display_paste,
.display_drag_start = impl_display_drag_start,
.display_drag_cancel = impl_display_drag_cancel,
.surface_create_toplevel = impl_surface_create_toplevel,
.surface_create_popup = impl_surface_create_popup,
.surface_popup_reposition = impl_surface_popup_reposition,
.surface_destroy = impl_surface_destroy,
.surface_display = impl_surface_display,
.surface_set_callbacks = impl_surface_set_callbacks,
.surface_set_title = impl_surface_set_title,
.surface_schedule_redraw = impl_surface_schedule_redraw,
.surface_present = impl_surface_present,
.surface_poll_event = impl_surface_poll_event,
.surface_set_pointer_mode = impl_surface_set_pointer_mode,
.surface_geometry = impl_surface_geometry,
.surface_timing = impl_surface_timing,
.surface_frame_time_ns = impl_surface_frame_time_ns,
.surface_set_cursor = impl_surface_set_cursor,
.surface_set_background_color = impl_surface_set_background_color,
.surface_ime_preedit = impl_surface_ime_preedit,
.surface_ime_preedit_cursor = impl_surface_ime_preedit_cursor,
.surface_set_ime_caret = impl_surface_set_ime_caret,
.surface_start_interactive_move = impl_surface_start_interactive_move,
.surface_start_interactive_resize = impl_surface_start_interactive_resize,
.surface_show_window_menu = impl_surface_show_window_menu,
.surface_drag_carry = impl_surface_drag_carry,
.surface_place_under_pointer = impl_surface_place_under_pointer,
.display_get_native_handle = impl_display_get_native_handle,
.surface_get_native_handle = impl_surface_get_native_handle,
};
|