aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--wl/wayland-bind.c (renamed from wl/c.go)28
-rw-r--r--wl/wayland-bind.h3
-rw-r--r--wl/wl.go24
3 files changed, 29 insertions, 26 deletions
diff --git a/wl/c.go b/wl/wayland-bind.c
index b571e063..a177a378 100644
--- a/wl/c.go
+++ b/wl/wayland-bind.c
@@ -1,17 +1,7 @@
-package wl
-
-//go:generate sh -c "wayland-scanner client-header `pkg-config --variable=datarootdir wayland-protocols`/wayland-protocols/staging/security-context/security-context-v1.xml security-context-v1-protocol.h"
-//go:generate sh -c "wayland-scanner private-code `pkg-config --variable=datarootdir wayland-protocols`/wayland-protocols/staging/security-context/security-context-v1.xml security-context-v1-protocol.c"
-
-/*
-#cgo linux pkg-config: --static wayland-client
-#cgo freebsd openbsd LDFLAGS: -lwayland-client
-
-#include <stdint.h>
+#include "wayland-bind.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -33,7 +23,7 @@ static const struct wl_registry_listener registry_listener = {
.global_remove = registry_handle_global_remove,
};
-static int32_t bind_wayland_fd(char *socket_path, int fd, const char *app_id, const char *instance_id, int sync_fd) {
+int32_t bind_wayland_fd(char *socket_path, int fd, const char *app_id, const char *instance_id, int sync_fd) {
int32_t res = 0; // refer to resErr for meaning
struct wl_display *display;
@@ -96,17 +86,3 @@ out:
free((void *)instance_id);
return res;
}
-*/
-import "C"
-import "errors"
-
-var resErr = [...]error{
- 0: nil,
- 1: errors.New("wl_display_connect_to_fd() failed"),
- 2: errors.New("wp_security_context_v1 not available"),
-}
-
-func bindWaylandFd(socketPath string, fd uintptr, appID, instanceID string, syncFD uintptr) error {
- res := C.bind_wayland_fd(C.CString(socketPath), C.int(fd), C.CString(appID), C.CString(instanceID), C.int(syncFD))
- return resErr[int32(res)]
-}
diff --git a/wl/wayland-bind.h b/wl/wayland-bind.h
new file mode 100644
index 00000000..67898fc6
--- /dev/null
+++ b/wl/wayland-bind.h
@@ -0,0 +1,3 @@
+#include <stdint.h>
+
+int32_t bind_wayland_fd(char *socket_path, int fd, const char *app_id, const char *instance_id, int sync_fd); \ No newline at end of file
diff --git a/wl/wl.go b/wl/wl.go
new file mode 100644
index 00000000..2eb0e89f
--- /dev/null
+++ b/wl/wl.go
@@ -0,0 +1,24 @@
+package wl
+
+//go:generate sh -c "wayland-scanner client-header `pkg-config --variable=datarootdir wayland-protocols`/wayland-protocols/staging/security-context/security-context-v1.xml security-context-v1-protocol.h"
+//go:generate sh -c "wayland-scanner private-code `pkg-config --variable=datarootdir wayland-protocols`/wayland-protocols/staging/security-context/security-context-v1.xml security-context-v1-protocol.c"
+
+/*
+#cgo linux pkg-config: --static wayland-client
+#cgo freebsd openbsd LDFLAGS: -lwayland-client
+
+#include "wayland-bind.h"
+*/
+import "C"
+import "errors"
+
+var resErr = [...]error{
+ 0: nil,
+ 1: errors.New("wl_display_connect_to_fd() failed"),
+ 2: errors.New("wp_security_context_v1 not available"),
+}
+
+func bindWaylandFd(socketPath string, fd uintptr, appID, instanceID string, syncFD uintptr) error {
+ res := C.bind_wayland_fd(C.CString(socketPath), C.int(fd), C.CString(appID), C.CString(instanceID), C.int(syncFD))
+ return resErr[int32(res)]
+}