diff options
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 3 | ||||
-rw-r--r-- | swaybar/ipc.c | 2 | ||||
-rw-r--r-- | swaybar/status_line.c | 13 | ||||
-rw-r--r-- | swaybar/tray/item.c | 26 | ||||
-rw-r--r-- | swaybar/tray/tray.c | 4 |
5 files changed, 32 insertions, 16 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index 15eab782..6ffdc9b4 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -54,7 +54,6 @@ static void swaybar_output_free(struct swaybar_output *output) { if (output->input_region != NULL) { wl_region_destroy(output->input_region); } - zxdg_output_v1_destroy(output->xdg_output); wl_output_destroy(output->output); destroy_buffer(&output->buffers[0]); destroy_buffer(&output->buffers[1]); @@ -172,7 +171,7 @@ bool determine_bar_visibility(struct swaybar *bar, bool moving_layer) { if (bar->status) { sway_log(SWAY_DEBUG, "Sending %s signal to status command", visible ? "cont" : "stop"); - kill(bar->status->pid, visible ? + kill(-bar->status->pid, visible ? bar->status->cont_signal : bar->status->stop_signal); } } diff --git a/swaybar/ipc.c b/swaybar/ipc.c index a64aa1ab..2cb235bf 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -550,7 +550,7 @@ bool handle_ipc_readable(struct swaybar *bar) { // The default depth of 32 is too small to represent some nested layouts, but // we can't pass INT_MAX here because json-c (as of this writing) prefaults // all the memory for its stack. - json_tokener *tok = json_tokener_new_ex(256); + json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH); if (!tok) { sway_log_errno(SWAY_ERROR, "failed to create tokener"); free_ipc_response(resp); diff --git a/swaybar/status_line.c b/swaybar/status_line.c index ecd91032..2e9bb7f1 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c @@ -117,11 +117,11 @@ bool status_handle_readable(struct status_line *status) { status->text = status->buffer; // intentional fall-through case PROTOCOL_TEXT: - errno = 0; while (true) { if (status->buffer[read_bytes - 1] == '\n') { status->buffer[read_bytes - 1] = '\0'; } + errno = 0; read_bytes = getline(&status->buffer, &status->buffer_size, status->read); if (errno == EAGAIN) { @@ -157,7 +157,12 @@ struct status_line *status_line_init(char *cmd) { assert(!getenv("WAYLAND_SOCKET") && "display must be initialized before " " starting `status-command`; WAYLAND_SOCKET should not be set"); status->pid = fork(); - if (status->pid == 0) { + if (status->pid < 0) { + sway_log_errno(SWAY_ERROR, "fork failed"); + exit(1); + } else if (status->pid == 0) { + setpgid(0, 0); + dup2(pipe_read_fd[1], STDOUT_FILENO); close(pipe_read_fd[0]); close(pipe_read_fd[1]); @@ -185,8 +190,8 @@ struct status_line *status_line_init(char *cmd) { void status_line_free(struct status_line *status) { status_line_close_fds(status); - kill(status->pid, status->cont_signal); - kill(status->pid, SIGTERM); + kill(-status->pid, status->cont_signal); + kill(-status->pid, SIGTERM); waitpid(status->pid, NULL, 0); if (status->protocol == PROTOCOL_I3BAR) { struct i3bar_block *block, *tmp; diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c index 19f4beac..6d4b17bf 100644 --- a/swaybar/tray/item.c +++ b/swaybar/tray/item.c @@ -493,24 +493,36 @@ uint32_t render_sni(cairo_t *cairo, struct swaybar_output *output, double *x, cairo_destroy(cairo_icon); } - int padded_size = icon_size + 2*padding; - *x -= padded_size; - int y = floor((height - padded_size) / 2.0); + double descaled_padding = (double)padding / output->scale; + double descaled_icon_size = (double)icon_size / output->scale; + + int size = descaled_icon_size + 2 * descaled_padding; + *x -= size; + int icon_y = floor((output->height - size) / 2.0); cairo_operator_t op = cairo_get_operator(cairo); cairo_set_operator(cairo, CAIRO_OPERATOR_OVER); - cairo_set_source_surface(cairo, icon, *x + padding, y + padding); - cairo_rectangle(cairo, *x, y, padded_size, padded_size); + + cairo_matrix_t scale_matrix; + cairo_pattern_t *icon_pattern = cairo_pattern_create_for_surface(icon); + // TODO: check cairo_pattern_status for "ENOMEM" + cairo_matrix_init_scale(&scale_matrix, output->scale, output->scale); + cairo_matrix_translate(&scale_matrix, -(*x + descaled_padding), -(icon_y + descaled_padding)); + cairo_pattern_set_matrix(icon_pattern, &scale_matrix); + cairo_set_source(cairo, icon_pattern); + cairo_rectangle(cairo, *x, icon_y, size, size); cairo_fill(cairo); + cairo_set_operator(cairo, op); + cairo_pattern_destroy(icon_pattern); cairo_surface_destroy(icon); struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); hotspot->x = *x; hotspot->y = 0; - hotspot->width = height; - hotspot->height = height; + hotspot->width = size; + hotspot->height = output->height; hotspot->callback = icon_hotspot_callback; hotspot->destroy = free; hotspot->data = strdup(sni->watcher_id); diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c index 5fe6f9c3..b0545f4a 100644 --- a/swaybar/tray/tray.c +++ b/swaybar/tray/tray.c @@ -116,8 +116,8 @@ uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) { } } // else display on all - if ((int) output->height*output->scale <= 2*config->tray_padding) { - return 2*config->tray_padding + 1; + if ((int)(output->height * output->scale) <= 2 * config->tray_padding) { + return (2 * config->tray_padding + 1) / output->scale; } uint32_t max_height = 0; |