From f929180b058eadf4ae99eda3b5cb4bf6d76c5393 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 8 Oct 2025 18:34:16 +0200 Subject: [PATCH] comments --- src/gui/helpers.c | 2 ++ src/window/thread.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/helpers.c b/src/gui/helpers.c index 5a0a021..53157c7 100644 --- a/src/gui/helpers.c +++ b/src/gui/helpers.c @@ -40,6 +40,8 @@ void pgpl_gui_theme_configure(PGPL_GuiTheme *theme, PGPL_Color base_color, theme->font = font; } +/* TODO: Not too happy with the fact that this code is mostly duplicate, might + * want to refactor this a bit. */ void pgpl_gui_widget_adjust_event_params(PGPL_GuiWidget *widget, PGPL_GuiTheme *theme, double *x, double *y, double *max_width, diff --git a/src/window/thread.c b/src/window/thread.c index fd26005..ace512b 100644 --- a/src/window/thread.c +++ b/src/window/thread.c @@ -82,9 +82,16 @@ static void *pgpl_window_event_loop(void *arg) { pgpl_mutex_unlock(window_thread->action_lock); timer = pgpl_timer_create(); + + /* Outer event loop, which sends render requests at a rate of 50 FPS, so long + * as the inner event loop isn't slowing things down. */ while (running) { PGPL_WindowEventData event_data; + /* Inner event loop, which fetches events from the window and responds to + * certain commands that are sent from outside of the event loop. Once no + * event is remaining, this loop is broken out of, and the thread sleeps + * until a frame is done. */ while (running) { PGPL_WindowEventType event_type = pgpl_window_fetch_event(window_thread->window, &event_data); @@ -194,7 +201,6 @@ static void *pgpl_window_event_loop(void *arg) { return NULL; } -/* Creates all needed mutexes. */ PGPL_WindowThread *pgpl_window_thread_create( const char *title, uint32_t width, uint32_t height, int32_t x, int32_t y, bool (*event_loop)(PGPL_Window *window, PGPL_WindowEventType event, @@ -226,7 +232,9 @@ PGPL_WindowThread *pgpl_window_thread_create( return args->window_thread; } -PGPL_WindowThreadActionData * +/* This is a helper function that helps send a message inside the event loop and + * returns the result once done. */ +static PGPL_WindowThreadActionData * pgpl_window_thread_internal_send_message(PGPL_WindowThread *window_thread, PGPL_WindowThreadAction action, PGPL_WindowThreadActionData *data) {