Formatted for consistency, moved some struct Tag* declarations outside of loops because I feel like it (probably won't hurt).
Changed some of the LENGTH usages to use the bar::tags field rather than the config.def.h tags so that things are a bit more consistent. In bar_create when creating tags I index tags directly as opposed to using the already initialized and declared tags variable.
このコミットが含まれているのは:
コミット
90582a831d
31
src/bar.c
31
src/bar.c
|
@ -93,7 +93,7 @@ void bar_bounds(void *data, double *x, double *y, double *width, double *height)
|
|||
struct Bar *bar = data;
|
||||
int bar_width = 0;
|
||||
struct Tag *tag;
|
||||
for (int i = 0; i < LENGTH(tags); i++) {
|
||||
for (int i = 0; i < LENGTH(bar->tags); i++) {
|
||||
tag = &bar->tags[i];
|
||||
bar_width += tag->component->width;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ enum Clicked bar_get_location(struct Bar *bar, double x, double y, int *tag_inde
|
|||
enum Clicked clicked = Click_None;
|
||||
struct Tag *tag;
|
||||
|
||||
for (int i = 0; i < LENGTH(tags); i++) {
|
||||
for (int i = 0; i < LENGTH(bar->tags); i++) {
|
||||
tag = &bar->tags[i];
|
||||
if (basic_component_is_clicked(tag->component, x, y)) {
|
||||
clicked = Click_Tag;
|
||||
|
@ -144,11 +144,12 @@ struct Bar *bar_create(struct List *hotspots, struct Pipeline *pipeline) {
|
|||
pango_layout_set_text(bar->status->layout, status, strlen(status));
|
||||
free(status);
|
||||
|
||||
struct Tag *tag;
|
||||
for (int i = 0; i < LENGTH(tags); i++) {
|
||||
struct Tag *tag = &bar->tags[i];
|
||||
tag = &bar->tags[i];
|
||||
*tag = (struct Tag){ 0, 0, 0,
|
||||
bar_component_create(pipeline) };
|
||||
pango_layout_set_text(bar->tags[i].component->layout, tags[i], strlen(tags[i]));
|
||||
pango_layout_set_text(tag->component->layout, tags[i], strlen(tags[i]));
|
||||
tag->component->width = basic_component_text_width(tag->component) + pipeline->font->height;
|
||||
}
|
||||
|
||||
|
@ -170,8 +171,9 @@ void bar_destroy(struct Bar *bar) {
|
|||
basic_component_destroy(bar->title);
|
||||
basic_component_destroy(bar->layout);
|
||||
basic_component_destroy(bar->status);
|
||||
for (int i = 0; i < LENGTH(tags); i++) {
|
||||
struct Tag *tag = &bar->tags[i];
|
||||
struct Tag *tag;
|
||||
for (int i = 0; i < LENGTH(bar->tags); i++) {
|
||||
tag = &bar->tags[i];
|
||||
basic_component_destroy(tag->component);
|
||||
}
|
||||
free(bar);
|
||||
|
@ -206,8 +208,9 @@ void bar_tags_render(struct Pipeline *pipeline, struct Bar *bar, cairo_t *painte
|
|||
if (!bar || !pipeline)
|
||||
return;
|
||||
|
||||
struct Tag *tag;
|
||||
for (int i = 0; i < LENGTH(tags); i++) {
|
||||
struct Tag *tag = &bar->tags[i];
|
||||
tag = &bar->tags[i];
|
||||
|
||||
if (tag->state & Tag_Active)
|
||||
pipeline_set_colorscheme(pipeline, schemes[Active_Scheme]);
|
||||
|
@ -227,12 +230,12 @@ void bar_tags_render(struct Pipeline *pipeline, struct Bar *bar, cairo_t *painte
|
|||
boxWidth = pipeline->font->height / 6 + 1;
|
||||
|
||||
if (tag->has_focused) {
|
||||
cairo_rectangle(painter, *x + boxHeight, boxHeight, boxWidth, boxWidth);
|
||||
cairo_fill(painter);
|
||||
cairo_rectangle(painter, *x + boxHeight, boxHeight, boxWidth, boxWidth);
|
||||
cairo_fill(painter);
|
||||
} else {
|
||||
cairo_rectangle(painter, *x + boxHeight + 0.5, boxHeight + 0.5, boxWidth, boxWidth);
|
||||
cairo_set_line_width(painter, 1);
|
||||
cairo_stroke(painter);
|
||||
cairo_rectangle(painter, *x + boxHeight + 0.5, boxHeight + 0.5, boxWidth, boxWidth);
|
||||
cairo_set_line_width(painter, 1);
|
||||
cairo_stroke(painter);
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -268,7 +271,7 @@ void bar_title_render(struct Pipeline *pipeline, struct Bar *bar, cairo_t *paint
|
|||
cairo_set_line_width(painter, 1);
|
||||
cairo_stroke(painter);
|
||||
|
||||
done:
|
||||
done:
|
||||
*x += bar->title->width;
|
||||
}
|
||||
|
||||
|
@ -353,7 +356,7 @@ int bar_width(struct Pipeline *pipeline, void *data, unsigned int future_widths)
|
|||
struct Bar *bar = data;
|
||||
int width = 0, title_width, status_width;
|
||||
|
||||
for (int i = 0; i < LENGTH(tags); i++)
|
||||
for (int i = 0; i < LENGTH(bar->tags); i++)
|
||||
width += bar_component_width(bar->tags[i].component, pipeline);
|
||||
width += bar_component_width(bar->layout, pipeline);
|
||||
|
||||
|
|
読み込み中…
新しいイシューから参照