aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/main.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-12-16 20:09:23 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-12-16 20:09:23 -0500
commitadadb109a766ce70791fad38b02cc62a7b2e6b54 (patch)
tree1a743f5fa0a61cd4f5efb4f270e6816455f4c182 /swaybar/main.c
parentMake swaybar a little quieter (diff)
downloadsway-adadb109a766ce70791fad38b02cc62a7b2e6b54.tar.gz
sway-adadb109a766ce70791fad38b02cc62a7b2e6b54.tar.zst
sway-adadb109a766ce70791fad38b02cc62a7b2e6b54.zip
Only re-render swaybar when it has changed
Fixes #345
Diffstat (limited to 'swaybar/main.c')
-rw-r--r--swaybar/main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/swaybar/main.c b/swaybar/main.c
index 65d2a493..60687bc5 100644
--- a/swaybar/main.c
+++ b/swaybar/main.c
@@ -51,6 +51,7 @@ FILE *command;
51char *line, *output, *status_command; 51char *line, *output, *status_command;
52struct registry *registry; 52struct registry *registry;
53struct window *window; 53struct window *window;
54bool dirty = true;
54 55
55struct colors colors = { 56struct colors colors = {
56 .background = 0x000000FF, 57 .background = 0x000000FF,
@@ -278,6 +279,7 @@ void update() {
278 if (line[l] == '\n') { 279 if (line[l] == '\n') {
279 line[l] = '\0'; 280 line[l] = '\0';
280 } 281 }
282 dirty = true;
281 } 283 }
282 } 284 }
283 if (ioctl(socketfd, FIONREAD, &pending) != -1 && pending > 0) { 285 if (ioctl(socketfd, FIONREAD, &pending) != -1 && pending > 0) {
@@ -285,6 +287,7 @@ void update() {
285 char *buf = ipc_recv_response(socketfd, &len); 287 char *buf = ipc_recv_response(socketfd, &len);
286 free(buf); 288 free(buf);
287 ipc_update_workspaces(); 289 ipc_update_workspaces();
290 dirty = true;
288 } 291 }
289} 292}
290 293
@@ -425,8 +428,8 @@ int main(int argc, char **argv) {
425 window->height = height + MARGIN * 2; 428 window->height = height + MARGIN * 2;
426 429
427 do { 430 do {
428 if (window_prerender(window) && window->cairo) { 431 update();
429 update(); 432 if (dirty && window_prerender(window) && window->cairo) {
430 render(); 433 render();
431 window_render(window); 434 window_render(window);
432 } 435 }