summaryrefslogtreecommitdiff
path: root/src/common/app.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 13:44:13 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 13:44:13 +0300
commitc059e3aa7f93da470f052a5cd8ee0d8dc969e679 (patch)
tree63ffa378287ed2c606eda2e940501b9edc3d2b8b /src/common/app.c
parent87d0bc50d53dc216efb2b04495f090616318bc5c (diff)
rename and simplification
Diffstat (limited to 'src/common/app.c')
-rw-r--r--src/common/app.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/common/app.c b/src/common/app.c
index 1916c5b..da9747d 100644
--- a/src/common/app.c
+++ b/src/common/app.c
@@ -1,8 +1,9 @@
#include "yasl/app.h"
#include "common/app_internal.h"
#include "common/backend.h"
+#include "platform/sync.h"
-#include <pthread.h>
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -38,7 +39,7 @@ struct app_runner {
int surface_count;
struct app_surface *surfaces;
- pthread_mutex_t user_event_mutex;
+ yasl_mutex user_event_mutex;
struct user_event_node *user_event_head;
struct user_event_node *user_event_tail;
};
@@ -158,7 +159,7 @@ void app_runner_register_surface(void *runner, struct yasl_surface *s)
ar->surface_count++;
ar->had_surfaces = true;
- struct yasl_surface_cbs cbs = {
+ struct yasl_window_cbs cbs = {
.draw = app_runner_surface_draw,
.configure = app_runner_surface_configure,
.close = app_runner_surface_close,
@@ -264,7 +265,7 @@ bool yasl_post_event(struct yasl_display *d, struct yasl_surface *s,
node->size = size;
node->next = NULL;
- pthread_mutex_lock(&ar->user_event_mutex);
+ yasl_mutex_lock(&ar->user_event_mutex);
if (ar->user_event_tail) {
ar->user_event_tail->next = node;
ar->user_event_tail = node;
@@ -272,7 +273,7 @@ bool yasl_post_event(struct yasl_display *d, struct yasl_surface *s,
ar->user_event_head = node;
ar->user_event_tail = node;
}
- pthread_mutex_unlock(&ar->user_event_mutex);
+ yasl_mutex_unlock(&ar->user_event_mutex);
if (d->loop) {
yasl_loop_kick(d->loop);
@@ -312,11 +313,11 @@ void yasl_app_del_timer(struct yasl_display *d, yasl_timer_id id)
static void app_runner_dispatch_user_events(struct app_runner *ar)
{
- pthread_mutex_lock(&ar->user_event_mutex);
+ yasl_mutex_lock(&ar->user_event_mutex);
struct user_event_node *node = ar->user_event_head;
ar->user_event_head = NULL;
ar->user_event_tail = NULL;
- pthread_mutex_unlock(&ar->user_event_mutex);
+ yasl_mutex_unlock(&ar->user_event_mutex);
while (node && ar->running) {
struct user_event_node *next = node->next;
@@ -467,7 +468,12 @@ int yasl_run(const struct yasl_app_desc *desc)
.surface_count = 0,
.surfaces = NULL,
};
- pthread_mutex_init(&runner.user_event_mutex, NULL);
+ int sync_error = yasl_mutex_init(&runner.user_event_mutex);
+ if (sync_error) {
+ yasl_display_close(d);
+ errno = sync_error;
+ return -1;
+ }
d->app_runner = &runner;
if (desc->init(desc->userdata, d) == YASL_APP_QUIT) {
@@ -529,15 +535,15 @@ int yasl_run(const struct yasl_app_desc *desc)
d->app_runner = NULL;
- pthread_mutex_lock(&runner.user_event_mutex);
+ yasl_mutex_lock(&runner.user_event_mutex);
struct user_event_node *node = runner.user_event_head;
while (node) {
struct user_event_node *next = node->next;
free(node);
node = next;
}
- pthread_mutex_unlock(&runner.user_event_mutex);
- pthread_mutex_destroy(&runner.user_event_mutex);
+ yasl_mutex_unlock(&runner.user_event_mutex);
+ yasl_mutex_destroy(&runner.user_event_mutex);
yasl_display_close(d);
return 0;