diff options
Diffstat (limited to 'swaybg')
-rw-r--r-- | swaybg/CMakeLists.txt | 2 | ||||
-rw-r--r-- | swaybg/main.c | 19 |
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 | |||
23 | ${common} | 23 | ${common} |
24 | ) | 24 | ) |
25 | 25 | ||
26 | TARGET_LINK_LIBRARIES(swaybg ${WAYLAND_CLIENT_LIBRARIES} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES}) | 26 | TARGET_LINK_LIBRARIES(swaybg ${WAYLAND_CLIENT_LIBRARIES} ${CAIRO_LIBRARIES} ${PANGO_LIBRARIES} -lm) |
27 | 27 | ||
28 | install( | 28 | install( |
29 | TARGETS swaybg | 29 | 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 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <wayland-client.h> | 3 | #include <wayland-client.h> |
4 | #include <time.h> | ||
4 | #include "client.h" | 5 | #include "client.h" |
5 | #include "log.h" | 6 | #include "log.h" |
6 | 7 | ||
@@ -17,18 +18,28 @@ int main(int argc, char **argv) { | |||
17 | 18 | ||
18 | uint8_t r = 0, g = 0, b = 0; | 19 | uint8_t r = 0, g = 0, b = 0; |
19 | 20 | ||
21 | long last_ms = 0; | ||
20 | int rs; | 22 | int rs; |
21 | do { | 23 | do { |
22 | if (!client_prerender(state)) continue; | 24 | struct timespec spec; |
25 | clock_gettime(CLOCK_MONOTONIC, &spec); | ||
26 | long ms = round(spec.tv_nsec / 1.0e6); | ||
27 | |||
23 | cairo_set_source_rgb(state->cairo, r, g, b); | 28 | cairo_set_source_rgb(state->cairo, r, g, b); |
24 | cairo_rectangle(state->cairo, 0, 0, 100, 100); | 29 | cairo_rectangle(state->cairo, 0, 0, 100, 100); |
25 | cairo_fill(state->cairo); | 30 | cairo_fill(state->cairo); |
26 | 31 | ||
27 | rs = client_render(state); | 32 | rs = client_render(state); |
28 | 33 | ||
29 | if (rs == 1) { | 34 | if (ms - last_ms > 100) { |
30 | sway_log(L_INFO, "rendering %d %d %d", r, g, b); | 35 | r++; |
31 | r++; g++; b++; | 36 | if (r == 0) { |
37 | g++; | ||
38 | if (g == 0) { | ||
39 | b++; | ||
40 | } | ||
41 | } | ||
42 | ms = last_ms; | ||
32 | } | 43 | } |
33 | } while (rs); | 44 | } while (rs); |
34 | 45 | ||