-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.c
292 lines (232 loc) · 7.1 KB
/
interface.c
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#include "_cgo_export.h"
#include <wlc/wlc.h>
/* output */
bool handle_output_created(wlc_handle output) {
return _goHandleOutputCreated(output);
}
void handle_output_destroyed(wlc_handle output) {
_goHandleOutputDestroyed(output);
}
void handle_output_focus(wlc_handle output, bool focus) {
_goHandleOutputFocus(output, focus);
}
void handle_output_resolution(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) {
struct wlc_size nc_from = {
.w = from->w,
.h = from->h
};
struct wlc_size nc_to = {
.w = to->w,
.h = to->h
};
_goHandleOutputResolution(output, &nc_from, &nc_to);
}
void handle_output_render_pre(wlc_handle output) {
_goHandleOutputRenderPre(output);
}
void handle_output_render_post(wlc_handle output) {
_goHandleOutputRenderPost(output);
}
void handle_output_context_created(wlc_handle output) {
_goHandleOutputContextCreated(output);
}
void handle_output_context_destroyed(wlc_handle output) {
_goHandleOutputContextDestroyed(output);
}
/* view */
bool handle_view_created(wlc_handle view) {
return _goHandleViewCreated(view);
}
void handle_view_destroyed(wlc_handle view) {
_goHandleViewDestroyed(view);
}
void handle_view_focus(wlc_handle view, bool focus) {
_goHandleViewFocus(view, focus);
}
void handle_view_move_to_output(wlc_handle view, wlc_handle from_output, wlc_handle to_output) {
_goHandleViewMoveToOutput(view, from_output, to_output);
}
void handle_view_request_geometry(wlc_handle view, const struct wlc_geometry *geometry) {
struct wlc_geometry nc_geometry = {
.origin = {
.x = geometry->origin.x,
.y = geometry->origin.y
},
.size = {
.w = geometry->size.w,
.h = geometry->size.h
}
};
_goHandleViewRequestGeometry(view, &nc_geometry);
}
void handle_view_request_state(wlc_handle view, enum wlc_view_state_bit bit, bool toggle) {
_goHandleViewRequestState(view, bit, toggle);
}
void handle_view_request_move(wlc_handle view, const struct wlc_point *point) {
struct wlc_point nc_point = {
.x = point->x,
.y = point->y
};
_goHandleViewRequestMove(view, &nc_point);
}
void handle_view_request_resize(wlc_handle view, uint32_t edges, const struct wlc_point *point) {
struct wlc_point nc_point = {
.x = point->x,
.y = point->y
};
_goHandleViewRequestResize(view, edges, &nc_point);
}
void handle_view_render_pre(wlc_handle view) {
_goHandleViewRenderPre(view);
}
void handle_view_render_post(wlc_handle view) {
_goHandleViewRenderPost(view);
}
void handle_view_properties_updated(wlc_handle view, uint32_t mask) {
_goHandleViewPropertiesUpdated(view, mask);
}
/* keyboard */
bool handle_keyboard_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint32_t key, enum wlc_key_state state) {
struct wlc_modifiers nc_modifiers = {
.leds = modifiers->leds,
.mods = modifiers->mods
};
return _goHandleKeyboardKey(view, time, &nc_modifiers, key, state);
}
/* pointer */
bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint32_t button, enum wlc_button_state state, const struct wlc_point *point) {
struct wlc_modifiers nc_modifiers = {
.leds = modifiers->leds,
.mods = modifiers->mods
};
struct wlc_point nc_point = {
.x = point->x,
.y = point->y
};
return _goHandlePointerButton(view, time, &nc_modifiers, button, state, &nc_point);
}
bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint8_t axis_bits, double amount[2]) {
struct wlc_modifiers nc_modifiers = {
.leds = modifiers->leds,
.mods = modifiers->mods
};
return _goHandlePointerScroll(view, time, &nc_modifiers, axis_bits, amount);
}
bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_point *point) {
struct wlc_point nc_point = {
.x = point->x,
.y = point->y
};
return _goHandlePointerMotion(view, time, &nc_point);
}
/* touch */
bool handle_touch_touch(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, enum wlc_touch_type touch, int32_t slot, const struct wlc_point *point) {
struct wlc_modifiers nc_modifiers = {
.leds = modifiers->leds,
.mods = modifiers->mods
};
struct wlc_point nc_point = {
.x = point->x,
.y = point->y
};
return _goHandleTouchTouch(view, time, &nc_modifiers, touch, slot, &nc_point);
}
/* compositor */
void handle_compositor_ready(void) {
_goHandleCompositorReady();
}
void handle_compositor_terminate(void) {
_goHandleCompositorTerminate();
}
/* input */
bool handle_input_created(struct libinput_device *device) {
return _goHandleInputCreated(device);
}
void handle_input_destroyed(struct libinput_device *device) {
_goHandleInputDestroyed(device);
}
/* Callback wrappers */
void set_output_created_cb() {
wlc_set_output_created_cb(handle_output_created);
}
void set_output_destroyed_cb() {
wlc_set_output_destroyed_cb(handle_output_destroyed);
}
void set_output_focus_cb() {
wlc_set_output_focus_cb(handle_output_focus);
}
void set_output_resolution_cb() {
wlc_set_output_resolution_cb(handle_output_resolution);
}
void set_output_render_pre_cb() {
wlc_set_output_render_pre_cb(handle_output_render_pre);
}
void set_output_render_post_cb() {
wlc_set_output_render_post_cb(handle_output_render_post);
}
void set_output_context_created_cb() {
wlc_set_output_context_created_cb(handle_output_context_created);
}
void set_output_context_destroyed_cb() {
wlc_set_output_context_destroyed_cb(handle_output_context_destroyed);
}
void set_view_created_cb() {
wlc_set_view_created_cb(handle_view_created);
}
void set_view_destroyed_cb() {
wlc_set_view_destroyed_cb(handle_view_destroyed);
}
void set_view_focus_cb() {
wlc_set_view_focus_cb(handle_view_focus);
}
void set_view_move_to_output_cb() {
wlc_set_view_move_to_output_cb(handle_view_move_to_output);
}
void set_view_request_geometry_cb() {
wlc_set_view_request_geometry_cb(handle_view_request_geometry);
}
void set_view_request_state_cb() {
wlc_set_view_request_state_cb(handle_view_request_state);
}
void set_view_request_move_cb() {
wlc_set_view_request_move_cb(handle_view_request_move);
}
void set_view_request_resize_cb() {
wlc_set_view_request_resize_cb(handle_view_request_resize);
}
void set_view_render_pre_cb() {
wlc_set_view_render_pre_cb(handle_view_render_pre);
}
void set_view_render_post_cb() {
wlc_set_view_render_post_cb(handle_view_render_post);
}
void set_view_properties_updated_cb() {
wlc_set_view_properties_updated_cb(handle_view_properties_updated);
}
void set_keyboard_key_cb() {
wlc_set_keyboard_key_cb(handle_keyboard_key);
}
void set_pointer_button_cb() {
wlc_set_pointer_button_cb(handle_pointer_button);
}
void set_pointer_scroll_cb() {
wlc_set_pointer_scroll_cb(handle_pointer_scroll);
}
void set_pointer_motion_cb() {
wlc_set_pointer_motion_cb(handle_pointer_motion);
}
void set_touch_cb() {
wlc_set_touch_cb(handle_touch_touch);
}
void set_compositor_ready_cb() {
wlc_set_compositor_ready_cb(handle_compositor_ready);
}
void set_compositor_terminate_cb() {
wlc_set_compositor_terminate_cb(handle_compositor_terminate);
}
void set_input_created_cb() {
wlc_set_input_created_cb(handle_input_created);
}
void set_input_destroyed_cb() {
wlc_set_input_destroyed_cb(handle_input_destroyed);
}