aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bardata.c6
-rw-r--r--src/tsar.c28
2 files changed, 29 insertions, 5 deletions
diff --git a/src/bardata.c b/src/bardata.c
index 493e9b1..507d8f9 100644
--- a/src/bardata.c
+++ b/src/bardata.c
@@ -103,4 +103,10 @@ void set_config(char argv[MAX_ARGS][MAX_ARG_LEN], int argc) {
// fontsize = atoi(argv[2]);
load_font(argv[2]);
}
+ if (strcmp(var, "background") == 0) {
+
+ }
+ if (strcmp(var, "foreground") == 0) {
+
+ }
}
diff --git a/src/tsar.c b/src/tsar.c
index da21ad3..2d9d041 100644
--- a/src/tsar.c
+++ b/src/tsar.c
@@ -19,7 +19,7 @@ GC gc;
XftFont* font = NULL;
XftColor fg_color;
-static int width = 1000;
+static int bar_width = 1000;
static float width_ratio = 1;
static int err_code = 1;
@@ -61,13 +61,13 @@ void init_x(void) {
};
Screen* screen = DefaultScreenOfDisplay(display);
- width = WidthOfScreen(screen);
+ bar_width = WidthOfScreen(screen);
win = XCreateWindow(
display,
DefaultRootWindow(display),
0, 0,
- width, bar_height,
+ bar_width, bar_height,
0,
CopyFromParent,
InputOutput,
@@ -120,6 +120,22 @@ void draw_text(const char* text, int x, int y) {
XftDrawDestroy(xft_draw);
}
+void draw_comp_set(float pos_ratio, comp_t **set, int size) {
+ int width = 0;
+ for (int i = 0; i < size; i++) {
+ comp_t *comp = set[i];
+ width += font->max_advance_width * strlen(comp->data);
+ }
+
+ int x = (bar_width - width) * pos_ratio;
+ for (int i = 0; i < size; i++) {
+ comp_t *comp = set[i];
+
+ draw_text(comp->data, x, 0);
+ x += font->max_advance_width * strlen(comp->data);
+ }
+}
+
int main(void) {
init_pipe();
init_x();
@@ -130,8 +146,7 @@ int main(void) {
XNextEvent(display, &ev);
XClearWindow(display, win);
-
- XResizeWindow(display, win, width, bar_height);
+ XResizeWindow(display, win, bar_width, bar_height);
int x = 0;
for (int i = 0; i < left_size; i++) {
@@ -139,6 +154,9 @@ int main(void) {
draw_text(comp->data, x, 0);
x += font->max_advance_width * strlen(comp->data);
}
+ draw_comp_set(0, comps_left, left_size);
+ draw_comp_set(0.5, comps_center, center_size);
+ draw_comp_set(1, comps_right, right_size);
XFlush(display);
await_change();