summaryrefslogtreecommitdiff
path: root/swaybar/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index 2d848bfa..26db80cb 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L
+#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <stdint.h>
@@ -120,14 +121,14 @@ static void i3bar_block_unref_callback(void *data) {
}
static uint32_t render_status_block(cairo_t *cairo,
- struct swaybar_config *config, struct swaybar_output *output,
- struct i3bar_block *block, double *x,
+ struct swaybar_output *output, struct i3bar_block *block, double *x,
uint32_t surface_height, bool focused, bool edge) {
if (!block->full_text || !*block->full_text) {
return 0;
}
uint32_t height = surface_height * output->scale;
+ struct swaybar_config *config = output->bar->config;
int text_width, text_height;
get_text_size(cairo, config->font, &text_width, &text_height, NULL,
@@ -177,16 +178,18 @@ static uint32_t render_status_block(cairo_t *cairo,
*x -= margin;
}
- struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
- hotspot->x = *x;
- hotspot->y = 0;
- hotspot->width = width;
- hotspot->height = height;
- hotspot->callback = block_hotspot_callback;
- hotspot->destroy = i3bar_block_unref_callback;
- hotspot->data = block;
- block->ref_count++;
- wl_list_insert(&output->hotspots, &hotspot->link);
+ if (output->bar->status->click_events) {
+ struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
+ hotspot->x = *x;
+ hotspot->y = 0;
+ hotspot->width = width;
+ hotspot->height = height;
+ hotspot->callback = block_hotspot_callback;
+ hotspot->destroy = i3bar_block_unref_callback;
+ hotspot->data = block;
+ block->ref_count++;
+ wl_list_insert(&output->hotspots, &hotspot->link);
+ }
double pos = *x;
if (block->background) {
@@ -268,7 +271,7 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo,
bool edge = true;
struct i3bar_block *block;
wl_list_for_each(block, &status->blocks, link) {
- uint32_t h = render_status_block(cairo, config, output,
+ uint32_t h = render_status_block(cairo, output,
block, x, surface_height, focused, edge);
max_height = h > max_height ? h : max_height;
edge = false;
@@ -478,6 +481,8 @@ static uint32_t render_to_cairo(cairo_t *cairo,
}
void render_frame(struct swaybar *bar, struct swaybar_output *output) {
+ assert(output->surface != NULL);
+
struct swaybar_hotspot *hotspot, *tmp;
wl_list_for_each_safe(hotspot, tmp, &output->hotspots, link) {
if (hotspot->destroy) {
@@ -505,7 +510,6 @@ void render_frame(struct swaybar *bar, struct swaybar_output *output) {
// TODO: this could infinite loop if the compositor assigns us a
// different height than what we asked for
wl_surface_commit(output->surface);
- wl_display_roundtrip(bar->display);
} else if (height > 0) {
// Replay recording into shm and send it off
output->current_buffer = get_next_buffer(bar->shm,
@@ -531,7 +535,6 @@ void render_frame(struct swaybar *bar, struct swaybar_output *output) {
wl_surface_damage(output->surface, 0, 0,
output->width, output->height);
wl_surface_commit(output->surface);
- wl_display_roundtrip(bar->display);
}
cairo_surface_destroy(recorder);
cairo_destroy(cairo);