diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-11-18 08:22:37 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-11-18 08:22:53 -0500 |
commit | f7c78d61e15d85729d3a83f3bf64336e452f20c9 (patch) | |
tree | f1e755126e43c30392ba0a4ad6f0c49fcaf62ce0 | |
parent | 8fa8326d1c1c190c3a7197673f75961f0642405e (diff) | |
download | swaybg-f7c78d61e15d85729d3a83f3bf64336e452f20c9.tar.gz swaybg-f7c78d61e15d85729d3a83f3bf64336e452f20c9.tar.bz2 |
Fix up wayland client implementation
Now it receives frame callbacks and renders properly, and is double
buffered and such.
-rw-r--r-- | main.c | 37 |
1 files changed, 12 insertions, 25 deletions
@@ -2,7 +2,7 @@ #include <stdlib.h> #include <wayland-client.h> #include <time.h> -#include "client.h" +#include "client/client.h" #include "log.h" struct client_state *state; @@ -14,36 +14,23 @@ void sway_terminate(void) { int main(int argc, char **argv) { init_log(L_INFO); - if (!(state = client_setup())) { + if (!(state = client_setup(100, 100))) { return -1; } - uint8_t r = 0, g = 0, b = 0; + uint8_t r = 100, g = 100, b = 100; - long last_ms = 0; - int rs; do { - 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 (ms - last_ms > 100) { - r++; - if (r == 0) { - g++; - if (g == 0) { - b++; - } - } - ms = last_ms; + if (client_prerender(state)) { + cairo_set_source_rgb(state->cairo, r / 256.0, g / 256.0, b / 256.0); + cairo_rectangle(state->cairo, 0, 0, state->width, state->height); + cairo_fill(state->cairo); + + client_render(state); + + r++; if (r == 0) { g++; if (g == 0) { b++; } } } - } while (rs); + } while (wl_display_dispatch(state->display) != -1); client_teardown(state); return 0; |