comments
This commit is contained in:
parent
74c5f7a004
commit
f929180b05
2 changed files with 12 additions and 2 deletions
|
|
@ -40,6 +40,8 @@ void pgpl_gui_theme_configure(PGPL_GuiTheme *theme, PGPL_Color base_color,
|
||||||
theme->font = font;
|
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,
|
void pgpl_gui_widget_adjust_event_params(PGPL_GuiWidget *widget,
|
||||||
PGPL_GuiTheme *theme, double *x,
|
PGPL_GuiTheme *theme, double *x,
|
||||||
double *y, double *max_width,
|
double *y, double *max_width,
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,16 @@ static void *pgpl_window_event_loop(void *arg) {
|
||||||
pgpl_mutex_unlock(window_thread->action_lock);
|
pgpl_mutex_unlock(window_thread->action_lock);
|
||||||
|
|
||||||
timer = pgpl_timer_create();
|
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) {
|
while (running) {
|
||||||
PGPL_WindowEventData event_data;
|
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) {
|
while (running) {
|
||||||
PGPL_WindowEventType event_type =
|
PGPL_WindowEventType event_type =
|
||||||
pgpl_window_fetch_event(window_thread->window, &event_data);
|
pgpl_window_fetch_event(window_thread->window, &event_data);
|
||||||
|
|
@ -194,7 +201,6 @@ static void *pgpl_window_event_loop(void *arg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates all needed mutexes. */
|
|
||||||
PGPL_WindowThread *pgpl_window_thread_create(
|
PGPL_WindowThread *pgpl_window_thread_create(
|
||||||
const char *title, uint32_t width, uint32_t height, int32_t x, int32_t y,
|
const char *title, uint32_t width, uint32_t height, int32_t x, int32_t y,
|
||||||
bool (*event_loop)(PGPL_Window *window, PGPL_WindowEventType event,
|
bool (*event_loop)(PGPL_Window *window, PGPL_WindowEventType event,
|
||||||
|
|
@ -226,7 +232,9 @@ PGPL_WindowThread *pgpl_window_thread_create(
|
||||||
return args->window_thread;
|
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_window_thread_internal_send_message(PGPL_WindowThread *window_thread,
|
||||||
PGPL_WindowThreadAction action,
|
PGPL_WindowThreadAction action,
|
||||||
PGPL_WindowThreadActionData *data) {
|
PGPL_WindowThreadActionData *data) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue