aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-09-17 13:31:24 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-09-18 11:36:33 +0100
commitbabd9618b93987665c11ff268463b344da698744 (patch)
tree490583f3d97985f9eb8de241c8fd7f90fbbe7c47 /swaybar/render.c
parentswaybar: send trailing comma with click event json (diff)
downloadsway-babd9618b93987665c11ff268463b344da698744.tar.gz
sway-babd9618b93987665c11ff268463b344da698744.tar.zst
sway-babd9618b93987665c11ff268463b344da698744.zip
swaybar: only create i3bar block hotspot if click events are enabled
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..b2c1c710 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->i3bar_state.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;