diff --git a/bar.c b/bar.c index 9f4cceb..b68ca70 100644 --- a/bar.c +++ b/bar.c @@ -317,9 +317,8 @@ on_mouse(struct bar *bar, enum mouse_event event, int x, int y) } static int -run(struct bar_run_context *run_ctx) +run(struct bar *_bar) { - struct bar *_bar = run_ctx->bar; struct private *bar = _bar->private; /* TODO: a lot of this (up to mapping the window) could be done in bar_new() */ @@ -536,19 +535,19 @@ run(struct bar_run_context *run_ctx) for (size_t i = 0; i < bar->left.count; i++) { struct module *mod = bar->left.mods[i]; - mod->abort_fd = run_ctx->abort_fd; + mod->abort_fd = _bar->abort_fd; thrd_create(&thrd_left[i], (int (*)(void *))bar->left.mods[i]->run, mod); } for (size_t i = 0; i < bar->center.count; i++) { struct module *mod = bar->center.mods[i]; - mod->abort_fd = run_ctx->abort_fd; + mod->abort_fd = _bar->abort_fd; thrd_create(&thrd_center[i], (int (*)(void *))bar->center.mods[i]->run, mod); } for (size_t i = 0; i < bar->right.count; i++) { struct module *mod = bar->right.mods[i]; - mod->abort_fd = run_ctx->abort_fd; + mod->abort_fd = _bar->abort_fd; thrd_create(&thrd_right[i], (int (*)(void *))bar->right.mods[i]->run, mod); } @@ -558,7 +557,7 @@ run(struct bar_run_context *run_ctx) while (true) { struct pollfd fds[] = { - {.fd = run_ctx->abort_fd, .events = POLLIN}, + {.fd = _bar->abort_fd, .events = POLLIN}, {.fd = fd, .events = POLLIN} }; @@ -569,7 +568,7 @@ run(struct bar_run_context *run_ctx) if (fds[1].revents & POLLHUP) { LOG_WARN("disconnected from XCB"); - write(run_ctx->abort_fd, &(uint64_t){1}, sizeof(uint64_t)); + write(_bar->abort_fd, &(uint64_t){1}, sizeof(uint64_t)); break; } diff --git a/bar.h b/bar.h index c64403e..5559584 100644 --- a/bar.h +++ b/bar.h @@ -3,15 +3,11 @@ #include "color.h" #include "module.h" -struct bar; -struct bar_run_context { - struct bar *bar; - int abort_fd; -}; - struct bar { + int abort_fd; + void *private; - int (*run)(struct bar_run_context *ctx); + int (*run)(struct bar *bar); void (*destroy)(struct bar *bar); void (*refresh)(const struct bar *bar); diff --git a/main.c b/main.c index e809de7..20cd327 100644 --- a/main.c +++ b/main.c @@ -120,13 +120,10 @@ main(int argc, const char *const *argv) xcb_init(); - struct bar_run_context bar_ctx = { - .bar = bar, - .abort_fd = abort_fd, - }; + bar->abort_fd = abort_fd; thrd_t bar_thread; - thrd_create(&bar_thread, (int (*)(void *))bar->run, &bar_ctx); + thrd_create(&bar_thread, (int (*)(void *))bar->run, bar); /* Now unblock. We should be only thread receiving SIGINT */ pthread_sigmask(SIG_UNBLOCK, &signal_mask, NULL);