From a4f7bf23b21d0d838a8a19261d5fd69719003a03 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Fri, 27 Jul 2018 11:19:42 -0400 Subject: Address first round review for swaynag --- swaynag/render.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 swaynag/render.c (limited to 'swaynag/render.c') diff --git a/swaynag/render.c b/swaynag/render.c new file mode 100644 index 00000000..150ae3f2 --- /dev/null +++ b/swaynag/render.c @@ -0,0 +1,300 @@ +#include +#include "cairo.h" +#include "log.h" +#include "pango.h" +#include "pool-buffer.h" +#include "swaynag/nagbar.h" +#include "wlr-layer-shell-unstable-v1-client-protocol.h" + +static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { + uint32_t height = nagbar->height * nagbar->scale; + height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; + + int text_width, text_height; + get_text_size(cairo, nagbar->font, &text_width, &text_height, + nagbar->scale, true, "%s", nagbar->message); + + int padding = NAGBAR_MESSAGE_PADDING * nagbar->scale; + + uint32_t ideal_height = text_height + padding * 2; + uint32_t ideal_surface_height = ideal_height / nagbar->scale; + if (nagbar->height < ideal_surface_height) { + return ideal_surface_height; + } + + cairo_set_source_u32(cairo, nagbar->colors.text); + cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); + pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", + nagbar->message); + + return ideal_height; +} + +static void render_details_scroll_button(cairo_t *cairo, + struct sway_nagbar *nagbar, struct sway_nagbar_button *button) { + int text_width, text_height; + get_text_size(cairo, nagbar->font, &text_width, &text_height, + nagbar->scale, true, "%s", button->text); + + int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; + int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; + + cairo_set_source_u32(cairo, nagbar->colors.border); + cairo_rectangle(cairo, button->x, button->y, + button->width, button->height); + cairo_fill(cairo); + + cairo_set_source_u32(cairo, nagbar->colors.button_background); + cairo_rectangle(cairo, button->x + border, button->y + border, + button->width - (border * 2), button->height - (border * 2)); + cairo_fill(cairo); + + cairo_set_source_u32(cairo, nagbar->colors.text); + cairo_move_to(cairo, button->x + border + padding, + button->y + border + (button->height - text_height) / 2); + pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); +} + +static int get_detailed_scroll_button_width(cairo_t *cairo, + struct sway_nagbar *nagbar) { + int up_width, down_width, temp_height; + get_text_size(cairo, nagbar->font, &up_width, &temp_height, + nagbar->scale, true, "%s", nagbar->details.button_up.text); + get_text_size(cairo, nagbar->font, &down_width, &temp_height, + nagbar->scale, true, "%s", nagbar->details.button_down.text); + + int text_width = up_width > down_width ? up_width : down_width; + int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; + int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; + + return text_width + border * 2 + padding * 2; +} + +static uint32_t render_detailed(cairo_t *cairo, struct sway_nagbar *nagbar, + uint32_t y) { + uint32_t width = nagbar->width * nagbar->scale; + uint32_t height = nagbar->height * nagbar->scale; + height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; + + int border = NAGBAR_DETAILS_BORDER_THICKNESS * nagbar->scale; + int padding = NAGBAR_MESSAGE_PADDING * nagbar->scale; + int decor = padding + border; + + nagbar->details.x = decor; + nagbar->details.y = y + decor; + nagbar->details.width = width - decor * 2; + + PangoLayout *layout = get_pango_layout(cairo, nagbar->font, + nagbar->details.message, nagbar->scale, true); + pango_layout_set_width(layout, + (nagbar->details.width - padding * 2) * PANGO_SCALE); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_single_paragraph_mode(layout, false); + pango_cairo_update_layout(cairo, layout); + nagbar->details.total_lines = pango_layout_get_line_count(layout); + + PangoLayoutLine *line; + line = pango_layout_get_line_readonly(layout, nagbar->details.offset); + gint offset = line->start_index; + const char *text = pango_layout_get_text(layout); + pango_layout_set_text(layout, text + offset, strlen(text) - offset); + + int text_width, text_height; + pango_cairo_update_layout(cairo, layout); + pango_layout_get_pixel_size(layout, &text_width, &text_height); + + bool show_buttons = nagbar->details.offset > 0; + int button_width = get_detailed_scroll_button_width(cairo, nagbar); + if (show_buttons) { + nagbar->details.width -= button_width; + pango_layout_set_width(layout, + (nagbar->details.width - padding * 2) * PANGO_SCALE); + } + + uint32_t ideal_height; + do { + ideal_height = nagbar->details.y + text_height + decor + padding * 2; + if (ideal_height > NAGBAR_MAX_HEIGHT) { + ideal_height = NAGBAR_MAX_HEIGHT; + + if (!show_buttons) { + show_buttons = true; + nagbar->details.width -= button_width; + pango_layout_set_width(layout, + (nagbar->details.width - padding * 2) * PANGO_SCALE); + } + } + + nagbar->details.height = ideal_height - nagbar->details.y - decor; + pango_layout_set_height(layout, + (nagbar->details.height - padding * 2) * PANGO_SCALE); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); + pango_cairo_update_layout(cairo, layout); + pango_layout_get_pixel_size(layout, &text_width, &text_height); + } while (text_height != (nagbar->details.height - padding * 2)); + + nagbar->details.visible_lines = pango_layout_get_line_count(layout); + + if (show_buttons) { + nagbar->details.button_up.x = + nagbar->details.x + nagbar->details.width; + nagbar->details.button_up.y = nagbar->details.y; + nagbar->details.button_up.width = button_width; + nagbar->details.button_up.height = nagbar->details.height / 2; + render_details_scroll_button(cairo, nagbar, + &nagbar->details.button_up); + + nagbar->details.button_down.x = + nagbar->details.x + nagbar->details.width; + nagbar->details.button_down.y = + nagbar->details.button_up.y + nagbar->details.button_up.height; + nagbar->details.button_down.width = button_width; + nagbar->details.button_down.height = nagbar->details.height / 2; + render_details_scroll_button(cairo, nagbar, + &nagbar->details.button_down); + } + + cairo_set_source_u32(cairo, nagbar->colors.border); + cairo_rectangle(cairo, nagbar->details.x, nagbar->details.y, + nagbar->details.width, nagbar->details.height); + cairo_fill(cairo); + + cairo_move_to(cairo, nagbar->details.x + padding, + nagbar->details.y + padding); + cairo_set_source_u32(cairo, nagbar->colors.text); + pango_cairo_show_layout(cairo, layout); + g_object_unref(layout); + + return ideal_height; +} + +static uint32_t render_button(cairo_t *cairo, struct sway_nagbar *nagbar, + int button_index, int *x) { + uint32_t height = nagbar->height * nagbar->scale; + height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; + struct sway_nagbar_button *button = nagbar->buttons->items[button_index]; + + int text_width, text_height; + get_text_size(cairo, nagbar->font, &text_width, &text_height, + nagbar->scale, true, "%s", button->text); + + int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; + int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; + + uint32_t ideal_height = text_height + padding * 2 + border * 2; + uint32_t ideal_surface_height = ideal_height / nagbar->scale; + if (nagbar->height < ideal_surface_height) { + return ideal_surface_height; + } + + button->x = *x - border - text_width - padding * 2; + button->y = (int)(ideal_height - text_height) / 2 - padding; + button->width = text_width + padding * 2; + button->height = text_height + padding * 2; + + cairo_set_source_u32(cairo, nagbar->colors.border); + cairo_rectangle(cairo, button->x - border, button->y - border, + button->width + border * 2, button->height + border * 2); + cairo_fill(cairo); + + cairo_set_source_u32(cairo, nagbar->colors.button_background); + cairo_rectangle(cairo, button->x, button->y, + button->width, button->height); + cairo_fill(cairo); + + cairo_set_source_u32(cairo, nagbar->colors.text); + cairo_move_to(cairo, button->x + padding, button->y + padding); + pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); + + *x = button->x - border; + + return ideal_height; +} + +static uint32_t render_to_cairo(cairo_t *cairo, struct sway_nagbar *nagbar) { + uint32_t max_height = 0; + + cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); + cairo_set_source_u32(cairo, nagbar->colors.background); + cairo_paint(cairo); + + uint32_t h = render_message(cairo, nagbar); + max_height = h > max_height ? h : max_height; + + int x = (nagbar->width - NAGBAR_BUTTON_MARGIN_RIGHT) * nagbar->scale; + for (int i = 0; i < nagbar->buttons->length; i++) { + h = render_button(cairo, nagbar, i, &x); + max_height = h > max_height ? h : max_height; + x -= NAGBAR_BUTTON_GAP * nagbar->scale; + if (i == 0) { + x -= NAGBAR_BUTTON_GAP_CLOSE * nagbar->scale; + } + } + + if (nagbar->details.visible) { + h = render_detailed(cairo, nagbar, max_height); + max_height = h > max_height ? h : max_height; + } + + int border = NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; + if (max_height > nagbar->height) { + max_height += border; + } + cairo_set_source_u32(cairo, nagbar->colors.border_bottom); + cairo_rectangle(cairo, 0, nagbar->height * nagbar->scale - border, + nagbar->width * nagbar->scale, border); + cairo_fill(cairo); + + return max_height; +} + +void render_frame(struct sway_nagbar *nagbar) { + if (!nagbar->run_display) { + return; + } + + cairo_surface_t *recorder = cairo_recording_surface_create( + CAIRO_CONTENT_COLOR_ALPHA, NULL); + cairo_t *cairo = cairo_create(recorder); + cairo_save(cairo); + cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); + cairo_paint(cairo); + cairo_restore(cairo); + uint32_t height = render_to_cairo(cairo, nagbar); + if (height != nagbar->height) { + zwlr_layer_surface_v1_set_size(nagbar->layer_surface, 0, height); + zwlr_layer_surface_v1_set_exclusive_zone(nagbar->layer_surface, + height); + wl_surface_commit(nagbar->surface); + wl_display_roundtrip(nagbar->display); + } else { + nagbar->current_buffer = get_next_buffer(nagbar->shm, + nagbar->buffers, + nagbar->width * nagbar->scale, + nagbar->height * nagbar->scale); + if (!nagbar->current_buffer) { + wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame."); + goto cleanup; + } + + cairo_t *shm = nagbar->current_buffer->cairo; + cairo_save(shm); + cairo_set_operator(shm, CAIRO_OPERATOR_CLEAR); + cairo_paint(shm); + cairo_restore(shm); + cairo_set_source_surface(shm, recorder, 0.0, 0.0); + cairo_paint(shm); + + wl_surface_set_buffer_scale(nagbar->surface, nagbar->scale); + wl_surface_attach(nagbar->surface, + nagbar->current_buffer->buffer, 0, 0); + wl_surface_damage(nagbar->surface, 0, 0, + nagbar->width, nagbar->height); + wl_surface_commit(nagbar->surface); + wl_display_roundtrip(nagbar->display); + } + +cleanup: + cairo_surface_destroy(recorder); + cairo_destroy(cairo); +} -- cgit v1.2.3 From 8463a2896a932cd99f3dc93608b03cb4aba93293 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sat, 28 Jul 2018 09:34:25 -0400 Subject: swaynag: implement config file support --- swaynag/render.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'swaynag/render.c') diff --git a/swaynag/render.c b/swaynag/render.c index 150ae3f2..134c247e 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -4,6 +4,7 @@ #include "pango.h" #include "pool-buffer.h" #include "swaynag/nagbar.h" +#include "swaynag/types.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { @@ -22,7 +23,7 @@ static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { return ideal_surface_height; } - cairo_set_source_u32(cairo, nagbar->colors.text); + cairo_set_source_u32(cairo, nagbar->type->text); cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", nagbar->message); @@ -39,17 +40,17 @@ static void render_details_scroll_button(cairo_t *cairo, int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; - cairo_set_source_u32(cairo, nagbar->colors.border); + cairo_set_source_u32(cairo, nagbar->type->border); cairo_rectangle(cairo, button->x, button->y, button->width, button->height); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->colors.button_background); + cairo_set_source_u32(cairo, nagbar->type->button_background); cairo_rectangle(cairo, button->x + border, button->y + border, button->width - (border * 2), button->height - (border * 2)); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->colors.text); + cairo_set_source_u32(cairo, nagbar->type->text); cairo_move_to(cairo, button->x + border + padding, button->y + border + (button->height - text_height) / 2); pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); @@ -154,14 +155,14 @@ static uint32_t render_detailed(cairo_t *cairo, struct sway_nagbar *nagbar, &nagbar->details.button_down); } - cairo_set_source_u32(cairo, nagbar->colors.border); + cairo_set_source_u32(cairo, nagbar->type->border); cairo_rectangle(cairo, nagbar->details.x, nagbar->details.y, nagbar->details.width, nagbar->details.height); cairo_fill(cairo); cairo_move_to(cairo, nagbar->details.x + padding, nagbar->details.y + padding); - cairo_set_source_u32(cairo, nagbar->colors.text); + cairo_set_source_u32(cairo, nagbar->type->text); pango_cairo_show_layout(cairo, layout); g_object_unref(layout); @@ -192,17 +193,17 @@ static uint32_t render_button(cairo_t *cairo, struct sway_nagbar *nagbar, button->width = text_width + padding * 2; button->height = text_height + padding * 2; - cairo_set_source_u32(cairo, nagbar->colors.border); + cairo_set_source_u32(cairo, nagbar->type->border); cairo_rectangle(cairo, button->x - border, button->y - border, button->width + border * 2, button->height + border * 2); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->colors.button_background); + cairo_set_source_u32(cairo, nagbar->type->button_background); cairo_rectangle(cairo, button->x, button->y, button->width, button->height); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->colors.text); + cairo_set_source_u32(cairo, nagbar->type->text); cairo_move_to(cairo, button->x + padding, button->y + padding); pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); @@ -215,7 +216,7 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct sway_nagbar *nagbar) { uint32_t max_height = 0; cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); - cairo_set_source_u32(cairo, nagbar->colors.background); + cairo_set_source_u32(cairo, nagbar->type->background); cairo_paint(cairo); uint32_t h = render_message(cairo, nagbar); @@ -240,7 +241,7 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct sway_nagbar *nagbar) { if (max_height > nagbar->height) { max_height += border; } - cairo_set_source_u32(cairo, nagbar->colors.border_bottom); + cairo_set_source_u32(cairo, nagbar->type->border_bottom); cairo_rectangle(cairo, 0, nagbar->height * nagbar->scale - border, nagbar->width * nagbar->scale, border); cairo_fill(cairo); -- cgit v1.2.3 From 58f3fa74aeb3e0dd9500d687f3c97a6c10612c41 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 28 Jul 2018 09:48:37 -0400 Subject: Disable pango markup for extended message --- swaynag/render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'swaynag/render.c') diff --git a/swaynag/render.c b/swaynag/render.c index 134c247e..ef0f72a8 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -25,7 +25,7 @@ static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { cairo_set_source_u32(cairo, nagbar->type->text); cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); - pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", + pango_printf(cairo, nagbar->font, nagbar->scale, false, "%s", nagbar->message); return ideal_height; @@ -86,7 +86,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct sway_nagbar *nagbar, nagbar->details.width = width - decor * 2; PangoLayout *layout = get_pango_layout(cairo, nagbar->font, - nagbar->details.message, nagbar->scale, true); + nagbar->details.message, nagbar->scale, false); pango_layout_set_width(layout, (nagbar->details.width - padding * 2) * PANGO_SCALE); pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); -- cgit v1.2.3 From a6145914c60351d8e541192c7fe35556f8e02507 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sat, 28 Jul 2018 23:15:12 -0400 Subject: swaynag: refactor {sway_,}nagbar to swaynag --- swaynag/render.c | 256 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 129 insertions(+), 127 deletions(-) (limited to 'swaynag/render.c') diff --git a/swaynag/render.c b/swaynag/render.c index ef0f72a8..67e26eaf 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -3,99 +3,100 @@ #include "log.h" #include "pango.h" #include "pool-buffer.h" -#include "swaynag/nagbar.h" +#include "swaynag/swaynag.h" #include "swaynag/types.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" -static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { - uint32_t height = nagbar->height * nagbar->scale; - height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; +static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) { + uint32_t height = swaynag->height * swaynag->scale; + height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; int text_width, text_height; - get_text_size(cairo, nagbar->font, &text_width, &text_height, - nagbar->scale, true, "%s", nagbar->message); + get_text_size(cairo, swaynag->font, &text_width, &text_height, + swaynag->scale, true, "%s", swaynag->message); - int padding = NAGBAR_MESSAGE_PADDING * nagbar->scale; + int padding = SWAYNAG_MESSAGE_PADDING * swaynag->scale; uint32_t ideal_height = text_height + padding * 2; - uint32_t ideal_surface_height = ideal_height / nagbar->scale; - if (nagbar->height < ideal_surface_height) { + uint32_t ideal_surface_height = ideal_height / swaynag->scale; + if (swaynag->height < ideal_surface_height) { return ideal_surface_height; } - cairo_set_source_u32(cairo, nagbar->type->text); + cairo_set_source_u32(cairo, swaynag->type->text); cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); - pango_printf(cairo, nagbar->font, nagbar->scale, false, "%s", - nagbar->message); + pango_printf(cairo, swaynag->font, swaynag->scale, false, "%s", + swaynag->message); return ideal_height; } static void render_details_scroll_button(cairo_t *cairo, - struct sway_nagbar *nagbar, struct sway_nagbar_button *button) { + struct swaynag *swaynag, struct swaynag_button *button) { int text_width, text_height; - get_text_size(cairo, nagbar->font, &text_width, &text_height, - nagbar->scale, true, "%s", button->text); + get_text_size(cairo, swaynag->font, &text_width, &text_height, + swaynag->scale, true, "%s", button->text); - int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; - int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; + int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale; + int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale; - cairo_set_source_u32(cairo, nagbar->type->border); + cairo_set_source_u32(cairo, swaynag->type->border); cairo_rectangle(cairo, button->x, button->y, button->width, button->height); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->type->button_background); + cairo_set_source_u32(cairo, swaynag->type->button_background); cairo_rectangle(cairo, button->x + border, button->y + border, button->width - (border * 2), button->height - (border * 2)); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->type->text); + cairo_set_source_u32(cairo, swaynag->type->text); cairo_move_to(cairo, button->x + border + padding, button->y + border + (button->height - text_height) / 2); - pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); + pango_printf(cairo, swaynag->font, swaynag->scale, true, + "%s", button->text); } static int get_detailed_scroll_button_width(cairo_t *cairo, - struct sway_nagbar *nagbar) { + struct swaynag *swaynag) { int up_width, down_width, temp_height; - get_text_size(cairo, nagbar->font, &up_width, &temp_height, - nagbar->scale, true, "%s", nagbar->details.button_up.text); - get_text_size(cairo, nagbar->font, &down_width, &temp_height, - nagbar->scale, true, "%s", nagbar->details.button_down.text); + get_text_size(cairo, swaynag->font, &up_width, &temp_height, + swaynag->scale, true, "%s", swaynag->details.button_up.text); + get_text_size(cairo, swaynag->font, &down_width, &temp_height, + swaynag->scale, true, "%s", swaynag->details.button_down.text); int text_width = up_width > down_width ? up_width : down_width; - int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; - int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; + int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale; + int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale; return text_width + border * 2 + padding * 2; } -static uint32_t render_detailed(cairo_t *cairo, struct sway_nagbar *nagbar, +static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, uint32_t y) { - uint32_t width = nagbar->width * nagbar->scale; - uint32_t height = nagbar->height * nagbar->scale; - height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; + uint32_t width = swaynag->width * swaynag->scale; + uint32_t height = swaynag->height * swaynag->scale; + height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; - int border = NAGBAR_DETAILS_BORDER_THICKNESS * nagbar->scale; - int padding = NAGBAR_MESSAGE_PADDING * nagbar->scale; + int border = SWAYNAG_DETAILS_BORDER_THICKNESS * swaynag->scale; + int padding = SWAYNAG_MESSAGE_PADDING * swaynag->scale; int decor = padding + border; - nagbar->details.x = decor; - nagbar->details.y = y + decor; - nagbar->details.width = width - decor * 2; + swaynag->details.x = decor; + swaynag->details.y = y + decor; + swaynag->details.width = width - decor * 2; - PangoLayout *layout = get_pango_layout(cairo, nagbar->font, - nagbar->details.message, nagbar->scale, false); + PangoLayout *layout = get_pango_layout(cairo, swaynag->font, + swaynag->details.message, swaynag->scale, false); pango_layout_set_width(layout, - (nagbar->details.width - padding * 2) * PANGO_SCALE); + (swaynag->details.width - padding * 2) * PANGO_SCALE); pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); pango_layout_set_single_paragraph_mode(layout, false); pango_cairo_update_layout(cairo, layout); - nagbar->details.total_lines = pango_layout_get_line_count(layout); + swaynag->details.total_lines = pango_layout_get_line_count(layout); PangoLayoutLine *line; - line = pango_layout_get_line_readonly(layout, nagbar->details.offset); + line = pango_layout_get_line_readonly(layout, swaynag->details.offset); gint offset = line->start_index; const char *text = pango_layout_get_text(layout); pango_layout_set_text(layout, text + offset, strlen(text) - offset); @@ -104,87 +105,87 @@ static uint32_t render_detailed(cairo_t *cairo, struct sway_nagbar *nagbar, pango_cairo_update_layout(cairo, layout); pango_layout_get_pixel_size(layout, &text_width, &text_height); - bool show_buttons = nagbar->details.offset > 0; - int button_width = get_detailed_scroll_button_width(cairo, nagbar); + bool show_buttons = swaynag->details.offset > 0; + int button_width = get_detailed_scroll_button_width(cairo, swaynag); if (show_buttons) { - nagbar->details.width -= button_width; + swaynag->details.width -= button_width; pango_layout_set_width(layout, - (nagbar->details.width - padding * 2) * PANGO_SCALE); + (swaynag->details.width - padding * 2) * PANGO_SCALE); } uint32_t ideal_height; do { - ideal_height = nagbar->details.y + text_height + decor + padding * 2; - if (ideal_height > NAGBAR_MAX_HEIGHT) { - ideal_height = NAGBAR_MAX_HEIGHT; + ideal_height = swaynag->details.y + text_height + decor + padding * 2; + if (ideal_height > SWAYNAG_MAX_HEIGHT) { + ideal_height = SWAYNAG_MAX_HEIGHT; if (!show_buttons) { show_buttons = true; - nagbar->details.width -= button_width; + swaynag->details.width -= button_width; pango_layout_set_width(layout, - (nagbar->details.width - padding * 2) * PANGO_SCALE); + (swaynag->details.width - padding * 2) * PANGO_SCALE); } } - nagbar->details.height = ideal_height - nagbar->details.y - decor; + swaynag->details.height = ideal_height - swaynag->details.y - decor; pango_layout_set_height(layout, - (nagbar->details.height - padding * 2) * PANGO_SCALE); + (swaynag->details.height - padding * 2) * PANGO_SCALE); pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); pango_cairo_update_layout(cairo, layout); pango_layout_get_pixel_size(layout, &text_width, &text_height); - } while (text_height != (nagbar->details.height - padding * 2)); + } while (text_height != (swaynag->details.height - padding * 2)); - nagbar->details.visible_lines = pango_layout_get_line_count(layout); + swaynag->details.visible_lines = pango_layout_get_line_count(layout); if (show_buttons) { - nagbar->details.button_up.x = - nagbar->details.x + nagbar->details.width; - nagbar->details.button_up.y = nagbar->details.y; - nagbar->details.button_up.width = button_width; - nagbar->details.button_up.height = nagbar->details.height / 2; - render_details_scroll_button(cairo, nagbar, - &nagbar->details.button_up); - - nagbar->details.button_down.x = - nagbar->details.x + nagbar->details.width; - nagbar->details.button_down.y = - nagbar->details.button_up.y + nagbar->details.button_up.height; - nagbar->details.button_down.width = button_width; - nagbar->details.button_down.height = nagbar->details.height / 2; - render_details_scroll_button(cairo, nagbar, - &nagbar->details.button_down); + swaynag->details.button_up.x = + swaynag->details.x + swaynag->details.width; + swaynag->details.button_up.y = swaynag->details.y; + swaynag->details.button_up.width = button_width; + swaynag->details.button_up.height = swaynag->details.height / 2; + render_details_scroll_button(cairo, swaynag, + &swaynag->details.button_up); + + swaynag->details.button_down.x = + swaynag->details.x + swaynag->details.width; + swaynag->details.button_down.y = + swaynag->details.button_up.y + swaynag->details.button_up.height; + swaynag->details.button_down.width = button_width; + swaynag->details.button_down.height = swaynag->details.height / 2; + render_details_scroll_button(cairo, swaynag, + &swaynag->details.button_down); } - cairo_set_source_u32(cairo, nagbar->type->border); - cairo_rectangle(cairo, nagbar->details.x, nagbar->details.y, - nagbar->details.width, nagbar->details.height); + cairo_set_source_u32(cairo, swaynag->type->border); + cairo_rectangle(cairo, swaynag->details.x, swaynag->details.y, + swaynag->details.width, swaynag->details.height); cairo_fill(cairo); - cairo_move_to(cairo, nagbar->details.x + padding, - nagbar->details.y + padding); - cairo_set_source_u32(cairo, nagbar->type->text); + cairo_move_to(cairo, swaynag->details.x + padding, + swaynag->details.y + padding); + cairo_set_source_u32(cairo, swaynag->type->text); pango_cairo_show_layout(cairo, layout); g_object_unref(layout); return ideal_height; } -static uint32_t render_button(cairo_t *cairo, struct sway_nagbar *nagbar, +static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, int button_index, int *x) { - uint32_t height = nagbar->height * nagbar->scale; - height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; - struct sway_nagbar_button *button = nagbar->buttons->items[button_index]; + uint32_t height = swaynag->height * swaynag->scale; + height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; + struct swaynag_button *button = swaynag->buttons->items[button_index]; int text_width, text_height; - get_text_size(cairo, nagbar->font, &text_width, &text_height, - nagbar->scale, true, "%s", button->text); + get_text_size(cairo, swaynag->font, &text_width, &text_height, + swaynag->scale, true, "%s", button->text); - int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; - int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; + int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale; + int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale; uint32_t ideal_height = text_height + padding * 2 + border * 2; - uint32_t ideal_surface_height = ideal_height / nagbar->scale; - if (nagbar->height < ideal_surface_height) { + uint32_t ideal_surface_height = ideal_height / swaynag->scale; + if (swaynag->height < ideal_surface_height) { return ideal_surface_height; } @@ -193,64 +194,65 @@ static uint32_t render_button(cairo_t *cairo, struct sway_nagbar *nagbar, button->width = text_width + padding * 2; button->height = text_height + padding * 2; - cairo_set_source_u32(cairo, nagbar->type->border); + cairo_set_source_u32(cairo, swaynag->type->border); cairo_rectangle(cairo, button->x - border, button->y - border, button->width + border * 2, button->height + border * 2); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->type->button_background); + cairo_set_source_u32(cairo, swaynag->type->button_background); cairo_rectangle(cairo, button->x, button->y, button->width, button->height); cairo_fill(cairo); - cairo_set_source_u32(cairo, nagbar->type->text); + cairo_set_source_u32(cairo, swaynag->type->text); cairo_move_to(cairo, button->x + padding, button->y + padding); - pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); + pango_printf(cairo, swaynag->font, swaynag->scale, true, + "%s", button->text); *x = button->x - border; return ideal_height; } -static uint32_t render_to_cairo(cairo_t *cairo, struct sway_nagbar *nagbar) { +static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { uint32_t max_height = 0; cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); - cairo_set_source_u32(cairo, nagbar->type->background); + cairo_set_source_u32(cairo, swaynag->type->background); cairo_paint(cairo); - uint32_t h = render_message(cairo, nagbar); + uint32_t h = render_message(cairo, swaynag); max_height = h > max_height ? h : max_height; - int x = (nagbar->width - NAGBAR_BUTTON_MARGIN_RIGHT) * nagbar->scale; - for (int i = 0; i < nagbar->buttons->length; i++) { - h = render_button(cairo, nagbar, i, &x); + int x = (swaynag->width - SWAYNAG_BUTTON_MARGIN_RIGHT) * swaynag->scale; + for (int i = 0; i < swaynag->buttons->length; i++) { + h = render_button(cairo, swaynag, i, &x); max_height = h > max_height ? h : max_height; - x -= NAGBAR_BUTTON_GAP * nagbar->scale; + x -= SWAYNAG_BUTTON_GAP * swaynag->scale; if (i == 0) { - x -= NAGBAR_BUTTON_GAP_CLOSE * nagbar->scale; + x -= SWAYNAG_BUTTON_GAP_CLOSE * swaynag->scale; } } - if (nagbar->details.visible) { - h = render_detailed(cairo, nagbar, max_height); + if (swaynag->details.visible) { + h = render_detailed(cairo, swaynag, max_height); max_height = h > max_height ? h : max_height; } - int border = NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; - if (max_height > nagbar->height) { + int border = SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; + if (max_height > swaynag->height) { max_height += border; } - cairo_set_source_u32(cairo, nagbar->type->border_bottom); - cairo_rectangle(cairo, 0, nagbar->height * nagbar->scale - border, - nagbar->width * nagbar->scale, border); + cairo_set_source_u32(cairo, swaynag->type->border_bottom); + cairo_rectangle(cairo, 0, swaynag->height * swaynag->scale - border, + swaynag->width * swaynag->scale, border); cairo_fill(cairo); return max_height; } -void render_frame(struct sway_nagbar *nagbar) { - if (!nagbar->run_display) { +void render_frame(struct swaynag *swaynag) { + if (!swaynag->run_display) { return; } @@ -261,24 +263,24 @@ void render_frame(struct sway_nagbar *nagbar) { cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); cairo_paint(cairo); cairo_restore(cairo); - uint32_t height = render_to_cairo(cairo, nagbar); - if (height != nagbar->height) { - zwlr_layer_surface_v1_set_size(nagbar->layer_surface, 0, height); - zwlr_layer_surface_v1_set_exclusive_zone(nagbar->layer_surface, + uint32_t height = render_to_cairo(cairo, swaynag); + if (height != swaynag->height) { + zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height); + zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface, height); - wl_surface_commit(nagbar->surface); - wl_display_roundtrip(nagbar->display); + wl_surface_commit(swaynag->surface); + wl_display_roundtrip(swaynag->display); } else { - nagbar->current_buffer = get_next_buffer(nagbar->shm, - nagbar->buffers, - nagbar->width * nagbar->scale, - nagbar->height * nagbar->scale); - if (!nagbar->current_buffer) { + swaynag->current_buffer = get_next_buffer(swaynag->shm, + swaynag->buffers, + swaynag->width * swaynag->scale, + swaynag->height * swaynag->scale); + if (!swaynag->current_buffer) { wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame."); goto cleanup; } - cairo_t *shm = nagbar->current_buffer->cairo; + cairo_t *shm = swaynag->current_buffer->cairo; cairo_save(shm); cairo_set_operator(shm, CAIRO_OPERATOR_CLEAR); cairo_paint(shm); @@ -286,13 +288,13 @@ void render_frame(struct sway_nagbar *nagbar) { cairo_set_source_surface(shm, recorder, 0.0, 0.0); cairo_paint(shm); - wl_surface_set_buffer_scale(nagbar->surface, nagbar->scale); - wl_surface_attach(nagbar->surface, - nagbar->current_buffer->buffer, 0, 0); - wl_surface_damage(nagbar->surface, 0, 0, - nagbar->width, nagbar->height); - wl_surface_commit(nagbar->surface); - wl_display_roundtrip(nagbar->display); + wl_surface_set_buffer_scale(swaynag->surface, swaynag->scale); + wl_surface_attach(swaynag->surface, + swaynag->current_buffer->buffer, 0, 0); + wl_surface_damage(swaynag->surface, 0, 0, + swaynag->width, swaynag->height); + wl_surface_commit(swaynag->surface); + wl_display_roundtrip(swaynag->display); } cleanup: -- cgit v1.2.3 From e01acb6097b583fcf2f6d0e0afe1bd878dd9b683 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sun, 29 Jul 2018 22:42:03 -0400 Subject: swaynag: allow more config options --- swaynag/render.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'swaynag/render.c') diff --git a/swaynag/render.c b/swaynag/render.c index 67e26eaf..bc3e520e 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -9,13 +9,13 @@ static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) { uint32_t height = swaynag->height * swaynag->scale; - height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; + height -= swaynag->type->bar_border_thickness * swaynag->scale; int text_width, text_height; - get_text_size(cairo, swaynag->font, &text_width, &text_height, + get_text_size(cairo, swaynag->type->font, &text_width, &text_height, swaynag->scale, true, "%s", swaynag->message); - int padding = SWAYNAG_MESSAGE_PADDING * swaynag->scale; + int padding = swaynag->type->message_padding * swaynag->scale; uint32_t ideal_height = text_height + padding * 2; uint32_t ideal_surface_height = ideal_height / swaynag->scale; @@ -25,7 +25,7 @@ static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) { cairo_set_source_u32(cairo, swaynag->type->text); cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); - pango_printf(cairo, swaynag->font, swaynag->scale, false, "%s", + pango_printf(cairo, swaynag->type->font, swaynag->scale, false, "%s", swaynag->message); return ideal_height; @@ -34,11 +34,11 @@ static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) { static void render_details_scroll_button(cairo_t *cairo, struct swaynag *swaynag, struct swaynag_button *button) { int text_width, text_height; - get_text_size(cairo, swaynag->font, &text_width, &text_height, + get_text_size(cairo, swaynag->type->font, &text_width, &text_height, swaynag->scale, true, "%s", button->text); - int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale; - int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale; + int border = swaynag->type->button_border_thickness * swaynag->scale; + int padding = swaynag->type->button_padding * swaynag->scale; cairo_set_source_u32(cairo, swaynag->type->border); cairo_rectangle(cairo, button->x, button->y, @@ -53,21 +53,21 @@ static void render_details_scroll_button(cairo_t *cairo, cairo_set_source_u32(cairo, swaynag->type->text); cairo_move_to(cairo, button->x + border + padding, button->y + border + (button->height - text_height) / 2); - pango_printf(cairo, swaynag->font, swaynag->scale, true, + pango_printf(cairo, swaynag->type->font, swaynag->scale, true, "%s", button->text); } static int get_detailed_scroll_button_width(cairo_t *cairo, struct swaynag *swaynag) { int up_width, down_width, temp_height; - get_text_size(cairo, swaynag->font, &up_width, &temp_height, + get_text_size(cairo, swaynag->type->font, &up_width, &temp_height, swaynag->scale, true, "%s", swaynag->details.button_up.text); - get_text_size(cairo, swaynag->font, &down_width, &temp_height, + get_text_size(cairo, swaynag->type->font, &down_width, &temp_height, swaynag->scale, true, "%s", swaynag->details.button_down.text); int text_width = up_width > down_width ? up_width : down_width; - int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale; - int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale; + int border = swaynag->type->button_border_thickness * swaynag->scale; + int padding = swaynag->type->button_padding * swaynag->scale; return text_width + border * 2 + padding * 2; } @@ -76,17 +76,17 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, uint32_t y) { uint32_t width = swaynag->width * swaynag->scale; uint32_t height = swaynag->height * swaynag->scale; - height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; + height -= swaynag->type->bar_border_thickness * swaynag->scale; - int border = SWAYNAG_DETAILS_BORDER_THICKNESS * swaynag->scale; - int padding = SWAYNAG_MESSAGE_PADDING * swaynag->scale; + int border = swaynag->type->details_border_thickness * swaynag->scale; + int padding = swaynag->type->message_padding * swaynag->scale; int decor = padding + border; swaynag->details.x = decor; swaynag->details.y = y + decor; swaynag->details.width = width - decor * 2; - PangoLayout *layout = get_pango_layout(cairo, swaynag->font, + PangoLayout *layout = get_pango_layout(cairo, swaynag->type->font, swaynag->details.message, swaynag->scale, false); pango_layout_set_width(layout, (swaynag->details.width - padding * 2) * PANGO_SCALE); @@ -173,15 +173,15 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, int button_index, int *x) { uint32_t height = swaynag->height * swaynag->scale; - height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; + height -= swaynag->type->bar_border_thickness * swaynag->scale; struct swaynag_button *button = swaynag->buttons->items[button_index]; int text_width, text_height; - get_text_size(cairo, swaynag->font, &text_width, &text_height, + get_text_size(cairo, swaynag->type->font, &text_width, &text_height, swaynag->scale, true, "%s", button->text); - int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale; - int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale; + int border = swaynag->type->button_border_thickness * swaynag->scale; + int padding = swaynag->type->button_padding * swaynag->scale; uint32_t ideal_height = text_height + padding * 2 + border * 2; uint32_t ideal_surface_height = ideal_height / swaynag->scale; @@ -206,7 +206,7 @@ static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, cairo_set_source_u32(cairo, swaynag->type->text); cairo_move_to(cairo, button->x + padding, button->y + padding); - pango_printf(cairo, swaynag->font, swaynag->scale, true, + pango_printf(cairo, swaynag->type->font, swaynag->scale, true, "%s", button->text); *x = button->x - border; @@ -224,13 +224,14 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { uint32_t h = render_message(cairo, swaynag); max_height = h > max_height ? h : max_height; - int x = (swaynag->width - SWAYNAG_BUTTON_MARGIN_RIGHT) * swaynag->scale; + int x = swaynag->width - swaynag->type->button_margin_right; + x *= swaynag->scale; for (int i = 0; i < swaynag->buttons->length; i++) { h = render_button(cairo, swaynag, i, &x); max_height = h > max_height ? h : max_height; - x -= SWAYNAG_BUTTON_GAP * swaynag->scale; + x -= swaynag->type->button_gap * swaynag->scale; if (i == 0) { - x -= SWAYNAG_BUTTON_GAP_CLOSE * swaynag->scale; + x -= swaynag->type->button_gap_close * swaynag->scale; } } @@ -239,7 +240,7 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { max_height = h > max_height ? h : max_height; } - int border = SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale; + int border = swaynag->type->bar_border_thickness * swaynag->scale; if (max_height > swaynag->height) { max_height += border; } -- cgit v1.2.3 From 0ef3988438c251c84251ef7a2723791856505065 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Mon, 30 Jul 2018 01:02:50 -0400 Subject: swaynag: fix hidpi --- swaynag/render.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'swaynag/render.c') diff --git a/swaynag/render.c b/swaynag/render.c index bc3e520e..766409e4 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -25,10 +25,10 @@ static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) { cairo_set_source_u32(cairo, swaynag->type->text); cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); - pango_printf(cairo, swaynag->type->font, swaynag->scale, false, "%s", - swaynag->message); + pango_printf(cairo, swaynag->type->font, swaynag->scale, false, + "%s", swaynag->message); - return ideal_height; + return ideal_surface_height; } static void render_details_scroll_button(cairo_t *cairo, @@ -61,9 +61,11 @@ static int get_detailed_scroll_button_width(cairo_t *cairo, struct swaynag *swaynag) { int up_width, down_width, temp_height; get_text_size(cairo, swaynag->type->font, &up_width, &temp_height, - swaynag->scale, true, "%s", swaynag->details.button_up.text); + swaynag->scale, true, + "%s", swaynag->details.button_up.text); get_text_size(cairo, swaynag->type->font, &down_width, &temp_height, - swaynag->scale, true, "%s", swaynag->details.button_down.text); + swaynag->scale, true, + "%s", swaynag->details.button_down.text); int text_width = up_width > down_width ? up_width : down_width; int border = swaynag->type->button_border_thickness * swaynag->scale; @@ -83,7 +85,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, int decor = padding + border; swaynag->details.x = decor; - swaynag->details.y = y + decor; + swaynag->details.y = y * swaynag->scale + decor; swaynag->details.width = width - decor * 2; PangoLayout *layout = get_pango_layout(cairo, swaynag->type->font, @@ -167,7 +169,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, pango_cairo_show_layout(cairo, layout); g_object_unref(layout); - return ideal_height; + return ideal_height / swaynag->scale; } static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, @@ -211,7 +213,7 @@ static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, *x = button->x - border; - return ideal_height; + return ideal_surface_height; } static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { @@ -245,8 +247,10 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { max_height += border; } cairo_set_source_u32(cairo, swaynag->type->border_bottom); - cairo_rectangle(cairo, 0, swaynag->height * swaynag->scale - border, - swaynag->width * swaynag->scale, border); + cairo_rectangle(cairo, 0, + swaynag->height * swaynag->scale - border, + swaynag->width * swaynag->scale, + border); cairo_fill(cairo); return max_height; -- cgit v1.2.3