From 68ef49366f267bc9f93ba779639022a5e171d375 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Wed, 15 Nov 2023 17:55:37 +0100 Subject: Add pango for text rendering and move size calculations to main --- comet.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'comet.c') diff --git a/comet.c b/comet.c index 5cc7734..85bdb27 100644 --- a/comet.c +++ b/comet.c @@ -1,3 +1,4 @@ +#include #include #include @@ -5,6 +6,8 @@ #include "log.h" #include "draw.h" +#define EVEN(n) ((int)(n) - ((int)(n) % 2 != 0)) + static gboolean mainloop_quit(gpointer data) { g_main_loop_quit(data); @@ -25,6 +28,17 @@ int main(int argc, char **argv) Window *win = window_create(); + int screen_width, screen_height; + window_get_screen_size(win, &screen_width, &screen_height); + + int height = EVEN(round(screen_height * 0.021)); + int x_padding = EVEN(round(screen_width * 0.005)); + int y_padding = EVEN(round(screen_height * 0.004)); + + log_debug("Calculated dimensions [height=%d, x_pad=%d, y_pad=%d]", height, x_padding, y_padding); + + draw_init("Hack 12", height, x_padding, y_padding); + guint source_term = g_unix_signal_add(SIGTERM, mainloop_quit, mainloop); guint source_int = g_unix_signal_add(SIGINT, mainloop_quit, mainloop); -- cgit v1.2.3