-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlibinput.c
More file actions
34 lines (30 loc) · 1.04 KB
/
libinput.c
File metadata and controls
34 lines (30 loc) · 1.04 KB
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
#include <libguile.h>
#include <libinput.h>
#include <stdio.h>
int open_restricted(const char *path, int flags, void *user_data) {
SCM proc = scm_car(user_data);
return scm_to_int(
scm_call_2(proc, scm_from_locale_string(path), scm_from_int(flags)));
};
void close_restricted(int fd, void *user_data) {
SCM proc = scm_cdr(user_data);
scm_call_1(proc, scm_from_int(fd));
};
const struct libinput_interface interface = {
.open_restricted = open_restricted, .close_restricted = close_restricted};
void libinput_finalizer(void *data) {
struct libinput *libinput = data;
SCM cons = libinput_get_user_data(libinput);
scm_gc_unprotect_object(cons);
libinput_unref(libinput);
}
SCM_DEFINE(g_libinput_path_create_context, "%libinput-path-create-context", 2,
0, 0, (SCM open, SCM close), "") {
SCM cons = scm_cons(open, close);
scm_gc_protect_object(cons);
return scm_from_pointer(libinput_path_create_context(&interface, cons),
libinput_finalizer);
}
void init_libinput() {
#include "libinput.x"
}