aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/wayland
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-16 20:57:29 +0900
committerOphestra <cat@gensokyo.uk>2025-11-16 20:57:29 +0900
commitb73a789dfe2b7361d9fce7d6755d14e44f6d9d57 (patch)
tree59e771315c64d90ff6c3f11d371b2fdbf7347ee1 /internal/wayland
parent38b5ff0cec266c7c5e423b68e8626f4a4a63d3ee (diff)
.clang-format: increase indent width
This significantly increases readability. This patch is pretty big so it is being done after mostly everything has settled. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/wayland')
-rw-r--r--internal/wayland/wayland-client-helper.c140
-rw-r--r--internal/wayland/wayland-client-helper.h46
2 files changed, 93 insertions, 93 deletions
diff --git a/internal/wayland/wayland-client-helper.c b/internal/wayland/wayland-client-helper.c
index 0fa0372e..25af847b 100644
--- a/internal/wayland/wayland-client-helper.c
+++ b/internal/wayland/wayland-client-helper.c
@@ -14,10 +14,10 @@ static void registry_handle_global(
uint32_t name,
const char *interface,
uint32_t version) {
- struct wp_security_context_manager_v1 **out = data;
+ struct wp_security_context_manager_v1 **out = data;
- if (strcmp(interface, wp_security_context_manager_v1_interface.name) == 0)
- *out = wl_registry_bind(registry, name, &wp_security_context_manager_v1_interface, 1);
+ if (strcmp(interface, wp_security_context_manager_v1_interface.name) == 0)
+ *out = wl_registry_bind(registry, name, &wp_security_context_manager_v1_interface, 1);
}
static void registry_handle_global_remove(
@@ -36,82 +36,82 @@ hakurei_wayland_res hakurei_security_context_bind(
const char *app_id,
const char *instance_id,
int close_fd) {
- hakurei_wayland_res res = HAKUREI_WAYLAND_SUCCESS; /* see wayland.go for handling */
+ hakurei_wayland_res res = HAKUREI_WAYLAND_SUCCESS; /* see wayland.go for handling */
- struct wl_display *display = NULL;
- struct wl_registry *registry;
- struct wp_security_context_manager_v1 *security_context_manager = NULL;
- int event_cnt;
- int listen_fd = -1;
- struct sockaddr_un sockaddr = {0};
- struct wp_security_context_v1 *security_context;
+ struct wl_display *display = NULL;
+ struct wl_registry *registry;
+ struct wp_security_context_manager_v1 *security_context_manager = NULL;
+ int event_cnt;
+ int listen_fd = -1;
+ struct sockaddr_un sockaddr = {0};
+ struct wp_security_context_v1 *security_context;
- display = wl_display_connect_to_fd(server_fd);
- if (display == NULL) {
- res = HAKUREI_WAYLAND_CONNECT;
- goto out;
- };
+ display = wl_display_connect_to_fd(server_fd);
+ if (display == NULL) {
+ res = HAKUREI_WAYLAND_CONNECT;
+ goto out;
+ };
- registry = wl_display_get_registry(display);
- if (wl_registry_add_listener(registry, &registry_listener, &security_context_manager) < 0) {
- res = HAKUREI_WAYLAND_LISTENER;
- goto out;
- }
- event_cnt = wl_display_roundtrip(display);
- wl_registry_destroy(registry);
- if (event_cnt < 0) {
- res = HAKUREI_WAYLAND_ROUNDTRIP;
- goto out;
- }
+ registry = wl_display_get_registry(display);
+ if (wl_registry_add_listener(registry, &registry_listener, &security_context_manager) < 0) {
+ res = HAKUREI_WAYLAND_LISTENER;
+ goto out;
+ }
+ event_cnt = wl_display_roundtrip(display);
+ wl_registry_destroy(registry);
+ if (event_cnt < 0) {
+ res = HAKUREI_WAYLAND_ROUNDTRIP;
+ goto out;
+ }
- if (security_context_manager == NULL) {
- res = HAKUREI_WAYLAND_NOT_AVAIL;
- goto out;
- }
+ if (security_context_manager == NULL) {
+ res = HAKUREI_WAYLAND_NOT_AVAIL;
+ goto out;
+ }
- listen_fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (listen_fd < 0) {
- res = HAKUREI_WAYLAND_SOCKET;
- goto out;
- }
+ listen_fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (listen_fd < 0) {
+ res = HAKUREI_WAYLAND_SOCKET;
+ goto out;
+ }
- sockaddr.sun_family = AF_UNIX;
- snprintf(sockaddr.sun_path, sizeof(sockaddr.sun_path), "%s", socket_path);
- if (bind(listen_fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) != 0) {
- res = HAKUREI_WAYLAND_BIND;
- goto out;
- }
+ sockaddr.sun_family = AF_UNIX;
+ snprintf(sockaddr.sun_path, sizeof(sockaddr.sun_path), "%s", socket_path);
+ if (bind(listen_fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) != 0) {
+ res = HAKUREI_WAYLAND_BIND;
+ goto out;
+ }
- if (listen(listen_fd, 0) != 0) {
- res = HAKUREI_WAYLAND_LISTEN;
- goto out;
- }
+ if (listen(listen_fd, 0) != 0) {
+ res = HAKUREI_WAYLAND_LISTEN;
+ goto out;
+ }
- security_context = wp_security_context_manager_v1_create_listener(security_context_manager, listen_fd, close_fd);
- if (security_context == NULL) { /* not reached */
- res = HAKUREI_WAYLAND_NOT_AVAIL;
- goto out;
- }
- wp_security_context_v1_set_sandbox_engine(security_context, "app.hakurei");
- wp_security_context_v1_set_app_id(security_context, app_id);
- wp_security_context_v1_set_instance_id(security_context, instance_id);
- wp_security_context_v1_commit(security_context);
- wp_security_context_v1_destroy(security_context);
- if (wl_display_roundtrip(display) < 0) {
- res = HAKUREI_WAYLAND_ROUNDTRIP;
- goto out;
- }
+ security_context = wp_security_context_manager_v1_create_listener(security_context_manager, listen_fd, close_fd);
+ if (security_context == NULL) { /* not reached */
+ res = HAKUREI_WAYLAND_NOT_AVAIL;
+ goto out;
+ }
+ wp_security_context_v1_set_sandbox_engine(security_context, "app.hakurei");
+ wp_security_context_v1_set_app_id(security_context, app_id);
+ wp_security_context_v1_set_instance_id(security_context, instance_id);
+ wp_security_context_v1_commit(security_context);
+ wp_security_context_v1_destroy(security_context);
+ if (wl_display_roundtrip(display) < 0) {
+ res = HAKUREI_WAYLAND_ROUNDTRIP;
+ goto out;
+ }
out:
- if (listen_fd >= 0)
- close(listen_fd);
- if (security_context_manager != NULL)
- wp_security_context_manager_v1_destroy(security_context_manager);
- if (display != NULL)
- wl_display_disconnect(display);
+ if (listen_fd >= 0)
+ close(listen_fd);
+ if (security_context_manager != NULL)
+ wp_security_context_manager_v1_destroy(security_context_manager);
+ if (display != NULL)
+ wl_display_disconnect(display);
- free((void *)socket_path);
- free((void *)app_id);
- free((void *)instance_id);
- return res;
+ free((void *)socket_path);
+ free((void *)app_id);
+ free((void *)instance_id);
+ return res;
}
diff --git a/internal/wayland/wayland-client-helper.h b/internal/wayland/wayland-client-helper.h
index 0a2cffb7..5f89ea7a 100644
--- a/internal/wayland/wayland-client-helper.h
+++ b/internal/wayland/wayland-client-helper.h
@@ -2,28 +2,28 @@
#include <sys/un.h>
typedef enum {
- HAKUREI_WAYLAND_SUCCESS,
- /* wl_display_connect_to_fd failed, errno */
- HAKUREI_WAYLAND_CONNECT,
- /* wl_registry_add_listener failed, errno */
- HAKUREI_WAYLAND_LISTENER,
- /* wl_display_roundtrip failed, errno */
- HAKUREI_WAYLAND_ROUNDTRIP,
- /* compositor does not implement wp_security_context_v1 */
- HAKUREI_WAYLAND_NOT_AVAIL,
- /* socket failed, errno */
- HAKUREI_WAYLAND_SOCKET,
- /* bind failed, errno */
- HAKUREI_WAYLAND_BIND,
- /* listen failed, errno */
- HAKUREI_WAYLAND_LISTEN,
+ HAKUREI_WAYLAND_SUCCESS,
+ /* wl_display_connect_to_fd failed, errno */
+ HAKUREI_WAYLAND_CONNECT,
+ /* wl_registry_add_listener failed, errno */
+ HAKUREI_WAYLAND_LISTENER,
+ /* wl_display_roundtrip failed, errno */
+ HAKUREI_WAYLAND_ROUNDTRIP,
+ /* compositor does not implement wp_security_context_v1 */
+ HAKUREI_WAYLAND_NOT_AVAIL,
+ /* socket failed, errno */
+ HAKUREI_WAYLAND_SOCKET,
+ /* bind failed, errno */
+ HAKUREI_WAYLAND_BIND,
+ /* listen failed, errno */
+ HAKUREI_WAYLAND_LISTEN,
- /* ensure pathname failed, implemented in conn.go */
- HAKUREI_WAYLAND_CREAT,
- /* socket for host server failed, implemented in conn.go */
- HAKUREI_WAYLAND_HOST_SOCKET,
- /* connect for host server failed, implemented in conn.go */
- HAKUREI_WAYLAND_HOST_CONNECT,
+ /* ensure pathname failed, implemented in conn.go */
+ HAKUREI_WAYLAND_CREAT,
+ /* socket for host server failed, implemented in conn.go */
+ HAKUREI_WAYLAND_HOST_SOCKET,
+ /* connect for host server failed, implemented in conn.go */
+ HAKUREI_WAYLAND_HOST_CONNECT,
} hakurei_wayland_res;
hakurei_wayland_res hakurei_security_context_bind(
@@ -35,6 +35,6 @@ hakurei_wayland_res hakurei_security_context_bind(
/* returns whether the specified size fits in the sun_path field of sockaddr_un */
static inline bool hakurei_is_valid_size_sun_path(size_t sz) {
- struct sockaddr_un sockaddr;
- return sz <= sizeof(sockaddr.sun_path);
+ struct sockaddr_un sockaddr;
+ return sz <= sizeof(sockaddr.sun_path);
};