Only re-render swaybar when it has changed

Fixes #345
master
Drew DeVault 9 years ago
parent 5a9cc96446
commit adadb109a7

@ -51,6 +51,7 @@ FILE *command;
char *line, *output, *status_command; char *line, *output, *status_command;
struct registry *registry; struct registry *registry;
struct window *window; struct window *window;
bool dirty = true;
struct colors colors = { struct colors colors = {
.background = 0x000000FF, .background = 0x000000FF,
@ -278,6 +279,7 @@ void update() {
if (line[l] == '\n') { if (line[l] == '\n') {
line[l] = '\0'; line[l] = '\0';
} }
dirty = true;
} }
} }
if (ioctl(socketfd, FIONREAD, &pending) != -1 && pending > 0) { if (ioctl(socketfd, FIONREAD, &pending) != -1 && pending > 0) {
@ -285,6 +287,7 @@ void update() {
char *buf = ipc_recv_response(socketfd, &len); char *buf = ipc_recv_response(socketfd, &len);
free(buf); free(buf);
ipc_update_workspaces(); ipc_update_workspaces();
dirty = true;
} }
} }
@ -425,8 +428,8 @@ int main(int argc, char **argv) {
window->height = height + MARGIN * 2; window->height = height + MARGIN * 2;
do { do {
if (window_prerender(window) && window->cairo) {
update(); update();
if (dirty && window_prerender(window) && window->cairo) {
render(); render();
window_render(window); window_render(window);
} }

Loading…
Cancel
Save