diff options
author | kotontrion <[email protected]> | 2024-06-16 18:37:04 +0200 |
---|---|---|
committer | kotontrion <[email protected]> | 2024-06-16 18:37:04 +0200 |
commit | 36ce3262ac1f137866bf7f94a2ffea8c6c6fcee6 (patch) | |
tree | a842210653b6b64796daf41b488fb4b61a1cf351 /src/wayland-source.c | |
parent | 637875607f230ab7bd45d05db685323f568900f9 (diff) |
fix code style
Diffstat (limited to 'src/wayland-source.c')
-rw-r--r-- | src/wayland-source.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/src/wayland-source.c b/src/wayland-source.c index d984c2e..516fc0c 100644 --- a/src/wayland-source.c +++ b/src/wayland-source.c @@ -1,8 +1,9 @@ +#include "wayland-source.h" + #include <errno.h> #include <glib.h> #include <wayland-client.h> -#include "wayland-source.h" struct _WLSource { GSource source; @@ -11,8 +12,7 @@ struct _WLSource { int error; }; -static gboolean wl_source_prepare(GSource *source, - gint *timeout) { +static gboolean wl_source_prepare(GSource *source, gint *timeout) { WLSource *self = (WLSource *)source; *timeout = 0; @@ -29,25 +29,20 @@ static gboolean wl_source_prepare(GSource *source, static gboolean wl_source_check(GSource *source) { WLSource *self = (WLSource *)source; - if (self->error > 0) - return TRUE; + if (self->error > 0) return TRUE; GIOCondition revents; revents = g_source_query_unix_fd(source, self->fd); if (revents & G_IO_IN) { - if (wl_display_read_events(self->display) < 0) - self->error = errno; - } - else + if (wl_display_read_events(self->display) < 0) self->error = errno; + } else wl_display_cancel_read(self->display); return revents > 0; } -static gboolean wl_source_dispatch(GSource *source, - GSourceFunc callback, - gpointer user_data) { +static gboolean wl_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { WLSource *self = (WLSource *)source; GIOCondition revents; @@ -55,14 +50,12 @@ static gboolean wl_source_dispatch(GSource *source, if ((self->error > 0) || (revents & (G_IO_ERR | G_IO_HUP))) { errno = self->error; self->error = 0; - if ( callback != NULL ) - return callback(user_data); + if (callback != NULL) return callback(user_data); return G_SOURCE_REMOVE; } if (wl_display_dispatch_pending(self->display) < 0) { - if ( callback != NULL ) - return callback(user_data); + if (callback != NULL) return callback(user_data); return G_SOURCE_REMOVE; } @@ -75,27 +68,25 @@ static void wl_source_finalize(GSource *source) { } static GSourceFuncs wl_source_funcs = { - .prepare = wl_source_prepare, - .check = wl_source_check, + .prepare = wl_source_prepare, + .check = wl_source_check, .dispatch = wl_source_dispatch, .finalize = wl_source_finalize, }; -WLSource* wl_source_new() { +WLSource *wl_source_new() { struct wl_display *display; WLSource *self; GSource *source; display = wl_display_connect(NULL); - if (display == NULL) - return NULL; + if (display == NULL) return NULL; source = g_source_new(&wl_source_funcs, sizeof(WLSource)); self = (WLSource *)source; self->display = display; - self->fd = g_source_add_unix_fd(source, - wl_display_get_fd(self->display), + self->fd = g_source_add_unix_fd(source, wl_display_get_fd(self->display), G_IO_IN | G_IO_ERR | G_IO_HUP); g_source_attach(source, NULL); @@ -104,11 +95,9 @@ WLSource* wl_source_new() { } void wl_source_free(WLSource *self) { - GSource * source = (GSource *)self; + GSource *source = (GSource *)self; g_source_destroy(source); g_source_unref(source); } -struct wl_display* wl_source_get_display(WLSource *self) { - return self->display; -} +struct wl_display *wl_source_get_display(WLSource *self) { return self->display; } |