aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <RyanDwyer@users.noreply.github.com>2018-09-21 20:05:39 +1000
committerLibravatar GitHub <noreply@github.com>2018-09-21 20:05:39 +1000
commit0798fadff2f2f74a7efd7c14c55737bac19de954 (patch)
tree86e1ab4983fec3586a8bbb0044216216e22cc1cb /swaybar/render.c
parentFix segfault in output_render (diff)
parentMerge pull request #2671 from emersion/output-execute-no-focus (diff)
downloadsway-0798fadff2f2f74a7efd7c14c55737bac19de954.tar.gz
sway-0798fadff2f2f74a7efd7c14c55737bac19de954.tar.zst
sway-0798fadff2f2f74a7efd7c14c55737bac19de954.zip
Merge branch 'master' into render-output-segfault
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index 2d848bfa..97690338 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -120,14 +120,14 @@ static void i3bar_block_unref_callback(void *data) {
120} 120}
121 121
122static uint32_t render_status_block(cairo_t *cairo, 122static uint32_t render_status_block(cairo_t *cairo,
123 struct swaybar_config *config, struct swaybar_output *output, 123 struct swaybar_output *output, struct i3bar_block *block, double *x,
124 struct i3bar_block *block, double *x,
125 uint32_t surface_height, bool focused, bool edge) { 124 uint32_t surface_height, bool focused, bool edge) {
126 if (!block->full_text || !*block->full_text) { 125 if (!block->full_text || !*block->full_text) {
127 return 0; 126 return 0;
128 } 127 }
129 128
130 uint32_t height = surface_height * output->scale; 129 uint32_t height = surface_height * output->scale;
130 struct swaybar_config *config = output->bar->config;
131 131
132 int text_width, text_height; 132 int text_width, text_height;
133 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 133 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
@@ -177,16 +177,18 @@ static uint32_t render_status_block(cairo_t *cairo,
177 *x -= margin; 177 *x -= margin;
178 } 178 }
179 179
180 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); 180 if (output->bar->status->click_events) {
181 hotspot->x = *x; 181 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
182 hotspot->y = 0; 182 hotspot->x = *x;
183 hotspot->width = width; 183 hotspot->y = 0;
184 hotspot->height = height; 184 hotspot->width = width;
185 hotspot->callback = block_hotspot_callback; 185 hotspot->height = height;
186 hotspot->destroy = i3bar_block_unref_callback; 186 hotspot->callback = block_hotspot_callback;
187 hotspot->data = block; 187 hotspot->destroy = i3bar_block_unref_callback;
188 block->ref_count++; 188 hotspot->data = block;
189 wl_list_insert(&output->hotspots, &hotspot->link); 189 block->ref_count++;
190 wl_list_insert(&output->hotspots, &hotspot->link);
191 }
190 192
191 double pos = *x; 193 double pos = *x;
192 if (block->background) { 194 if (block->background) {
@@ -268,7 +270,7 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo,
268 bool edge = true; 270 bool edge = true;
269 struct i3bar_block *block; 271 struct i3bar_block *block;
270 wl_list_for_each(block, &status->blocks, link) { 272 wl_list_for_each(block, &status->blocks, link) {
271 uint32_t h = render_status_block(cairo, config, output, 273 uint32_t h = render_status_block(cairo, output,
272 block, x, surface_height, focused, edge); 274 block, x, surface_height, focused, edge);
273 max_height = h > max_height ? h : max_height; 275 max_height = h > max_height ? h : max_height;
274 edge = false; 276 edge = false;