swaybar: set bar dirty on SNI event

master
Ian Fan 6 years ago
parent 6becde0246
commit 2fd41fe9c8

@ -88,6 +88,8 @@ bool bar_setup(struct swaybar *bar, const char *socket_path);
void bar_run(struct swaybar *bar);
void bar_teardown(struct swaybar *bar);
void set_bar_dirty(struct swaybar *bar);
/*
* Determines whether the bar should be visible and changes it to be so.
* If the current visibility of the bar is the different to what it should be,

@ -124,7 +124,7 @@ static void destroy_layer_surface(struct swaybar_output *output) {
output->frame_scheduled = false;
}
static void set_bar_dirty(struct swaybar *bar) {
void set_bar_dirty(struct swaybar *bar) {
struct swaybar_output *output;
wl_list_for_each(output, &bar->outputs, link) {
set_output_dirty(output);

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "swaybar/bar.h"
#include "swaybar/tray/host.h"
#include "swaybar/tray/item.h"
#include "swaybar/tray/tray.h"
@ -56,6 +57,7 @@ static int handle_sni_unregistered(sd_bus_message *msg, void *data,
wlr_log(WLR_DEBUG, "Unregistering Status Notifier Item '%s'", id);
destroy_sni(tray->items->items[idx]);
list_del(tray->items, idx);
set_bar_dirty(tray->bar);
}
return ret;
}

@ -24,6 +24,13 @@ static bool sni_ready(struct swaybar_sni *sni) {
sni->icon_name || sni->icon_pixmap);
}
static void set_sni_dirty(struct swaybar_sni *sni) {
if (sni_ready(sni)) {
sni->min_size = sni->max_size = 0; // invalidate previous icon
set_bar_dirty(sni->tray->bar);
}
}
static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
const char *prop, list_t **dest) {
int ret = sd_bus_message_enter_container(msg, 'a', "(iiay)");
@ -124,6 +131,11 @@ static int get_property_callback(sd_bus_message *msg, void *data,
*str = strdup(*str);
}
}
if (strcmp(prop, "Status") == 0 || (sni->status && (sni->status[0] == 'N' ?
prop[0] == 'A' : strncmp(prop, "Icon", 4) == 0))) {
set_sni_dirty(sni);
}
cleanup:
free(data);
return ret;
@ -185,6 +197,7 @@ static int handle_new_status(sd_bus_message *msg, void *data, sd_bus_error *erro
free(sni->status);
sni->status = strdup(status);
wlr_log(WLR_DEBUG, "%s has new Status '%s'", sni->watcher_id, status);
set_sni_dirty(sni);
}
return ret;
}

Loading…
Cancel
Save