aboutsummaryrefslogtreecommitdiffstats
path: root/surfaces/screen.c
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-18 23:54:06 +0100
committereunhhu <[email protected]>2026-10-18 23:54:06 +0100
commita2ad1a7a9cd3e608f3fb4e5a694540a9cfef9c69 (patch)
treef40556ac45d36bb749ea64948f5e19659a882ee6 /surfaces/screen.c
parentda79f1e2b8d49dabe2290f5d795f8809c8b15c0f (diff)
downloadvega-a2ad1a7a9cd3e608f3fb4e5a694540a9cfef9c69.tar.gz
vega-a2ad1a7a9cd3e608f3fb4e5a694540a9cfef9c69.zip
Size to the module what is the module's (Pure 027's 4f-3a): timers grow to its inputs, the focus marks to its views, the accessibility tree's children to their count; a table shows its first VEGA_COLUMNS (64) columns, Vega's own countHEADmaster
Diffstat (limited to 'surfaces/screen.c')
-rw-r--r--surfaces/screen.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/surfaces/screen.c b/surfaces/screen.c
index eeaaa8d..9c5d3fa 100644
--- a/surfaces/screen.c
+++ b/surfaces/screen.c
@@ -3,6 +3,7 @@
#include "module-text.h"
#include <inttypes.h>
#include <math.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -19,14 +20,18 @@ double vega_clock(void) {
}
void vega_timers_start(VegaTimers *timers, const PureModule *m, double clock) {
- for (uint32_t i = 0; i < m->inputs; ++i)
+ if (timers->count < m->inputs) {
+ double *grown = realloc(timers->next, m->inputs * sizeof(*grown));
+ if (grown) timers->next = grown, timers->count = m->inputs; /* else its timers past count never tick */
+ }
+ for (uint32_t i = 0; i < m->inputs && i < timers->count; ++i)
timers->next[i] = m->input[i].binding == PURE_BIND_TIMER ? clock + m->input[i].period : 0;
}
long vega_timers_run(VegaTimers *timers, PureApp *app, double clock, bool *ticked) {
const PureModule *m = app->module;
double soonest = -1;
- for (uint32_t i = 0; i < m->inputs; ++i) {
+ for (uint32_t i = 0; i < m->inputs && i < timers->count; ++i) {
if (m->input[i].binding != PURE_BIND_TIMER) continue;
if (timers->next[i] <= clock) {
app->now = vega_now();
@@ -59,16 +64,16 @@ void vega_screen(VegaScreen *screen, const PureModule *m) {
if (m->input[i].binding == PURE_BIND_FRAME) screen->frame = (int)i;
}
/* A <table>_focus view belongs to its table, not to the fields. */
- bool focus_view[PURE_MODULE_VIEWS] = {false};
+ bool *focus_view = calloc(m->views + 1, sizeof(*focus_view)); /* (without room, none is) */
for (uint32_t i = 0; i < m->views; ++i) {
if (m->view_type[i] != PURE_VIEW_LIST || m->view_table[i]) continue;
char name[PURE_MODULE_NAME + 8];
snprintf(name, sizeof(name), "%s_focus", m->view_names[i]);
int focus = pure_module_view(m, name);
- if (focus >= 0 && m->view_type[focus] == PURE_VIEW_NUM) focus_view[focus] = true;
+ if (focus >= 0 && m->view_type[focus] == PURE_VIEW_NUM && focus_view) focus_view[focus] = true;
}
for (uint32_t i = 0; i < m->views && screen->count < VEGA_PARTS; ++i) {
- if (m->view_table[i] || (int)i == screen->title || focus_view[i]) continue;
+ if (m->view_table[i] || (int)i == screen->title || (focus_view && focus_view[i])) continue;
VegaPart *part = &screen->parts[screen->count++];
*part = (VegaPart){.kind = VEGA_FIELD, .view = i, .focus = -1, .pointer = -1, .label = -1, .tone = -1, .detail = -1,
.badge = -1};
@@ -76,7 +81,7 @@ void vega_screen(VegaScreen *screen, const PureModule *m) {
char name[PURE_MODULE_NAME + 8];
snprintf(name, sizeof(name), "%s_focus", m->view_names[i]);
part->focus = pure_module_view(m, name);
- if (part->focus >= 0 && !focus_view[part->focus]) part->focus = -1;
+ if (part->focus >= 0 && !(focus_view && focus_view[part->focus])) part->focus = -1;
for (uint32_t k = 0; part->focus >= 0 && k < m->inputs; ++k)
if (m->input[k].binding == PURE_BIND_POINT && m->input[k].view == i) part->pointer = (int)k;
part->label = column(m, i, "label", PURE_VIEW_TEXT);
@@ -87,8 +92,10 @@ void vega_screen(VegaScreen *screen, const PureModule *m) {
part->badge = column(m, i, "badge", PURE_VIEW_TEXT);
}
for (uint32_t k = 0; k < m->views; ++k)
- if (m->view_table[k] == i + 1 && (int)k != part->tone) part->columns[part->column_count++] = k;
+ if (m->view_table[k] == i + 1 && (int)k != part->tone && part->column_count < VEGA_COLUMNS)
+ part->columns[part->column_count++] = k;
}
+ free(focus_view);
}
static bool is_view(const PureModule *m, int view, uint8_t type) {