summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-11-13 10:27:16 -0500
committerDrew DeVault <sir@cmpwn.com>2015-11-13 10:27:16 -0500
commitc649f191933e84c9693553f361c994fb934a2795 (patch)
tree4d79677c15a8e5d3e1f914b763b5fc49db7fba37 /main.c
parent99e477b3bd1c97166513acb9e3037e9e473dd690 (diff)
downloadswaybg-c649f191933e84c9693553f361c994fb934a2795.tar.gz
swaybg-c649f191933e84c9693553f361c994fb934a2795.tar.bz2
Clean up some things better in wayland clients
Diffstat (limited to 'main.c')
-rw-r--r--main.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/main.c b/main.c
index 5ceb94b..af0a1b2 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <wayland-client.h>
+#include <time.h>
#include "client.h"
#include "log.h"
@@ -17,18 +18,28 @@ int main(int argc, char **argv) {
uint8_t r = 0, g = 0, b = 0;
+ long last_ms = 0;
int rs;
do {
- if (!client_prerender(state)) continue;
+ struct timespec spec;
+ clock_gettime(CLOCK_MONOTONIC, &spec);
+ long ms = round(spec.tv_nsec / 1.0e6);
+
cairo_set_source_rgb(state->cairo, r, g, b);
cairo_rectangle(state->cairo, 0, 0, 100, 100);
cairo_fill(state->cairo);
rs = client_render(state);
- if (rs == 1) {
- sway_log(L_INFO, "rendering %d %d %d", r, g, b);
- r++; g++; b++;
+ if (ms - last_ms > 100) {
+ r++;
+ if (r == 0) {
+ g++;
+ if (g == 0) {
+ b++;
+ }
+ }
+ ms = last_ms;
}
} while (rs);