aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-11-24 23:30:30 +0100
committerFederico Angelilli <code@fedang.net>2024-11-24 23:30:30 +0100
commit2582279bc1046954702311c300294c5fd9f3ae0c (patch)
treecf2e1438c225f7cb66ace66b91098e788afdcb1b /src
parent7ed39aca6d07b8ca69c0373f5623ffd6a5564412 (diff)
Add more config options
Diffstat (limited to 'src')
-rw-r--r--src/comet.c12
-rw-r--r--src/config.c13
-rw-r--r--src/config.h8
-rw-r--r--src/window.c12
4 files changed, 27 insertions, 18 deletions
diff --git a/src/comet.c b/src/comet.c
index 21fae78..9ff848c 100644
--- a/src/comet.c
+++ b/src/comet.c
@@ -101,9 +101,6 @@ int main(int argc, char **argv)
window_t window;
window_init(&window, &display, &config);
- int x_padding = 10;
- int y_padding = 8;
-
log_debug("Loading font '%s'", config.font);
PangoFontDescription *fontdesc = pango_font_description_from_string(config.font);
@@ -123,12 +120,13 @@ int main(int argc, char **argv)
log_debug("Starting bar");
window_resize(&window, config.width, config.height);
- window_move(&window, x_padding, y_padding);
+ window_move(&window, config.x_offset, config.y_offset);
- // TODO: Allow ondemand rendering
- struct timespec rate, start, end, diff;
+ const double fps = 60.0;
+ const double freq = 1.0 / fps + 0.5e-9;
- double freq = 1.0 / 60.0 + 0.5e-9;
+ // TODO: Allow ondemand/lazy rendering
+ struct timespec rate, start, end, diff;
rate.tv_sec = (long)freq;
rate.tv_nsec = (freq - rate.tv_sec) * 1000000000ul;
diff --git a/src/config.c b/src/config.c
index 3bbce6d..c8b63b4 100644
--- a/src/config.c
+++ b/src/config.c
@@ -22,15 +22,19 @@ config_enum_t text_align_enum[] = {
};
const config_entry_t bar_entries[] = {
- { "width", CONFIG_UINT, NULL, offsetof(config_t, width) },
- { "height", CONFIG_UINT, NULL, offsetof(config_t, height) },
- { "font", CONFIG_STRING, NULL, offsetof(config_t, font) },
- { "monitor", CONFIG_STRING, NULL, offsetof(config_t, monitor) },
{ "override-redirect", CONFIG_BOOL, NULL, offsetof(config_t, override_redirect) },
{ "action-strict-run", CONFIG_BOOL, NULL, offsetof(config_t, action_strict_run) },
{ "action-strict-set", CONFIG_BOOL, NULL, offsetof(config_t, action_strict_set) },
{ "action-fail-fast", CONFIG_BOOL, NULL, offsetof(config_t, action_failfast) },
+ { "wm-name", CONFIG_STRING, NULL, offsetof(config_t, wm_name) },
+ { "wm-struts", CONFIG_BOOL, NULL, offsetof(config_t, wm_struts) },
{ "background", CONFIG_GRADIENT, NULL, offsetof(config_t, background) },
+ { "font", CONFIG_STRING, NULL, offsetof(config_t, font) },
+ { "monitor", CONFIG_STRING, NULL, offsetof(config_t, monitor) },
+ { "width", CONFIG_UINT, NULL, offsetof(config_t, width) },
+ { "height", CONFIG_UINT, NULL, offsetof(config_t, height) },
+ { "x-offset", CONFIG_UINT, NULL, offsetof(config_t, x_offset) },
+ { "y-offset", CONFIG_UINT, NULL, offsetof(config_t, y_offset) },
{ "scale", CONFIG_DOUBLE, NULL, offsetof(config_t, scale) },
{ 0 },
};
@@ -864,4 +868,5 @@ void config_free(config_t *config)
gradient_free(&config->background);
free(config->font);
free(config->monitor);
+ free(config->wm_name);
}
diff --git a/src/config.h b/src/config.h
index e4bc2d6..9a26615 100644
--- a/src/config.h
+++ b/src/config.h
@@ -41,15 +41,19 @@ typedef struct {
block_t **blocks;
size_t n_actions;
action_t *actions;
- char *font;
- char *monitor;
bool override_redirect;
bool action_strict_run;
bool action_strict_set;
bool action_failfast;
+ bool wm_struts;
+ char *wm_name;
gradient_t background;
+ char *font;
+ char *monitor;
unsigned int width;
unsigned int height;
+ unsigned int x_offset;
+ unsigned int y_offset;
double scale;
} config_t;
diff --git a/src/window.c b/src/window.c
index b71bc07..de22814 100644
--- a/src/window.c
+++ b/src/window.c
@@ -61,13 +61,13 @@ static void wm_set_struts(window_t *window)
log_trace("EWMH struts updated");
}
-static void wm_setup(window_t *window)
+static void wm_setup(window_t *window, const char *name, bool struts)
{
- const char *title = "comet";
+ const char *title = name != NULL ? name : "comet";
xcb_icccm_set_wm_name(window->display->connection, window->window, XCB_ATOM_STRING, 8, strlen(title), title);
const char class[] = "comet\0Comet";
- xcb_icccm_set_wm_class(window->display->connection, window->window, strlen(class), class);
+ xcb_icccm_set_wm_class(window->display->connection, window->window, sizeof(class), class);
log_value_debug("Updated window information",
"s:title", title,
@@ -85,7 +85,9 @@ static void wm_setup(window_t *window)
// TODO: These should be updated depdending on the situation!
wm_set_size(window);
- wm_set_struts(window);
+
+ if (struts)
+ wm_set_struts(window);
}
void window_init(window_t *window, display_t *display, config_t *config)
@@ -133,7 +135,7 @@ void window_init(window_t *window, display_t *display, config_t *config)
log_value_debug("Created window",
"u:id", window->window);
- wm_setup(window);
+ wm_setup(window, config->wm_name, config->wm_struts);
log_trace("Updated window WM options");
xcb_map_window(display->connection, window->window);