mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
swaybar: only create i3bar block hotspot if click events are enabled
This commit is contained in:
parent
87c93d6ad9
commit
babd9618b9
|
@ -120,14 +120,14 @@ static void i3bar_block_unref_callback(void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t render_status_block(cairo_t *cairo,
|
static uint32_t render_status_block(cairo_t *cairo,
|
||||||
struct swaybar_config *config, struct swaybar_output *output,
|
struct swaybar_output *output, struct i3bar_block *block, double *x,
|
||||||
struct i3bar_block *block, double *x,
|
|
||||||
uint32_t surface_height, bool focused, bool edge) {
|
uint32_t surface_height, bool focused, bool edge) {
|
||||||
if (!block->full_text || !*block->full_text) {
|
if (!block->full_text || !*block->full_text) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t height = surface_height * output->scale;
|
uint32_t height = surface_height * output->scale;
|
||||||
|
struct swaybar_config *config = output->bar->config;
|
||||||
|
|
||||||
int text_width, text_height;
|
int text_width, text_height;
|
||||||
get_text_size(cairo, config->font, &text_width, &text_height, NULL,
|
get_text_size(cairo, config->font, &text_width, &text_height, NULL,
|
||||||
|
@ -177,16 +177,18 @@ static uint32_t render_status_block(cairo_t *cairo,
|
||||||
*x -= margin;
|
*x -= margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
|
if (output->bar->status->i3bar_state.click_events) {
|
||||||
hotspot->x = *x;
|
struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
|
||||||
hotspot->y = 0;
|
hotspot->x = *x;
|
||||||
hotspot->width = width;
|
hotspot->y = 0;
|
||||||
hotspot->height = height;
|
hotspot->width = width;
|
||||||
hotspot->callback = block_hotspot_callback;
|
hotspot->height = height;
|
||||||
hotspot->destroy = i3bar_block_unref_callback;
|
hotspot->callback = block_hotspot_callback;
|
||||||
hotspot->data = block;
|
hotspot->destroy = i3bar_block_unref_callback;
|
||||||
block->ref_count++;
|
hotspot->data = block;
|
||||||
wl_list_insert(&output->hotspots, &hotspot->link);
|
block->ref_count++;
|
||||||
|
wl_list_insert(&output->hotspots, &hotspot->link);
|
||||||
|
}
|
||||||
|
|
||||||
double pos = *x;
|
double pos = *x;
|
||||||
if (block->background) {
|
if (block->background) {
|
||||||
|
@ -268,7 +270,7 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo,
|
||||||
bool edge = true;
|
bool edge = true;
|
||||||
struct i3bar_block *block;
|
struct i3bar_block *block;
|
||||||
wl_list_for_each(block, &status->blocks, link) {
|
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);
|
block, x, surface_height, focused, edge);
|
||||||
max_height = h > max_height ? h : max_height;
|
max_height = h > max_height ? h : max_height;
|
||||||
edge = false;
|
edge = false;
|
||||||
|
|
Loading…
Reference in a new issue