2015-11-13 00:31:47 +11:00
|
|
|
#include <stdio.h>
|
2015-11-13 11:04:01 +11:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <wayland-client.h>
|
2015-11-14 02:27:16 +11:00
|
|
|
#include <time.h>
|
2015-11-13 11:04:01 +11:00
|
|
|
#include "client.h"
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
struct client_state *state;
|
|
|
|
|
|
|
|
void sway_terminate(void) {
|
|
|
|
client_teardown(state);
|
|
|
|
exit(1);
|
|
|
|
}
|
2015-11-13 00:31:47 +11:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2015-11-13 11:04:01 +11:00
|
|
|
init_log(L_INFO);
|
2015-11-14 06:42:45 +11:00
|
|
|
if (!(state = client_setup())) {
|
|
|
|
return -1;
|
|
|
|
}
|
2015-11-13 11:04:01 +11:00
|
|
|
|
2015-11-13 11:35:39 +11:00
|
|
|
uint8_t r = 0, g = 0, b = 0;
|
|
|
|
|
2015-11-14 02:27:16 +11:00
|
|
|
long last_ms = 0;
|
2015-11-13 11:35:39 +11:00
|
|
|
int rs;
|
2015-11-13 11:04:01 +11:00
|
|
|
do {
|
2015-11-14 02:27:16 +11:00
|
|
|
struct timespec spec;
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &spec);
|
|
|
|
long ms = round(spec.tv_nsec / 1.0e6);
|
|
|
|
|
2015-11-13 11:35:39 +11:00
|
|
|
cairo_set_source_rgb(state->cairo, r, g, b);
|
2015-11-13 11:04:01 +11:00
|
|
|
cairo_rectangle(state->cairo, 0, 0, 100, 100);
|
|
|
|
cairo_fill(state->cairo);
|
2015-11-13 11:35:39 +11:00
|
|
|
|
|
|
|
rs = client_render(state);
|
|
|
|
|
2015-11-14 02:27:16 +11:00
|
|
|
if (ms - last_ms > 100) {
|
|
|
|
r++;
|
|
|
|
if (r == 0) {
|
|
|
|
g++;
|
|
|
|
if (g == 0) {
|
|
|
|
b++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ms = last_ms;
|
2015-11-13 11:35:39 +11:00
|
|
|
}
|
|
|
|
} while (rs);
|
2015-11-13 11:04:01 +11:00
|
|
|
|
|
|
|
client_teardown(state);
|
2015-11-13 00:31:47 +11:00
|
|
|
return 0;
|
|
|
|
}
|