diff options
Diffstat (limited to 'src/comet.c')
| -rw-r--r-- | src/comet.c | 84 |
1 files changed, 27 insertions, 57 deletions
diff --git a/src/comet.c b/src/comet.c index eb401b9..7e3f12c 100644 --- a/src/comet.c +++ b/src/comet.c @@ -43,23 +43,29 @@ int main(int argc, char **argv) window_t window; window_init(&window, &display); - window_move(&window, 100, 100); - window_resize(&window, 1000, 1000); + int x_padding = 10; + int y_padding = 8; + + int height = 30; + int width = display.screen_size->width - 2 * x_padding; + + const char *font = "Hack 12"; + log_debug("Loading font '%s'", font); + + layout_info_t info = { + .fontdesc = pango_font_description_from_string(font), + .context = pango_cairo_create_context(window.cr), + .x_offset = 0, + .height = height, + .width = width, + }; + + window_resize(&window, width, height); + window_move(&window, x_padding, y_padding); block_t blocks[2] = { { - .hidden = false, .color = { 0.2, 0.2, 0.2, 1 }, - .line_color = { 0 }, - .line_width = 0, - .x_padding = 0, - .y_padding = 0, - .min_width = 0, - .max_width = 0, - .update_interval = 0, - .update_last = { 0 }, - .update_cb = NULL, - .event_cb = NULL, .type = BLOCK_TEXT, .text = { .text = "A", @@ -67,22 +73,12 @@ int main(int argc, char **argv) }, }, { - .hidden = false, - .color = { 0.2, 0.2, 0.8, 1 }, - .line_color = { 0 }, - .line_width = 0, - .x_padding = 0, - .y_padding = 0, - .min_width = 100, - .max_width = 100, - .update_interval = 0, - .update_last = { 0 }, - .update_cb = NULL, - .event_cb = NULL, + .color = { 0.2, 0.2, 0.2, 1 }, .type = BLOCK_TEXT, + .min_width = 100, .text = { .text = "B", - .text_color = { 0.8, 0.9, 0.2, 1 }, + .text_color = { 0.8, 0.9, 0.3, 1 }, }, }, }; @@ -90,16 +86,7 @@ int main(int argc, char **argv) block_t top = { .hidden = false, .color = { 0.3, 0.2, 0.5, 1 }, - .line_color = { 0 }, - .line_width = 0, - .x_padding = 0, - .y_padding = 0, .min_width = 1000, - .max_width = 0, - .update_interval = { 0 }, - .update_last = { 0 }, - .update_cb = NULL, - .event_cb = NULL, .type = BLOCK_GROUP, .group = { .spacing = 10, @@ -108,31 +95,16 @@ int main(int argc, char **argv) }, }; - int x_padding = 10; - int y_padding = 8; - - int height = 30; - int width = display.screen_size->width - 2 * x_padding; - - layout_info_t info = { - .fontdesc = pango_font_description_from_string("Hack 13"), - .context = pango_cairo_create_context(window.cr), - .x_offset = 0, - .height = height, - .width = width, - }; - - window_resize(&window, width, height); - window_move(&window, x_padding, y_padding); - + // TODO: Allow ondemand rendering double freq = 1.0 / 60.0 + 0.5e-9; struct timespec rate; rate.tv_sec = (long)freq; rate.tv_nsec = (freq - rate.tv_sec) * 1000000000ul; + struct timespec start, end, diff; + while (true) { - struct timespec start; timespec_get(&start, TIME_UTC); block_update(&top); @@ -147,11 +119,9 @@ int main(int argc, char **argv) cairo_surface_destroy(surface); layout_free(&layout); - struct timespec end; timespec_get(&end, TIME_UTC); - - struct timespec delta = timespec_diff(timespec_diff(end, start), rate); - nanosleep(&delta, NULL); + diff = timespec_diff(timespec_diff(end, start), rate); + nanosleep(&diff, NULL); } window_close(&window); |
