aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/render.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-28 23:15:12 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-08-01 22:47:54 -0400
commita6145914c60351d8e541192c7fe35556f8e02507 (patch)
tree8bb5cacc6e91ed4483c8a4fd0b903aacb76abf15 /swaynag/render.c
parentswaynag: split config into own file and fix optind (diff)
downloadsway-a6145914c60351d8e541192c7fe35556f8e02507.tar.gz
sway-a6145914c60351d8e541192c7fe35556f8e02507.tar.zst
sway-a6145914c60351d8e541192c7fe35556f8e02507.zip
swaynag: refactor {sway_,}nagbar to swaynag
Diffstat (limited to 'swaynag/render.c')
-rw-r--r--swaynag/render.c256
1 files changed, 129 insertions, 127 deletions
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 @@
3#include "log.h" 3#include "log.h"
4#include "pango.h" 4#include "pango.h"
5#include "pool-buffer.h" 5#include "pool-buffer.h"
6#include "swaynag/nagbar.h" 6#include "swaynag/swaynag.h"
7#include "swaynag/types.h" 7#include "swaynag/types.h"
8#include "wlr-layer-shell-unstable-v1-client-protocol.h" 8#include "wlr-layer-shell-unstable-v1-client-protocol.h"
9 9
10static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { 10static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) {
11 uint32_t height = nagbar->height * nagbar->scale; 11 uint32_t height = swaynag->height * swaynag->scale;
12 height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; 12 height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale;
13 13
14 int text_width, text_height; 14 int text_width, text_height;
15 get_text_size(cairo, nagbar->font, &text_width, &text_height, 15 get_text_size(cairo, swaynag->font, &text_width, &text_height,
16 nagbar->scale, true, "%s", nagbar->message); 16 swaynag->scale, true, "%s", swaynag->message);
17 17
18 int padding = NAGBAR_MESSAGE_PADDING * nagbar->scale; 18 int padding = SWAYNAG_MESSAGE_PADDING * swaynag->scale;
19 19
20 uint32_t ideal_height = text_height + padding * 2; 20 uint32_t ideal_height = text_height + padding * 2;
21 uint32_t ideal_surface_height = ideal_height / nagbar->scale; 21 uint32_t ideal_surface_height = ideal_height / swaynag->scale;
22 if (nagbar->height < ideal_surface_height) { 22 if (swaynag->height < ideal_surface_height) {
23 return ideal_surface_height; 23 return ideal_surface_height;
24 } 24 }
25 25
26 cairo_set_source_u32(cairo, nagbar->type->text); 26 cairo_set_source_u32(cairo, swaynag->type->text);
27 cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); 27 cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2);
28 pango_printf(cairo, nagbar->font, nagbar->scale, false, "%s", 28 pango_printf(cairo, swaynag->font, swaynag->scale, false, "%s",
29 nagbar->message); 29 swaynag->message);
30 30
31 return ideal_height; 31 return ideal_height;
32} 32}
33 33
34static void render_details_scroll_button(cairo_t *cairo, 34static void render_details_scroll_button(cairo_t *cairo,
35 struct sway_nagbar *nagbar, struct sway_nagbar_button *button) { 35 struct swaynag *swaynag, struct swaynag_button *button) {
36 int text_width, text_height; 36 int text_width, text_height;
37 get_text_size(cairo, nagbar->font, &text_width, &text_height, 37 get_text_size(cairo, swaynag->font, &text_width, &text_height,
38 nagbar->scale, true, "%s", button->text); 38 swaynag->scale, true, "%s", button->text);
39 39
40 int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; 40 int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale;
41 int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; 41 int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale;
42 42
43 cairo_set_source_u32(cairo, nagbar->type->border); 43 cairo_set_source_u32(cairo, swaynag->type->border);
44 cairo_rectangle(cairo, button->x, button->y, 44 cairo_rectangle(cairo, button->x, button->y,
45 button->width, button->height); 45 button->width, button->height);
46 cairo_fill(cairo); 46 cairo_fill(cairo);
47 47
48 cairo_set_source_u32(cairo, nagbar->type->button_background); 48 cairo_set_source_u32(cairo, swaynag->type->button_background);
49 cairo_rectangle(cairo, button->x + border, button->y + border, 49 cairo_rectangle(cairo, button->x + border, button->y + border,
50 button->width - (border * 2), button->height - (border * 2)); 50 button->width - (border * 2), button->height - (border * 2));
51 cairo_fill(cairo); 51 cairo_fill(cairo);
52 52
53 cairo_set_source_u32(cairo, nagbar->type->text); 53 cairo_set_source_u32(cairo, swaynag->type->text);
54 cairo_move_to(cairo, button->x + border + padding, 54 cairo_move_to(cairo, button->x + border + padding,
55 button->y + border + (button->height - text_height) / 2); 55 button->y + border + (button->height - text_height) / 2);
56 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); 56 pango_printf(cairo, swaynag->font, swaynag->scale, true,
57 "%s", button->text);
57} 58}
58 59
59static int get_detailed_scroll_button_width(cairo_t *cairo, 60static int get_detailed_scroll_button_width(cairo_t *cairo,
60 struct sway_nagbar *nagbar) { 61 struct swaynag *swaynag) {
61 int up_width, down_width, temp_height; 62 int up_width, down_width, temp_height;
62 get_text_size(cairo, nagbar->font, &up_width, &temp_height, 63 get_text_size(cairo, swaynag->font, &up_width, &temp_height,
63 nagbar->scale, true, "%s", nagbar->details.button_up.text); 64 swaynag->scale, true, "%s", swaynag->details.button_up.text);
64 get_text_size(cairo, nagbar->font, &down_width, &temp_height, 65 get_text_size(cairo, swaynag->font, &down_width, &temp_height,
65 nagbar->scale, true, "%s", nagbar->details.button_down.text); 66 swaynag->scale, true, "%s", swaynag->details.button_down.text);
66 67
67 int text_width = up_width > down_width ? up_width : down_width; 68 int text_width = up_width > down_width ? up_width : down_width;
68 int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; 69 int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale;
69 int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; 70 int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale;
70 71
71 return text_width + border * 2 + padding * 2; 72 return text_width + border * 2 + padding * 2;
72} 73}
73 74
74static uint32_t render_detailed(cairo_t *cairo, struct sway_nagbar *nagbar, 75static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag,
75 uint32_t y) { 76 uint32_t y) {
76 uint32_t width = nagbar->width * nagbar->scale; 77 uint32_t width = swaynag->width * swaynag->scale;
77 uint32_t height = nagbar->height * nagbar->scale; 78 uint32_t height = swaynag->height * swaynag->scale;
78 height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; 79 height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale;
79 80
80 int border = NAGBAR_DETAILS_BORDER_THICKNESS * nagbar->scale; 81 int border = SWAYNAG_DETAILS_BORDER_THICKNESS * swaynag->scale;
81 int padding = NAGBAR_MESSAGE_PADDING * nagbar->scale; 82 int padding = SWAYNAG_MESSAGE_PADDING * swaynag->scale;
82 int decor = padding + border; 83 int decor = padding + border;
83 84
84 nagbar->details.x = decor; 85 swaynag->details.x = decor;
85 nagbar->details.y = y + decor; 86 swaynag->details.y = y + decor;
86 nagbar->details.width = width - decor * 2; 87 swaynag->details.width = width - decor * 2;
87 88
88 PangoLayout *layout = get_pango_layout(cairo, nagbar->font, 89 PangoLayout *layout = get_pango_layout(cairo, swaynag->font,
89 nagbar->details.message, nagbar->scale, false); 90 swaynag->details.message, swaynag->scale, false);
90 pango_layout_set_width(layout, 91 pango_layout_set_width(layout,
91 (nagbar->details.width - padding * 2) * PANGO_SCALE); 92 (swaynag->details.width - padding * 2) * PANGO_SCALE);
92 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); 93 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
93 pango_layout_set_single_paragraph_mode(layout, false); 94 pango_layout_set_single_paragraph_mode(layout, false);
94 pango_cairo_update_layout(cairo, layout); 95 pango_cairo_update_layout(cairo, layout);
95 nagbar->details.total_lines = pango_layout_get_line_count(layout); 96 swaynag->details.total_lines = pango_layout_get_line_count(layout);
96 97
97 PangoLayoutLine *line; 98 PangoLayoutLine *line;
98 line = pango_layout_get_line_readonly(layout, nagbar->details.offset); 99 line = pango_layout_get_line_readonly(layout, swaynag->details.offset);
99 gint offset = line->start_index; 100 gint offset = line->start_index;
100 const char *text = pango_layout_get_text(layout); 101 const char *text = pango_layout_get_text(layout);
101 pango_layout_set_text(layout, text + offset, strlen(text) - offset); 102 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,
104 pango_cairo_update_layout(cairo, layout); 105 pango_cairo_update_layout(cairo, layout);
105 pango_layout_get_pixel_size(layout, &text_width, &text_height); 106 pango_layout_get_pixel_size(layout, &text_width, &text_height);
106 107
107 bool show_buttons = nagbar->details.offset > 0; 108 bool show_buttons = swaynag->details.offset > 0;
108 int button_width = get_detailed_scroll_button_width(cairo, nagbar); 109 int button_width = get_detailed_scroll_button_width(cairo, swaynag);
109 if (show_buttons) { 110 if (show_buttons) {
110 nagbar->details.width -= button_width; 111 swaynag->details.width -= button_width;
111 pango_layout_set_width(layout, 112 pango_layout_set_width(layout,
112 (nagbar->details.width - padding * 2) * PANGO_SCALE); 113 (swaynag->details.width - padding * 2) * PANGO_SCALE);
113 } 114 }
114 115
115 uint32_t ideal_height; 116 uint32_t ideal_height;
116 do { 117 do {
117 ideal_height = nagbar->details.y + text_height + decor + padding * 2; 118 ideal_height = swaynag->details.y + text_height + decor + padding * 2;
118 if (ideal_height > NAGBAR_MAX_HEIGHT) { 119 if (ideal_height > SWAYNAG_MAX_HEIGHT) {
119 ideal_height = NAGBAR_MAX_HEIGHT; 120 ideal_height = SWAYNAG_MAX_HEIGHT;
120 121
121 if (!show_buttons) { 122 if (!show_buttons) {
122 show_buttons = true; 123 show_buttons = true;
123 nagbar->details.width -= button_width; 124 swaynag->details.width -= button_width;
124 pango_layout_set_width(layout, 125 pango_layout_set_width(layout,
125 (nagbar->details.width - padding * 2) * PANGO_SCALE); 126 (swaynag->details.width - padding * 2) * PANGO_SCALE);
126 } 127 }
127 } 128 }
128 129
129 nagbar->details.height = ideal_height - nagbar->details.y - decor; 130 swaynag->details.height = ideal_height - swaynag->details.y - decor;
130 pango_layout_set_height(layout, 131 pango_layout_set_height(layout,
131 (nagbar->details.height - padding * 2) * PANGO_SCALE); 132 (swaynag->details.height - padding * 2) * PANGO_SCALE);
132 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); 133 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
133 pango_cairo_update_layout(cairo, layout); 134 pango_cairo_update_layout(cairo, layout);
134 pango_layout_get_pixel_size(layout, &text_width, &text_height); 135 pango_layout_get_pixel_size(layout, &text_width, &text_height);
135 } while (text_height != (nagbar->details.height - padding * 2)); 136 } while (text_height != (swaynag->details.height - padding * 2));
136 137
137 nagbar->details.visible_lines = pango_layout_get_line_count(layout); 138 swaynag->details.visible_lines = pango_layout_get_line_count(layout);
138 139
139 if (show_buttons) { 140 if (show_buttons) {
140 nagbar->details.button_up.x = 141 swaynag->details.button_up.x =
141 nagbar->details.x + nagbar->details.width; 142 swaynag->details.x + swaynag->details.width;
142 nagbar->details.button_up.y = nagbar->details.y; 143 swaynag->details.button_up.y = swaynag->details.y;
143 nagbar->details.button_up.width = button_width; 144 swaynag->details.button_up.width = button_width;
144 nagbar->details.button_up.height = nagbar->details.height / 2; 145 swaynag->details.button_up.height = swaynag->details.height / 2;
145 render_details_scroll_button(cairo, nagbar, 146 render_details_scroll_button(cairo, swaynag,
146 &nagbar->details.button_up); 147 &swaynag->details.button_up);
147 148
148 nagbar->details.button_down.x = 149 swaynag->details.button_down.x =
149 nagbar->details.x + nagbar->details.width; 150 swaynag->details.x + swaynag->details.width;
150 nagbar->details.button_down.y = 151 swaynag->details.button_down.y =
151 nagbar->details.button_up.y + nagbar->details.button_up.height; 152 swaynag->details.button_up.y + swaynag->details.button_up.height;
152 nagbar->details.button_down.width = button_width; 153 swaynag->details.button_down.width = button_width;
153 nagbar->details.button_down.height = nagbar->details.height / 2; 154 swaynag->details.button_down.height = swaynag->details.height / 2;
154 render_details_scroll_button(cairo, nagbar, 155 render_details_scroll_button(cairo, swaynag,
155 &nagbar->details.button_down); 156 &swaynag->details.button_down);
156 } 157 }
157 158
158 cairo_set_source_u32(cairo, nagbar->type->border); 159 cairo_set_source_u32(cairo, swaynag->type->border);
159 cairo_rectangle(cairo, nagbar->details.x, nagbar->details.y, 160 cairo_rectangle(cairo, swaynag->details.x, swaynag->details.y,
160 nagbar->details.width, nagbar->details.height); 161 swaynag->details.width, swaynag->details.height);
161 cairo_fill(cairo); 162 cairo_fill(cairo);
162 163
163 cairo_move_to(cairo, nagbar->details.x + padding, 164 cairo_move_to(cairo, swaynag->details.x + padding,
164 nagbar->details.y + padding); 165 swaynag->details.y + padding);
165 cairo_set_source_u32(cairo, nagbar->type->text); 166 cairo_set_source_u32(cairo, swaynag->type->text);
166 pango_cairo_show_layout(cairo, layout); 167 pango_cairo_show_layout(cairo, layout);
167 g_object_unref(layout); 168 g_object_unref(layout);
168 169
169 return ideal_height; 170 return ideal_height;
170} 171}
171 172
172static uint32_t render_button(cairo_t *cairo, struct sway_nagbar *nagbar, 173static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag,
173 int button_index, int *x) { 174 int button_index, int *x) {
174 uint32_t height = nagbar->height * nagbar->scale; 175 uint32_t height = swaynag->height * swaynag->scale;
175 height -= NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; 176 height -= SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale;
176 struct sway_nagbar_button *button = nagbar->buttons->items[button_index]; 177 struct swaynag_button *button = swaynag->buttons->items[button_index];
177 178
178 int text_width, text_height; 179 int text_width, text_height;
179 get_text_size(cairo, nagbar->font, &text_width, &text_height, 180 get_text_size(cairo, swaynag->font, &text_width, &text_height,
180 nagbar->scale, true, "%s", button->text); 181 swaynag->scale, true, "%s", button->text);
181 182
182 int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; 183 int border = SWAYNAG_BUTTON_BORDER_THICKNESS * swaynag->scale;
183 int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; 184 int padding = SWAYNAG_BUTTON_PADDING * swaynag->scale;
184 185
185 uint32_t ideal_height = text_height + padding * 2 + border * 2; 186 uint32_t ideal_height = text_height + padding * 2 + border * 2;
186 uint32_t ideal_surface_height = ideal_height / nagbar->scale; 187 uint32_t ideal_surface_height = ideal_height / swaynag->scale;
187 if (nagbar->height < ideal_surface_height) { 188 if (swaynag->height < ideal_surface_height) {
188 return ideal_surface_height; 189 return ideal_surface_height;
189 } 190 }
190 191
@@ -193,64 +194,65 @@ static uint32_t render_button(cairo_t *cairo, struct sway_nagbar *nagbar,
193 button->width = text_width + padding * 2; 194 button->width = text_width + padding * 2;
194 button->height = text_height + padding * 2; 195 button->height = text_height + padding * 2;
195 196
196 cairo_set_source_u32(cairo, nagbar->type->border); 197 cairo_set_source_u32(cairo, swaynag->type->border);
197 cairo_rectangle(cairo, button->x - border, button->y - border, 198 cairo_rectangle(cairo, button->x - border, button->y - border,
198 button->width + border * 2, button->height + border * 2); 199 button->width + border * 2, button->height + border * 2);
199 cairo_fill(cairo); 200 cairo_fill(cairo);
200 201
201 cairo_set_source_u32(cairo, nagbar->type->button_background); 202 cairo_set_source_u32(cairo, swaynag->type->button_background);
202 cairo_rectangle(cairo, button->x, button->y, 203 cairo_rectangle(cairo, button->x, button->y,
203 button->width, button->height); 204 button->width, button->height);
204 cairo_fill(cairo); 205 cairo_fill(cairo);
205 206
206 cairo_set_source_u32(cairo, nagbar->type->text); 207 cairo_set_source_u32(cairo, swaynag->type->text);
207 cairo_move_to(cairo, button->x + padding, button->y + padding); 208 cairo_move_to(cairo, button->x + padding, button->y + padding);
208 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); 209 pango_printf(cairo, swaynag->font, swaynag->scale, true,
210 "%s", button->text);
209 211
210 *x = button->x - border; 212 *x = button->x - border;
211 213
212 return ideal_height; 214 return ideal_height;
213} 215}
214 216
215static uint32_t render_to_cairo(cairo_t *cairo, struct sway_nagbar *nagbar) { 217static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) {
216 uint32_t max_height = 0; 218 uint32_t max_height = 0;
217 219
218 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); 220 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
219 cairo_set_source_u32(cairo, nagbar->type->background); 221 cairo_set_source_u32(cairo, swaynag->type->background);
220 cairo_paint(cairo); 222 cairo_paint(cairo);
221 223
222 uint32_t h = render_message(cairo, nagbar); 224 uint32_t h = render_message(cairo, swaynag);
223 max_height = h > max_height ? h : max_height; 225 max_height = h > max_height ? h : max_height;
224 226
225 int x = (nagbar->width - NAGBAR_BUTTON_MARGIN_RIGHT) * nagbar->scale; 227 int x = (swaynag->width - SWAYNAG_BUTTON_MARGIN_RIGHT) * swaynag->scale;
226 for (int i = 0; i < nagbar->buttons->length; i++) { 228 for (int i = 0; i < swaynag->buttons->length; i++) {
227 h = render_button(cairo, nagbar, i, &x); 229 h = render_button(cairo, swaynag, i, &x);
228 max_height = h > max_height ? h : max_height; 230 max_height = h > max_height ? h : max_height;
229 x -= NAGBAR_BUTTON_GAP * nagbar->scale; 231 x -= SWAYNAG_BUTTON_GAP * swaynag->scale;
230 if (i == 0) { 232 if (i == 0) {
231 x -= NAGBAR_BUTTON_GAP_CLOSE * nagbar->scale; 233 x -= SWAYNAG_BUTTON_GAP_CLOSE * swaynag->scale;
232 } 234 }
233 } 235 }
234 236
235 if (nagbar->details.visible) { 237 if (swaynag->details.visible) {
236 h = render_detailed(cairo, nagbar, max_height); 238 h = render_detailed(cairo, swaynag, max_height);
237 max_height = h > max_height ? h : max_height; 239 max_height = h > max_height ? h : max_height;
238 } 240 }
239 241
240 int border = NAGBAR_BAR_BORDER_THICKNESS * nagbar->scale; 242 int border = SWAYNAG_BAR_BORDER_THICKNESS * swaynag->scale;
241 if (max_height > nagbar->height) { 243 if (max_height > swaynag->height) {
242 max_height += border; 244 max_height += border;
243 } 245 }
244 cairo_set_source_u32(cairo, nagbar->type->border_bottom); 246 cairo_set_source_u32(cairo, swaynag->type->border_bottom);
245 cairo_rectangle(cairo, 0, nagbar->height * nagbar->scale - border, 247 cairo_rectangle(cairo, 0, swaynag->height * swaynag->scale - border,
246 nagbar->width * nagbar->scale, border); 248 swaynag->width * swaynag->scale, border);
247 cairo_fill(cairo); 249 cairo_fill(cairo);
248 250
249 return max_height; 251 return max_height;
250} 252}
251 253
252void render_frame(struct sway_nagbar *nagbar) { 254void render_frame(struct swaynag *swaynag) {
253 if (!nagbar->run_display) { 255 if (!swaynag->run_display) {
254 return; 256 return;
255 } 257 }
256 258
@@ -261,24 +263,24 @@ void render_frame(struct sway_nagbar *nagbar) {
261 cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); 263 cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
262 cairo_paint(cairo); 264 cairo_paint(cairo);
263 cairo_restore(cairo); 265 cairo_restore(cairo);
264 uint32_t height = render_to_cairo(cairo, nagbar); 266 uint32_t height = render_to_cairo(cairo, swaynag);
265 if (height != nagbar->height) { 267 if (height != swaynag->height) {
266 zwlr_layer_surface_v1_set_size(nagbar->layer_surface, 0, height); 268 zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height);
267 zwlr_layer_surface_v1_set_exclusive_zone(nagbar->layer_surface, 269 zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface,
268 height); 270 height);
269 wl_surface_commit(nagbar->surface); 271 wl_surface_commit(swaynag->surface);
270 wl_display_roundtrip(nagbar->display); 272 wl_display_roundtrip(swaynag->display);
271 } else { 273 } else {
272 nagbar->current_buffer = get_next_buffer(nagbar->shm, 274 swaynag->current_buffer = get_next_buffer(swaynag->shm,
273 nagbar->buffers, 275 swaynag->buffers,
274 nagbar->width * nagbar->scale, 276 swaynag->width * swaynag->scale,
275 nagbar->height * nagbar->scale); 277 swaynag->height * swaynag->scale);
276 if (!nagbar->current_buffer) { 278 if (!swaynag->current_buffer) {
277 wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame."); 279 wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame.");
278 goto cleanup; 280 goto cleanup;
279 } 281 }
280 282
281 cairo_t *shm = nagbar->current_buffer->cairo; 283 cairo_t *shm = swaynag->current_buffer->cairo;
282 cairo_save(shm); 284 cairo_save(shm);
283 cairo_set_operator(shm, CAIRO_OPERATOR_CLEAR); 285 cairo_set_operator(shm, CAIRO_OPERATOR_CLEAR);
284 cairo_paint(shm); 286 cairo_paint(shm);
@@ -286,13 +288,13 @@ void render_frame(struct sway_nagbar *nagbar) {
286 cairo_set_source_surface(shm, recorder, 0.0, 0.0); 288 cairo_set_source_surface(shm, recorder, 0.0, 0.0);
287 cairo_paint(shm); 289 cairo_paint(shm);
288 290
289 wl_surface_set_buffer_scale(nagbar->surface, nagbar->scale); 291 wl_surface_set_buffer_scale(swaynag->surface, swaynag->scale);
290 wl_surface_attach(nagbar->surface, 292 wl_surface_attach(swaynag->surface,
291 nagbar->current_buffer->buffer, 0, 0); 293 swaynag->current_buffer->buffer, 0, 0);
292 wl_surface_damage(nagbar->surface, 0, 0, 294 wl_surface_damage(swaynag->surface, 0, 0,
293 nagbar->width, nagbar->height); 295 swaynag->width, swaynag->height);
294 wl_surface_commit(nagbar->surface); 296 wl_surface_commit(swaynag->surface);
295 wl_display_roundtrip(nagbar->display); 297 wl_display_roundtrip(swaynag->display);
296 } 298 }
297 299
298cleanup: 300cleanup: