aboutsummaryrefslogtreecommitdiff
path: root/swaybg
diff options
context:
space:
mode:
Diffstat (limited to 'swaybg')
-rw-r--r--swaybg/CMakeLists.txt2
-rw-r--r--swaybg/main.c19
2 files changed, 16 insertions, 5 deletions
diff --git a/swaybg/CMakeLists.txt b/swaybg/CMakeLists.txt
index 8da31faa..5a46ffb8 100644
--- a/swaybg/CMakeLists.txt
+++ b/swaybg/CMakeLists.txt
@@ -23,7 +23,7 @@ add_executable(swaybg
${common}
)
-TARGET_LINK_LIBRARIES(swaybg ${WAYLAND_CLIENT_LIBRARIES} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES})
+TARGET_LINK_LIBRARIES(swaybg ${WAYLAND_CLIENT_LIBRARIES} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES} -lm)
install(
TARGETS swaybg
diff --git a/swaybg/main.c b/swaybg/main.c
index 5ceb94bc..af0a1b27 100644
--- a/swaybg/main.c
+++ b/swaybg/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);